Re-mounting an AWS EBS Volume to another instance

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:

  1. Stop the original instance.
  2. Detach the volume from the stopped instance.
  3. Create a new instance of similar type to the original instance and assign the same security group.
  4. Start the new instance.
  5. Attach the detached original volume to the new instance as /dev/xvdf
  6. Login to the new instance, create mount point and mount the original volume.
  7. Once completed, umount the original volume and detach from the new instance.
  8. Attach the original volume to the original instance as /dev/sda1
  9. 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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s