This guide walks through the steps required to build a RHEL-based bfEBS Eucalyptus Machine Image from scratch. You will need access to installation media for the distribution, either through .iso media or a via a network repository.
This process has been tested against with RHEL6.1 but the steps will be much the same for RHEL/Centos 5 & 6. A node controller was used for the build process (eucalyptus-nc service was stopped) and the RHEL install tree was available on a web server.
# cd /tmp
In a convenient working directory, create a new 4GB disk image for the system using qemu-img and set the disk label with parted:
# qemu-img create -f raw rhel6-x86-64.img 4G
# parted rhel6-x86-64.img mklabel msdos
Use virt-install to kick off a kickstarted installation of RHEL, creating a single root partition inside the image:
# virt-install --name rhel6-bfebs --ram 1024 --os-type linux --os-variant rhel6 -l http://192.168.1.10/rhel/releases/6.1/6Server/ --disk path=/tmp/rhel6-x86-64.img,bus=virtio --vnc -x "lang=en_US keymap=us ks=http://192.168.1.10/bfebs/bfs_instance.cfg"
NOTE - At this point you could remove the "ks" option and perform the install manually and interactively.
This will spawn a virt-viewer connection to the VNC server. Complete the kickstart or interactive installation and reboot the virtual machine.
NOTE - After install the virtual machine may terminate rather than reboot due to power management. If this is the case, simply restart the VM.
Preparing the System
Once the guest has rebooted, log into the virtual machine and make the following changes:
Remove the HWADDR line from /etc/sysconfig/network-scripts/ifcfg-eth0
Add the NOZEROCONF line to /etc/sysconfig/network:
# echo "NOZEROCONF=yes" >> /etc/sysconfig/network
Remove the udev rule for networking:
# rm -f /etc/udev/rules.d/70-persistent-net.rules
Ensure that SELinux is set to permissive:
# sed -i -e "s/SELINUX=enforcing/SELINUX=permissive/" /etc/sysconfig/selinux
Disable the plymouth boot splash:
# plymouth-set-default-theme details --rebuild-initrd
To ensure the console gets updated with the kernel messages (ie euca-get-console-output will work) make sure that in /etc/grub.conf the line with kernel contains
Finally, import the Eucalyptus rc.local file (assuming you have internet connectivity, otherwise copy manually to the VM):
# curl https://raw.github.com/eucalyptus/Eucalyptus-Scripts/master/rc.local -o /etc/rc.local
Copying into the EBS Volume
Shutdown the virtual machine and restart the eucalyptus-nc process. You may want to compress your image to make it easier and quicker to transfer between machines:
# gzip rhel6-x86-64.img
Copy this compressed image to a machine whereby you can login to a Eucalyptus instance (i.e. that has your SSH key and euca2ools).
Create a new EBS volume with sufficient size for your instance:
$ euca-create-volume -z az -s 4
Start another Linux instance on your cloud and attach the same EBS volume:
$ euca-run-instances -k mykey -g ssh -z myaz -t m1.small emi-123456$ euca-attach-volume -i <instanceID> -d vdb <volumeID>
Next, SSH and uncompress the disk image straight onto the new EBS volume:
# cat rhel6-x86-64.img.gz | ssh -i <privatekey> root@<instanceIP> "zcat - > /dev/vdb"
On the instance, you can now mount and check the volume:
# hdparm -z /dev/vdb
# mount /dev/vdb /mnt
At this point you can make last minute changes to the image prior to bundling. When you are happy with this, detach the volume.
# umount /dev/vdb
$ euca-detach-volume <volumeID>
Snapshot & Register
Next, snapshot the volume:
$ euca-create-snapshot <volumeID>
Finally, register the snapshot:
$ euca-register -n "RHEL6bfEBS" -s <snapshotID>
Now you can run your bfEBS instance in the cloud!