I have an Amazon EC2 instance that is using an instance-store as its root device. It has no EBS volumes attached to it. It has a database and a running web application on it. If I understand correctly this is a bad setup as I would lose all the data on the instance if it were to reboot. I would like to correct this mistake. I'd like to move all the data on the running instance to a new EBS volume and make that new volume the root device. How do I go about doing this?


2 Answers 2


Basically you just need to copy the running instance to am EBS volume. Before doing this stop any services which change things on the filesystem (mysql, etc...)

So create a volume, make sure it's in the same availability zone as your s3 backed instance, and attach it to that instance.

ec2-create-volume -s 10 -z us-east-1d
ec2-attach-volume -i i-instance_id -d /dev/sdh

Copy everything over to the ebs volume and validate.

dd bs=65536 if=/dev/sda1 of=/dev/sdh
fsck /dev/sdh

Then mount the drive

mkdir -p 000 /ebs
mount /dev/sdh /ebs

make sure /ebs/etc/fstab wont try and mount anything that's not there, then unmount the drive

umount /dev/sdh

You can then create a snapshot of that volume, then you can ec2-register it as an ami, you have to do this from the command line, I don't think you can register an ami from a snapshot using the web interface.

  • thanks. There are two disks on the system /dev/sda1 and /dev/sda2, do I copy both to that EBS? does that take two dd commands?
    – Adam
    Commented Mar 16, 2011 at 16:02
  • Ah, i'm answering both questions, aren't I. Depends if you have anything in /mnt or not. If you do it might be better to format the drive then rsync everything to the ebs volume.
    – Decado
    Commented Mar 16, 2011 at 16:56

At a high level, you:

a) Create an EBS volume
b) Attach the EBS volume to the correct instance
c) Format and mount the volume so the operating system can use it.

The first two can be done easiest from the AWS Management Console. The last task depends on your OS but for linux here is one link that will help: http://www.randomtools.net/how-to-mount-amazon-ec2-ebs-volume-on-an-instances-file-system-76.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .