When you attach an EBS volume to an EC2 instance, you can specify a device name for the volume (by default, one is filled in for you). The block device driver of the EC2 instance also assigns a volume name when mounting the volume, and that name might be different from the name that you assign.
For more details on device naming, see Device Naming on Linux Instances or Device Naming on Windows Instances.
If you specify a device name that is not in use by EC2, but is being used by the block device driver within the EC2 instance, the attachment of the EBS volume does not succeed and the EBS volume is stuck in the attaching state. This is usually due to one of the following reasons:
The block device driver is remapping the specified device name
For example, if your HVM EC2 instance has a root device attached on /dev/sda1, and you attempt to attach a secondary EBS volume to /dev/xvda, the secondary EBS volume will not successfully attach to the instance. This is because on an HVM instance, /dev/sda1 remaps to /dev/xvda, so an attempt to attach a volume to /dev/xvda results in the volume being stuck in the attaching state.
The device name was not released by the block device driver
If a user has initiated a forced detach of an EBS volume, the block device driver of the EC2 instance might not immediately release the device name for reuse, and attempting to use that device name when attaching a volume causes the volume to be stuck in the attaching state.
Before taking any action, make sure your data is backed up, either with an EBS snapshot or a manual backup solution. After your data is backed up, you can resolve most issues with volumes stuck in the attaching state by following these steps:
- In the Volumes pane of the Amazon EC2 console, select the volume and choose Force Detach Volumes from the Actions menu.
- When the instance is in the “running” state, attempt to attach the volume to the instance again.
If these steps don’t resolve the issue, and the device driver still appears to be busy, reboot the instance.
You might also need to choose a different block device name for the instance to use. For instructions for a Linux instance, see Instance Block Device Mapping; for Windows, see Mapping Disks to Volumes on your Windows EC2 Instance. If you’re attempting to use a block device name that was previously in use by another volume, the OS might not have released the block device name for reuse; try force detaching the volume and rebooting the instance.
If you continue to experience difficulties, please open a case with the TD SYNNEX Public Sector Operations Center.
Article is closed for comments.