Add to Google Reader or Homepage |
~ pjvenda / blog
$home . blog . photography

17 May 2011

Enabling a full XEN domU login console

So I got rid of vserver and I'm rebuilding my server with xen. I'm building a XEN 4.1 with Gentoo XEN kernels for domain 0 and unprivileged domains. There were a number of issues with the process but I managed to get a stable fully functional dom0 kernel going. Unprivileged domains will have to be built from scratch as the current file systems were tweaked for the vserver environment.

The base file system is a Gentoo amd64 stage3 mounted in loopback mode. I also have a functional domU kernel so it was time to create a sample configuration file and fire up a virtual host with

xm create <config_file> -c
It seemed to bootup properly but console output ceased immediately after the kernel booted - the point at which process 1 is called: init. Some theory as to why this happens can be found here:

So to enable a fully functional xen login console the following is required (as always, there are other methods for similar or different purposes):

  • Make sure your domU kernel has all serial ports disabled. This may not be required but it will save some potential hassle because of how xen handles domU kernels;

  • Make sure your domU file system is populated with a bare base of device files in /dev (console, null, etc.). Gentoo's stage {1,2,3} base filesystems have all the necessary files;

  • Configure the kernel's virtual terminal driver to use xen's subsystem by adding the following command line parameter
    As far as I understand, this is the default for current XEN kernels, so this parameter may not be required (it wasn't in my case but it's here for the sake of completeness);

  • Configure the kernel's console to output to a xvc type terminal. This is done by adding
    to the domU's kernel command line;

  • Adding kernel command line parameters can be done by editing the configuration file and adding (or adding to) a 'extra=' entry with whatever command line parameters as required. Specifically for this case, that would be
    extra = 'xencons=xvc console=xvc0'
    If 'extra=' already exists and contains something, just add the console parameter at the end:
    extra = 'parameter=value param2=value2 xencons=xvc console=xvc0'

  • Observe the kernel bootup messages looking for lines with 'console'. There should be one similar to:
    Xen virtual console successfully installed as xvc0

At this point, there should be a working console past the init process, service startup output (rc*) will be visible. However, it is likely that a login prompt won't appear. If that's the case and you want one, read on.

  • /etc/inittab can be setup to fire respawning login terminals at character devices, such as serial ports or the xen console (xvc0). One or more terminal lines are probably already on /etc/inittab with getty processes such as
    c1:12345:respawn:/sbin/agetty 38400 tty1 linux
    I modified one of those to point at /dev/xvc0 rather than at /dev/tty1:
    c1:12345:respawn:/sbin/agetty 38400 xvc0 linux
    (in case you're wondering, the first parameter c1 is only a label). In addition, for xen domU virtual hosts, there is little point in having any other login terminals, so the remaining (at tty2, tty3 and so on) can safely be commented out;

  • Remember to setup a root password...;

  • The final step is to get your system to allow root logins on the xen console. /etc/securetty contains a list of terminal devices over which root logins are allowed, to which 'xvc0' needs to be added (no /dev/);


A few more things I learnt while setting up this template file system:

  • When creating sparse loopback file systems, make sure the host file system can accommodate the entire file, or else the loopback file system will become corrupt;
  • Linux does strange things when it runs out of space on /;