This is handy for a lot of reasons, like rescuing disk data or fixing boot configuration. The detail is here at the Amazon documentation. The outline of steps is below:
- Stop the original instance.
- Detach the volume from the stopped instance.
- Create a new instance of similar type to the original instance and assign the same security group.
- Start the new instance.
- Attach the detached original volume to the new instance as /dev/xvdf
- Login to the new instance, create mount point and mount the original volume.
- Once completed, umount the original volume and detach from the new instance.
- Attach the original volume to the original instance as /dev/sda1
- Start the original instance.
Essential commands for this, based on Ubuntu. Some steps above are done in the AWS Console GUI.
ubuntu:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk xvda1 202:1 0 8G 0 part / xvdf 202:80 0 10G 0 disk xvdf1 202:81 0 10G 0 part ubuntu:~$ sudo file -s /dev/xvdf /dev/xvdf: x86 boot sector ubuntu:~$ sudo mkdir /rescue ubuntu:~$ sudo mount /dev/xvdf1 /rescue