If something goes wrong with one of your Xen virtual machines, you might want to boot it from the installation...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
disk to run the rescue program. But, booting a Xen virtual machine from an optical disk is not that easy (you can't just connect the disk and expect the machine to boot). In this article you'll learn how to boot a Xen virtual machine from a disk. This tip applies to all Xen solutions that are using Linux as the VM host machine, and is not intended for Citrix XenServer.
In Xen environments, you can install virtual machines as paravirtual machines, or as full virtual machines. To boot a virtual machine from CD-ROM or DVD, it does matter how you installed it. Full virtual machines are a bit easier to boot from CD-ROM or DVD than paravirtual machines. The good news is that you can change the configuration of a paravirtual machine to have it boot from the optical disk anyway.
Paravirtual versus full virtual machines
The starting point to have your VM boot from the optical drive, is the virtual machine startup script. On a SUSE based Xen host, these are the scripts that you find in the /etc/xen/vm directory. In this article, we're talking about the "normal" scripts, not the XML scripts that you also find in this directory. Using these scripts, Xen tries to start a virtual machine. That means that it will initialize the virtual hardware and try to boot the operating system that is installed on the virtual hard disk. This applies to both paravirtual and full virtual machines.
There is a difference though in the way a full virtual machine boots, as compared to the way a paravirtual machine boots. The fact is that full virtual machines are easier to boot from CD-ROM or DVD. But if you just want to boot the virtual machine from an optical disk, it doesn't really matter if you start it as a full virtual machine or a paravirtual machine. The only thing that matters, is that you are able to access the virtual machine disk by booting the machine from the optical drive. To do this, it's enough to create a template virtual machine file and use that for all the virtual machines that you want to boot from the optical disk. The only thing you'll need to do with this template file, is to replace the VM specific items in it. The listing below shows what this template file could look like:
Tempalte VM file to boot virtual machines from optical drive
name="bootfromcd" memory=1024 maxmem=4048 vcpus=1 on_poweroff="destroy" on_reboot="restart" on_crash="destroy" localtime=1
builder="hvm" device_model="/usr/lib/xen/bin/qemu-dm" kernel="/usr/lib/xen/boot/hvmloader" disk=[ 'REPLACE THIS WITH DISK SPECIFICATION FROM ORIGINAL FILE', ] vif=[ 'REPLACE THIS WITH NETWORK CARD SPECIFICATION FROM ORIGINAL FILE', ] boot="d" stdvga=0 vnc=1 vncunused=1 apic=1 acpi=1 pae=1
In the example template file there are a few things that you should be aware of. First, there are some generic options that specify how the VM is composed. These are all the lines up to the vmloader line, which specifies the hvm (hardware virtual machine) is used to load this virtual machine.
Following the generic lines, you can find two lines where the disk and network card of the virtual machine are defined. You have to make sure that at least the disk line contains the name of the discs as you are using them in the virtual machine that you are booting. That means, you'll first have the definition of the disk file itself, followed by the specification of the optical drive. The latter could look like phy:/dev/cdrom,xvdb for instance.
The last part in this configuration that you need to consider, is the boot line. Above, it states boot="d". This line is using drive letters as are used in a Windows environment to refer to the device that the VM should be booting from, so this example assumes that there is one virtual hard disk in the virtual machine. Change this according to the number of disks that really are used by your virtual machine.
After creating the template file in this way, you're ready to run the virtual machine and boot it from the optical drive. Before doing that, just make sure that it isn't currently active, as that might lead to conflicts in disk access. Once started from the optical disk, you can run any troubleshooting program you like from it. This should help you fixing whatever is broken in the VM.
ABOUT THE AUTHOR: Sander van Vugt is an author and independent technical trainer, specializing in Linux since 1994. Vugt is also a technical consultant for high-availability (HA) clustering and performance optimization, as well as an expert on SLED 10 administration.