Skip to content

Installing CentOS 7 on Xen

CentOS 7 is out.   You might want to install it on your Fedora-based Xen system, but if you’re used to the CentOS 4/5/6 method of install, you might be in for a few surprises.  This post is specifically about an environment running Fedora 20, Libvirt 1.2.5, Cobbler 2.4.4 and Xen 4.4.

Large installations will be using kickstart files, but small installs, or those who intend to build a kickstart file will often, at least initially, want to use the installer (“Anaconda”).

The trouble seems to stem from a few things: the new graphical installer, Fedora dropping non-DRI2 X drivers (Xen/qemu’s cirrus being one, it seems), systemd not spawning agetty on hvc0 terminals so you can see what’s going on, libxl not supporting all the quirks and workarounds that xend did, and probably more.

Here’s how a CentOS 6 virt-install might look on Xen 4.1:

virt-install –virt-type=xen –paravirt –name=apps –arch=x86_64 –vcpus=10 –cpuset=2-11 –ram=1024  –location=http://ks-host/cobbler/ks_mirror/centos6-x86_64 –os-type=linux –os-variant=rhel6 –disk path=/dev/zvol/storage/apps/boot –disk path=/dev/zvol/storage/apps/root  –disk path=/dev/zvol/storage/apps/swap  –network bridge=br0,mac=02:00:0a:bfc:c0:15 –graphics=vnc

Run this and you’d be given a VNC port with the text anaconda running on it.  If you try this with el7 on such a system, first you won’t even get a running domain – you’ll see something like, if you enable the -d flag for debugging:

Starting install…
Retrieving file .treeinfo…                                                                                | 1.9 kB  00:00:00 !!!
Retrieving file vmlinuz…                                                                                  | 9.4 MB  00:00:00 !!!
Retrieving file initrd.img…                                                                               |  67 MB  00:00:00 !!!
ERROR    internal error: libxenlight failed to create new domain ‘apps’

Chasing through the libvirt source doesn’t get too far, but it turns out that a release note on Xen 4.2 does provide a clue, which is that in order to get VNC to work on current Xen may require passing device_model_version=”qemu-xen-traditional” to Xen so it can set up qemu-dm correctly.  That does work to get a VNC console launched, but it’s still not going to work for installation AFAICT for the above reasons about X not supporting cirrus.   Let’s say you build a Xen config file to launch the DomU.  Without this option you’ll see:

# xl create -c /etc/xen/apps
Parsing config from /etc/xen/apps
libxl: error: libxl_dm.c:1371:device_model_spawn_outcome: domain 28 device model: spawn failed (rc=-3)
libxl: error: libxl_create.c:1186:domcreate_devmodel_started: device model did not start: -3
libxl: error: libxl_dm.c:1475:kill_device_model: Device Model already exited

Add the option and launch it – you will in fact get a VNC terminal connection, sized for IBMPC text mode, but even though Xen will load the initrd and vmlinuz, you’ll never see anything on the console.  Go ahead and pass in vga= or xserver=vesa or text or inst.xserver=vesa and still you won’t get an installer.  Exactly the same result occurs on an SDL console.

Sounds like quite the pickle, eh?   But, there is, in fact, a simple solution.  Buried deep inside the RHEL7 install guide is a note about installing on IBM Power systems that are headless, and for those Redhat built in a VNC server directly into the installer package.  Ah, ha!

We can express the desired configuration as a Xen config file such as:

name = “apps”
uuid = “869ccb5a-4303-4fd4-8f9c-0b89b6bb30c3”
memory = “1024”
disk = [
vif = [ ‘mac=02:00:0A:BF:C0:15, bridge=br0’, ]
extra=”inst.vnc inst.repo=http://ks-host/cobbler/ks_mirror/centos7-x86_64″

And then, by connecting to the address your DHCP server assigned, on VNC Display #1 (not #0), such as:

vncviewer apps:1

you will, in fact, be staring at a VNC display of the EL7 installer.  w00t!  Be patient, gentle reader, as the VNC server will not be starting until the kernel is booted, the initrd is run, the squashfs is retrieved and mounted, and the installer gets far enough in to start the VNC server.  This took a good 30 seconds on my 2GHZ 22nm Xeon-based system.  And if you’re not on a secure private network, please pass “inst.vncpassword=yoursecret” as well.

So, getting back to a virt-install command line, we can use the existing –location field to take care of inst.repo (the installer seems to understand method= as well on the kernel command line), and add an –extra line for “inst.vnc”:

virt-install –virt-type=xen –paravirt –name=apps –arch=x86_64 –vcpus=10 –cpuset=2-11 –ram=1024  –location=http://ks-host/cobbler/ks_mirror/centos7-x86_64 –extra=”inst.vnc” –os-type=linux –os-variant=rhel7 –disk path=/dev/zvol/storage/apps/boot  –disk path=/dev/zvol/storage/apps/root  –disk path=/dev/zvol/storage/apps/swap –network bridge=br0,mac=02:00:0a:bf:c0:15 –graphics=none

At this point, you’ll have a working installer.  So, you’re all set, right?

Well, no, EL7 uses grub commands ‘linux16’ and ‘initrd16’, so pygrub cannot boot the system.  Fortunately a little patch will fix pygrub.

So, from the top (TL;DR):

1. Fetch the DVD installer via torrent (netinstall will not import!):

2. update cobbler’s signatures for el7 (not in the current release or on -testing):

# cobbler signature update

3. import the distro into cobbler:

# mkdir /mnt/dvd

# mount -o loop CentOS-7.0-1406-x86_64-DVD.iso /mnt/dvd

# cobbler import –path=/mnt/dvd –name=centos7-x86_64 –arch=x86_64

# umount /mnt/dvd

4. allocate your storage by your favorite method.  I created 3 zvols:

# zfs create storage/apps
# zfs create -V 2G  storage/apps/boot
# zfs create -V 64G storage/apps/root
# zfs create -V 16G storage/apps/swap

You may be using lvm, raw disks, files, etc.

5. kick off virt-install:

virt-install –virt-type=xen –paravirt –name=apps –arch=x86_64 –vcpus=10 –cpuset=2-11 –ram=1024  –location=http://ks-host/cobbler/ks_mirror/centos7-x86_64 –extra=”inst.vnc” –os-type=linux –os-variant=rhel7 –disk path=/dev/zvol/storage/apps/boot  –disk path=/dev/zvol/storage/apps/root  –disk path=/dev/zvol/storage/apps/swap –network bridge=br0,mac=02:00:0a:bf:c0:15 –graphics=none

6. connect with VNC:

vncviewer apps:1

7.  Finish graphical install.

8. patch pygrub:

# cd /usr/lib64/python2.7/site-packages/grub/

# patch -p0 < pygrub-el7-linux16.patch

9.  Finally, start your DomU:

# xl create -c /etc/xen/apps

Until EL8, nanoo-nanoo.