Xen: Booting into run level 1


Booting into run level 1 from grub is useful in times of troubleshooting. I am using centos and my problem is when I am using xen, everything is automated by the pygrub bootloader.

I tried to google for a solution for a long time and couldn’t find anything. Someone suggested changing the inittab. Yes, I know but I want to be able to boot into different run levels from grub! I eventually experimented and found a quick trick myself.

We start off by looking at the xen boot parameters.

Doing a ‘xm list -l’ gives something like:

(domid 1)
(uuid 735cd9c5-9387-dbf9-2421-037e28e5df5e)
(vcpus 1)
(cpu_weight 1.0)
(memory 128)
(shadow_memory 0)
(maxmem 128)
(bootloader /usr/bin/pygrub)
(features )
(name hera)
(on_poweroff destroy)
(on_reboot restart)
(on_crash restart)
(image
(linux
(ramdisk /var/lib/xen/boot_ramdisk.LWoAIP)
(kernel /var/lib/xen/boot_kernel.CXG2Ju)
(args ‘ro root=LABEL=/’)
)
)

To get the bootloader to boot up in run level 1, I need to somehow append a ‘1’ to the end of the ‘ro root=LABEL=/’

The pygrub creates the vm for us with the right parameters. So having an args tag and overriding the args isn’t an option. The trick is to add a root parameter like so:

root = “LABEL=/ ro 1”

Lets run “xm list -l” again.

(image
(linux
(ramdisk /var/lib/xen/boot_ramdisk.7zQG0Q)
(kernel /var/lib/xen/boot_kernel.8h2uu9)
(args ‘ro root=LABEL=/’)
(root ‘ro LABEL=/ 1’)
)
)

the ‘root’ tag now correctly appends after the args which should overide the args. This should enable my virtual machine to boot into run level 1.

and it did. YAY!

* note: need to create xen instance from command line, ie “xm create xen-config” in order for it to work. does not work if run from virt-manager

Like it.? Share it:

Comments are closed.