Creating a Boot From EBS (bfEBS) image


Hi all,

I recently spent some time investigating this with my good colleague Andy Grimm. I had some initial issues in creating a RHEL6 image for KVM which would boot from EBS. Boot from EBS (sometimes referred to as bfEBS) is a new feature in Eucalyptus 3.X which allows a cloud administrator to back an instance with an EBS volume, thus giving persistence in the VM. This feature is present in AWS.

Below are some of my steps I used to create a RHEL6 guest image as a bfEBS volume. Note that I was using RHEL6 + KVM as the hypervisor:

1) Stop eucalyptus-nc on a designated host (or use another KVM host somewhere)
2) On the designated host, use qemu-img create to create a disk image:

qemu-img create -f raw rhel6_bfebs.img 2G

3) Set the disk label using parted: parted rhel6_bfebs.img mklabel msdos
4) Use virt-install to kick off a from-scratch installation:

virt-install --name rhel6-bfebs2 --ram 1024 --os-type linux --os-variant rhel6 \
-l http://192.168.7.65/rhel/releases/6.1/6Server/--disk \
path=/tmp/rhel6_bfebs.img,bus=virtio --vnc -x "lang=en_US keymap=us"

In your kickstart .cfg :

clearpart --all --drives=vda  --initlabel
 part / --size=512 --grow --fstype ext3 --ondisk=vda

Tweak as required :)

5) Complete the install then using virt-manager or other libvirt tool, start up the guest again (since finishing the install process is sometimes likely to shut it down, rather than reboot due to power mgmt).
6) Inside the guest:

- Remove the HWADDR line from /etc/sysconfig/network-scripts/ifcfg-eth0 <- this strips out the MAC address
- In /boot/grub/menu.lst for kernel option pass: console=ttyS0 at the end <- this will give you a serial console
– In /boot/grub/menu.lst also remove quiet option from kernel params and the grub menu splash image
– Edit /etc/sysconfig/network and add NOZEROCONF=yes  (disable the zeroconf route, which can mess up access to metadata service)
– Edit /etc/udev/rules.d/70-persistent-net.rules and remove the entry for existing NIC completely
Then, don’t forget to use our rc.local from here:  https://github.com/EucalyptusSystems/Eucalyptus-Scripts/blob/master/rc.local

7) On the instance, you can always mount the volume and check stuff:

hdparm -z /dev/vdX (re-read partition table)
 mount /dev/vdX /mnt/test

8) Make sure you unmount the EBS volume, if attached. Then detach the volume from the instance:

euca-detach-volume <volumeID>

9) Now snapshot the volume:

euca-create-snapshot<volumeID>

10) Register the snapshot (after it has completed):

euca-register -n "MyRHEL6bfEBS" -s <volumeID>

Done! Run your EBS-backed instance. Make sure that when you want to stop/start that you use the following commands:

euca-stop-instances
euca-start-instances

Otherwise, unless you’re using image attributes you’ll end up with the underlying volume being destroyed when you use euca-terminate-instances.  There goes your persistence ;)

About these ads

4 thoughts on “Creating a Boot From EBS (bfEBS) image

  1. Great doc.

    I am using the following rc.local w/ bfEBS volumes

    #!/bin/sh -e
    depmod -a
    modprobe acpiphp || true

    # delete previous hostname from /etc/hosts
    sed -i ‘/eucalyptus.internal/d’ /etc/hosts

    # set the hostname to something sensible
    META_HOSTNAME=”`curl -s http://169.254.169.254/latest/meta-data/local-hostname
    META_IP=”`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`”

    hostname $META_HOSTNAME
    SHORT_HOSTNAME=`hostname -s`
    echo >> /etc/hosts
    echo “${META_IP} ${META_HOSTNAME} ${SHORT_HOSTNAME}” >> /etc/hosts

    exit 0

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