Amazon EC2 - Swap root instance store device with EBS device?

You could migrate your running instance to an EBS backed AMI. Here's how I did it: Boot up a regular S3 AMI backed instance (or since you've already got an instance you're happy with, use that) Make an EBS volume of the same size as your root sda1 partition (currently the default is 10G for an m1. Small and possibly others) Attach that EBS volume to a free block device on the instance using the web console or command line tools (e.g. /dev/sdd) Stop the services on the instance (e.g. /etc/init.

D/mysql stop etc.) Copy the ephemeral root volume to the EBS volume: dd bs=65536 if=/dev/sda1 of=/dev/sdd Check the EBS volume for consistency: fsck /dev/sdd Mount the EBS volume onto the instance: mount /dev/sdd /root/ebs-vol Remove the /mnt entry from the fstab on your EBS vol: vim /root/ebs-vol/etc/fstab Unmout the EBS volume: umount /dev/sdd Create a snapshot of the EBS volume using the AWS management console (or command line API tools) Make note of the snapshot id Register the snapshot image with AWS and take note of the AMI id produced, when registering remember to specify the kernel and ramdisk image (these should be the same as those used in your current instance): ec2-register -s snap-12345 -a i386 -d "Description of AMI" -n "name-of-image" -k aki-12345 -r ari-12345 To create an instance with more than 10G of persistent storage you have to use the cli tools. E.g. For 20G ec2-run-instances ami-54321 -t m1.

Small -n 1 -g default --availability-zone=eu-west-1a -k ec2-key1 -b /dev/sda1=snap-12345:20:false If you boot up an instance based on one of these AMIs with > default volume size, once it's started up you can do an online resize of the filesystem: resize2fs /dev/sda1.

1 nice instructions, although I don't think it's what the OP wants. – kdgregory Jan 20 '10 at 12:57 1 Thank you very much for the comprehensive answer. That's great – Sug Feb 3 '10 at 21:46 We basically did the same, but used rsync with excludes instead of dd, worked like a charm too.

One more thing to take care of (I know it's obvious, but it happens over and over again): when creating your EBS volume, make sure to double check it's in the same region as the instance you want to attach it to ;-) – Michael Kohl Mar 10 '10 at 14:56.

You might also try the following tool to convert an instance-store AMI to an ebs-boot AMI: https://cloudyscripts. Com/tool/show/2.

Great work on this tool! – Andy Oct 7 '10 at 15:24 agreed...awesome tool – dbyrne Mar 13 at 0:23.

This can be done without creating a new AMI and without launching a new instance. When it's done the original root volume stays attached on /dev/sda1 (or wherever it was originally mounted. /dev/sda1 is the default for many AMIs).

The original root volume will not be mounted to the filesystem - you'd need to do that yourself via the "mount" command. The technique requires the recent Ubuntu kernels, the ones that run in their 10.04 and 10.10 releases. Check out alestic.Com for the most recent AMI IDs for these Ubuntu releases.

These recent kernels are configured to boot from any attached device whose volume label is "uec-rootfs". If you are running one of these kernels all you need to do is to change the volume label of the current (instance-store) root volume to something else, change the volume label of the new root to uec-rootfs, and then reboot. If you're not running one of these kernels, you can't use this technique.

Here's the code. Put this in a file (reroot.Sh) on the instance: #! /bin/bash device=$1 # change the filesystem labels e2label /dev/sda1 old-uec-rootfs e2label $device uec-rootfs First you would attach the EBS volume you want to act as the new root to one of the available devices /dev/sdf../dev/sdp.

This can be done either with direct EC2 API calls, with the EC2 Command Line API tools (ec2-attach-volume), or with a library such as boto, or via the AWS Management Console UI. Then, run the reroot. Sh script as root, and provide the device you attached the new root volume on, as follows: sudo reroot.

Sh /dev/sdp This will do the dirty work. Then you simply reboot: sudo shutdown -r now Viola. To test this you should create an EBS volume that you know will boot properly.

I like to do that by snapshotting the root volume of the EBS-backed AMIs from those above mentioned Ubuntu AMIs. From that snapshot you can create a new, bootable EBS volume in any Availability Zone. Make sure you can tell the difference between the running instance's original root volume and the new EBS root volume - before you run the reroot procedure above you can put in a "marker" file on the old root volume: cd touch this-is-the-original-root-volume Then, when you reroot and reboot, if that file exists in your home directory you're still running with the original root volume.

If it's not there, then the reroot-and-reboot worked. Here are two example use cases for this technique, with thorough explanations: http://shlomoswidler.com/2011/02/play-chicken-with-spot-instances.html http://shlomoswidler.com/2011/02/recapture-unused-ec2-minutes.html.

1, and thanks for making the note on my answer ... it's now deleted. – kdgregory Mar 31 at 12:19.

AlexM has come up with good steps. You would also be interested in checking this link: coderslike.us/2009/12/07/amazon-ec2-boot... EDIT: Another link: elastician.com/2009/12/creating-ebs-back....

I'm not sure how easy it would be to convert an existing instance, but Amazon now offers the ability to boot directly from an EBS volume when you create a new instance.

In place of the other long comment on here, I used the following command to do this: ec2-register --snapshot snap-9eb4ecf6 --architecture i386 --name "Zenoss Enterprise 3.0 beta 2 on centOS" --description "This is from an install of zenoss core beta 1 and zenoss enterprise beta 2, both of version 3.0 (or internally 2.5.70 217). An ebs block device was attached, and the file system rsynced over, then ebs was snapshotted and this is basedd off that. " --root-device-name /dev/sda1 --kernel aki-9b00e5f2.

This can be done without creating a new AMI and without launching a new instance. When it's done the original root volume stays attached on /dev/sda1 (or wherever it was originally mounted. /dev/sda1 is the default for many AMIs).

The original root volume will not be mounted to the filesystem - you'd need to do that yourself via the "mount" command. The technique requires the recent Ubuntu kernels, the ones that run in their 10.04 and 10.10 releases. Check out alestic.com for the most recent AMI IDs for these Ubuntu releases.

These recent kernels are configured to boot from any attached device whose volume label is "uec-rootfs". If you are running one of these kernels all you need to do is to change the volume label of the current (instance-store) root volume to something else, change the volume label of the new root to uec-rootfs, and then reboot. If you're not running one of these kernels, you can't use this technique.

Here's the code. First you would attach the EBS volume you want to act as the new root to one of the available devices /dev/sdf../dev/sdp. This can be done either with direct EC2 API calls, with the EC2 Command Line API tools (ec2-attach-volume), or with a library such as boto, or via the AWS Management Console UI.

This will do the dirty work. To test this you should create an EBS volume that you know will boot properly. I like to do that by snapshotting the root volume of the EBS-backed AMIs from those above mentioned Ubuntu AMIs.

From that snapshot you can create a new, bootable EBS volume in any Availability Zone. Then, when you reroot and reboot, if that file exists in your home directory you're still running with the original root volume. If it's not there, then the reroot-and-reboot worked.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions