Custom Images via boot.rackspace.com - Training Wheels Included
To simplify the custom image creation process, Rackspace released boot.rackspace.com, a collection of iPXE scripts that allows you to rapidly network boot Operating Systems, Utilities and other tools very easily. It's especially useful for remote access environments when you don't want to utilize remote attached CD's in a Dell DRAC, HP iLO or some other type of remote tool. It's especially awesome for bootstrapping your own custom installation on a Cloud Server!
In this post, I will walk you through each of the steps required to get you up & running a custom version of Ubuntu 12.04 via boot.rackspace.com.
- Versions of Ubuntu greater than 12.04 have not been thorougly tested with this tutorial. Therefore, it is recommended you too use Ubuntu 12.04.
1. Boot the boot.rackspace.com ISO
This command will boot a Cloud Server with a small 1 MB iPXE based ISO. In turn, it will set up the server’s assigned networking within the virtual BIOS and netboot into a menu of operating system options hosted over HTTP on boot.rackspace.com.
nova boot --image=9aa0d346-c06f-4652-bbb1-4342a7d2d017 --flavor=performance1-2 my_ubuntu_1204
2. Connect to the boot.rackspace.com VM via the Console
- Log into mycloud.rackspace.com
- Once the VM is 'Active,' click on the 'Actions' available in the Server Details, and select 'Connect Via Console'
2. Select Linux Operating Systems from the Boot Menu
3. Select Ubuntu from the list of Distros
4. Select 12.04 from the list of Versions
5. Select ubuntu install from the the Boot Paramaters
6. Proceed through the install & setup accordingly
- In addendum to custom modifications, make sure to do the following:
- During partioning:
- Select 'Guided - use entire disk'
- Use the 'Virtual disk 1 (xvda) - 42.9 GB`
- Select OpenSSH server during the software install process
- Install the GRUB boot loader to the master boot record
- During partioning:
7. Reboot from local hdd
Once the installation is complete, the VM will reboot and the console will disconnect. Reconnect to the console, but this time, select to boot from the Local HDD as we've already installed the OS and because iPXE by default does a netboot.
8. Instance configuration required by Rackspace
To configure the instance, you must first get to the prompt. You can do this via the console from the browser, or by SSH'ing into the VM (SSH may be easier to work with)
sudo apt-get update && sudo apt-get install curl -y
Now proceed to install XenServer Tools & Nova Agent
- XenServer Tools
- The XenTools are needed for communication between the host and the guest for configuration via the xenstore
curl -skS -L http://git.io/nUeUrA | sudo bash
- Nova Agent
- The Nova Agent is used for configuration of the instance. It handles detection of the Operating System type and sets the appropriate networking configuration. It also handles password resets, configuration of any licensing for Red Hat and Windows, versioning, and the ability to handle updates of itself
curl -skS -L http://git.io/_tdvZw | sudo bash
- Clear out the network interfaces
(cat | sudo tee /etc/network/interfaces) << EOF auto lo iface lo inet loopback EOF
9. Make custom OS modifications
This is the opportunity to install, configure and set up any custom system level modifications you want to persist for future instances of the image
10. Once modifications are complete, cleanup your image
- Typically, you'll want to remove the following before taking the snapshot
to have a clean, pristine image:
- local files in root & other user home directories
- log files
- ssh_host keys
- unnecessary files
11. After modifications and cleanup is done, snapshot your image
In the Server Details, select 'Create Image' to snapshot the image as-is and give it a name, i.e. 'myubuntu1204'
12. Set metadata for the image
Set vm_mode to:
- "xen" for a Paravirtualized (PV) Instance. For most Linux VMs, PV is typically the best option.
- "hvm" for HVM Mode, typically used for FreeBSD, Linux PVHVM and Windows. When using with Linux, make sure you're using one of the newer 3.x kernels for the best experience.
If using Nova Agent:
If using Cloud-Init exclusively, the Agent isn't needed, so make sure to disable it so that the build isn't actively polling for responses from the Nova Agent:
nova image-meta my_ubuntu_1204 set vm_mode=xen nova image-meta my_ubuntu_1204 set xenapi_use_agent=true
13. After snapshotting, its time to boot your custom image
nova boot --image="my_ubuntu_1204" --flavor=performance1-2 my_ubuntu_1204_test
14. Log in to the VM via console and/or SSH & enjoy your new custom image :)
- Once you save/snapshot your custom image, you must use a Performance Flavor to boot the VM
- After snapshotting & testing the boot of the custom image, it is safe to delete the initial boot.rackspace.com ISO VM
About the Author
Mike Metral is a Solution Architect at Rackspace in the Private Cloud Product organization. Mike joined Rackspace in 2012 with the intent of helping OpenStack become the open standard for cloud management. At Rackspace, Mike has led the integration effort with strategic partner RightScale; aided in the assessment, development, and evolution of Rackspace Private Cloud; as well as served as the Chief Architect of the Service Provider Program. Prior to joining Rackspace, Mike held senior technical roles at Sandia National Laboratories performing research and development in Cyber Security with regards to distributed systems, cloud and mobile computing. You can follow Mike on Twitter @mikemetral and Github as metral