Create an EBS image from existing image

Follow

This guide describes how create an EBS image from an existing CentOS image. This article uses CentOS 5.8, should be applicable with other versions too.

Start a new instance,

euca-run-instances -k sshlogin emi-6D533ABF

Create and attach the volume,

euca-create-volume -s 5 -z cluster1
euca-attach-volume -i i-F8F74491 -d vdb vol-76483E6C

Login the instance and create a new partition on the attached volume,

fdisk /dev/vdb

Run the following to convert and copy the image to the volume,

dd if=<image name> bs=1M | ssh -i sshlogin root@10.104.3.128 "dd of=/dev/vdb1 bs=1M"

Login to the instance and set the volume label of the filesystem,

tune2fs -L rootdisk /dev/vdb1

Mount the partition of the volume,

mount /dev/vdb1 /mnt/

Change the following line from /mnt/etc/fstab

LABEL=rootdisk         /             ext3     defaults,errors=remount-ro 0 0

Copy the grub files,

cp /mnt/usr/share/grub/x86_64-redhat/* /mnt/boot/grub/

Copy a known-good kernel and ramdisk from your Eucalyptus cloud to your new instance /mnt/boot/


Modify the /mnt/boot/grub/grub.conf accordingly, in particular ensure that the kernel line has

console=ttyS0 console=tty0 

to ensure that euca-get-console-output will work accordingly.


Install grub on the new root device,

mount -o bind /proc /mnt/proc
mount -o bind /dev /mnt/dev
chroot /mnt
# echo "(hd0) /dev/vdb" > /tmp/device.map
# grub --batch --no-floppy --device-map=/tmp/device.map << EOF
> device (hd0) /dev/vdb
> root (hd0,0)
> setup --stage2=/boot/grub/stage2 (hd0)
> quit
> EOF
exit

Unmount everything,

umount /mnt/proc
umount /mnt/dev
umount /mnt

Detach the volume,

euca-detach-volume vol-76483E6C

Create snapshot and register Emi,

euca-create-snapshot vol-76483E6C
euca-register -a x86_64 -n centos58_ebs --root-device-name /dev/vda -b /dev/vda=snap-93A63F3D
Have more questions? Submit a request

Comments

Powered by Zendesk