AWS EBS Volume Stuck in 'Attaching' State – The Fix
Your EBS volume won't attach to an EC2 instance. Here's the real fix, why it works, and how to avoid it next time.
The Stuck Volume Pain
You've attached an EBS volume to an EC2 instance, and it's been spinning in attaching state for five minutes. You've checked the console, waited, maybe rebooted the instance. Nothing. I've been there. Here's how to get it unstuck.
The Immediate Fix
First, stop the EC2 instance. Yes, stop it — not reboot. Go to the EC2 console, select your instance, click Instance State > Stop. Wait until it shows stopped (this can take a minute or two).
Now detach the stuck volume. In the console, go to Elastic Block Store > Volumes, select the stuck volume, click Actions > Detach Volume. For Force Detach, check the box. This bypasses any filesystem locks. Click Detach.
Re-attach the volume. Select the same volume, click Actions > Attach Volume. Choose your instance from the dropdown. Leave the device name as default (usually /dev/sdf or /dev/xvdf). Click Attach. The volume should show attached within 30 seconds.
Start your instance again: Instance State > Start.
After restarting, SSH into your instance. Run lsblk to confirm the volume shows up. You'll see something like xvdf or nvme1n1 depending on your instance type. If it's a new volume (not yet formatted), you'll need to format and mount it. That's a different guide, but you're past the attachment problem.
Why This Works
The stuck attaching state happens because the EC2 instance's hypervisor gets confused when a volume attaches while the instance is running. It's a race condition — the volume's metadata says it's attached, but the OS never acknowledged it. Stopping the instance clears that metadata lock. Forcing the detach tells AWS to ignore any pending I/O operations. Re-attaching while stopped gives a clean handshake.
Skipping the stop step? You'll see the same stuck state again. I've tested this on Amazon Linux 2, Ubuntu 22.04, and Windows Server 2022. Every time, the stop-and-detach approach works.
Less Common Variations
Volume Attaches but Shows 'Error' State
If the volume attaches briefly then shows error, you're hitting a different problem. The volume might be detached from another instance with a filesystem that's still dirty. Run sudo fsck -f /dev/xvdf (replace with your device) on the old instance before moving it. On Windows, you'll need to check disk using chkdsk.
Volume Attaches but Not Visible Inside the Instance
This is weird but happens. The volume shows attached in the console, but lsblk doesn't see it. Reason: the instance uses NVMe drivers, and the device name you chose (like /dev/sdf) doesn't match what the kernel expects. Naming conventions for NVMe volumes are /dev/nvme1n1, /dev/nvme2n1, etc. The fix: detach the volume, re-attach it with a generic name like /dev/sdf (AWS maps it correctly behind the scenes), then in the OS check lsblk again. Or use AWS's recommended mapping: for Nitro instances, always use /dev/sd[b-z] and don't worry about the NVMe names — AWS handles the translation.
Volume Stuck on Detach (Reverse Problem)
Sometimes you can't detach a volume. It stays detaching indefinitely. This is the same root cause: the instance has the filesystem mounted and won't yield. Stop the instance (again), then force detach. If you can't stop the instance because it's production, you can try sudo umount -f /mnt/volume on Linux, or Dismount-VHD on Windows, then detach normally. But be careful — force unmounting without proper sync can corrupt the filesystem.
Prevention
Don't attach or detach EBS volumes while the instance is running if you can avoid it. It works 99% of the time, but that 1% is a headache. For production workloads, use lifecycle hooks or automation scripts that stop the instance before making volume changes.
Also, keep your EBS volumes in the same Availability Zone as the instance. AWS won't let you attach a volume from us-east-1aus-east-1b. That's a different error (invalidParameterValue), but I've seen people confuse it with the stuck issue.
Finally, use the AWS CLI for quick checks. The command aws ec2 describe-volumes --volume-ids vol-xxxxxxxx --query 'Volumes[0].State' tells you the state without the console lag. If it's stuck, you'll see "attaching" for minutes. Normal attachment takes under 10 seconds.
One last thing: if you're using Windows, the same stop-instance trick works. But after re-attaching, go to Disk Management (diskmgmt.msc) and bring the volume online if it shows as offline. Linux doesn't have that step.
Was this solution helpful?