Home > Cobbler, Linux, RedHat, Virtualization > XenServer PV guests and Cobbler

XenServer PV guests and Cobbler

Far, far beyond the island
We dwelt in shades of twilight
Through dread and weary days
Through grief and endless pain

(Blind Guardian – Mirror, mirror)

After automatizing deployment of machines, one starts to really hate manual installs 🙂 They are long, repetitive task that bores one to hell… One thing we didn’t automatize yet were installations of Citrix XenServer paravirtualized guests. After searching through Citrix forums, we found a neat solution.

First step is to configure new system in Cobbler. I’m using my own cobbler-puppet module (https://forge.puppetlabs.com/jsosic/cobbler) for managing cobbler, so I’ll post the puppet code instead of classic Cobbler CLI for adding new system:

   cobblersystem { 'pv_vm_autoinstall.example.com':
    ensure     => present,
    profile    => 'CentOS-6.4-x86_64-xen',
    interfaces => {
      'eth0' => {
        ip_address  => '192.168.1.13',
        netmask     => '255.255.255.0',
        mac_address => 'EE:B8:80:CB:B3:04',
        static      => true,
        management  => true,
      },
    },
    kernel_options => {
      clocksource  => 'acpi_pm',
      text         => '~',
      kssendmac    => '~',
    },
    gateway    => '192.168.1.1',
    hostname   => 'pv_vm_autoinstall.example.com',
  }

As you can notice, we added “clocksource=acpi_pm” kernel parameter, so that kernel at installation time uses acpi_pm as source for it’s clock. This parameter is needed for the VM to boot properly in Rescue mode. So, how does a kickstart file look like?  Important parts are about partitioning:

# System bootloader configuration
bootloader --location=mbr --driveorder=xvda --append="console=hvc0"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --drives=xvda --all
# Disk partitioning information
part /boot --ondisk=xvda --asprimary --fstype="ext2" --size=100
part swap  --ondisk=xvda --asprimary --fstype="swap" --size=4096
part /     --ondisk=xvda --asprimary --fstype="ext3" --size=20480
part /data --ondisk=xvda --asprimary --fstype="ext4" --size=4096 --grow

Notice that we changed classic ‘sda’ with ‘xvda’, because it’s the block device name in XenServer guests, and added “console=hvc0” parameter to kernel cmdline in “bootloader” section.

After we set up Cobbler, we can advance to creating new virtual machine in XenServer. In this example I choose CentOS 6.0 template. The most important thing is not to boot the VM after creation:

XenServer PV VM creation wizzard

I will emphasize it once more: it’s important to turn off the “Start the new VM automatically” option. Also, to ensure the boot from PXE, you must leave the virtual DVD drive empty. Now, there is one more issue I’ve stumbled upon. For some reason, if the first boot of the VM is done in Rescue Mode, vbd-param “bootable” is false. So, neat trick I use to overcome this issue is to boot the VM in normal mode, and power it off afterwards, and then boot it with empty DVD drive into Rescue Mode, which will use PXE…. And that’s it! Cobbler will install the VM, and after installation is complete, VM will reboot into PV mode.

If the VM refuses to boot after PXE/kickstart installation is done, you have to use little XenServer magic to set the bootable flag to true:

# xe vm-disk-list uuid=<our_new_shiny_vm_uuid>
# xe vbd-param-set uuid=<vbd_uuid_from_previous_command> bootable=true

Although this is not fully automatized solution which can spawn VM’s on it’s own, it surely helps to advance to fully managed environment.

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment