Convert an Instance-Store AMI to EBS-Backed AMI
- Launch an instance from an instance store-backed AMI.
- Make a note of the ramdisk ID and kernel ID your running instance is using
- Create a 10GiB Amazon EBS volume in the same Availability Zone as that of your newly-launched instance e.g. /dev/sdf
- Attach the volume to the running instance using either the AWS Management Console or the command line interface.
- Make sure all services are turned off like mysqld, nginx etc.
- Format the volume with a file system. Newer kernels use /dev/xvdf convention
-
mkfs.ext3 /dev/xvdf
- Create a directory /mnt/ebs and mount the volume on it.
-
mkdir /mnt/ebs
-
mount /dev/xvdf /mnt/ebs
- Copy the data on the root storage device to the newly-attached volume.
- rsync -avx --exclude /mnt/ebs / /mnt/ebs
- [SPECIFIC TO UBUNTU]
-
Edit
/mnt/ebs/etc/fstab,/mnt/ebs/boot/grub/menu.lst
and /mnt/ebs/boot/grub/grub.cfg and replace uses of LABEL=cloudimg-rootfs with /dev/xvda1
- Remove /dev/xvda2 and /dev/xvda3 specific instructions from /mnt/ebs/etc/fstab
- [SPECIFIC TO CENTOS]
- Edit /mnt/ebs/etc/fstab,/mnt/ebs/boot/grub/menu.lst and replace uses of LABEL=/ with /dev/xvde1.
- Remove /dev/xvde2 and /dev/xvde3 specific instructions from /mnt/ebs/etc/fstab
- Create the following devices within the /mnt/ebs
- MAKEDEV console
- MAKEDEV generic
- MAKEDEV zero
- MAKEDEV null
- Detach the volume from the instance.
- Create a snapshot of the volume.
- Register the snapshot of the volume as an AMI. While registering make sure you enter the architecture correct and the Kernel ID and Ramdisk ID should match the one taken a note of in Step 2. If the Ramdisk ID information is not available form the instance then leave it to Use Default.
Comments
Post a Comment