Ubuntu 10.04 LTS paravirtualised on Citrix XenServer 5/5.5

If you're running XenServer 5.6+, there is a much simpler process.

Installing Ubuntu Server 10.04 (32bit and 64bit) LTS.

_

How to get Ubuntu 10.04 installed on Citrix XenServer 5.5 Update 2, using PV instead of HVM.

Due to Grub2 and ext4, Xen can't boot Ubuntu using PV.

Some places say to modify pygrub and GrubConf.py via patches; but from experience this has resulted in failure on our XS setup. This means each VM must be told what to boot via parameters set via the xe command-line tool.

Pre-requisites

  • XenServer 5.5 with console/SSH access
  • Ubuntu 10.04 ISO (this contains the “minimal virtual machine”, previously JeOS)
  • Put the makepv.sh script (below) into /root/ on the XS host and make it executable (chmod +x ~/.makepv.sh)

Procedure outline

  • Install minimal virtual machine onto Xen (HVM mode)
  • Add a Xen TTY
  • Make note of kernel boot options & parameters
  • Run script to set various VM options
  • Install XenServer Tools ISO

What to do

Create & Install

  • Create VM with desired options
  • Attach Ubuntu ISO
  • At Ubuntu boot prompt: choose language, press F4, choose install minimal virtual machine
  • Follow on-screen instructions until disk partitioning stage
  • If using something other than ext3, you need to create a small (100M) ext3 partition for /boot
  • Make sure you choose the OpenSSH server package at the Software selection screen so you can connect via PuTTY to copy-and-paste kernel boot options later
  • Finish install, boot into VM

Configure console, read boot settings

  • Connect to the VM via SSH
  • Duplicate /etc/init/tty1.conf to create a new console for Xen. If Nano is not installed, install it now via sudo apt-get install nano.
sudo cp /etc/init/tty1.conf /etc/init/hvc0.conf
sudo nano /etc/init/hvc0.conf
  • Change tty1 to hvc0
  • Save & exit (Ctrl + O, Enter, Ctrl + X)
  • Read /boot/grub/grub.cfg and look for menuentry near the bottom.
linux /boot/vmlinuz-2.6.32-21-server root=UUID=c49dc1b4-3f20-409e-a757-2158bc52ff4b ro   quiet
initrd  /boot/initrd.img-2.6.32-21-server
  • Copy that to a temporary text document for pasting later
  • The bits you need to look out for are:
    • Kernel path: /boot/vmlinuz-2.6.32-21-server
    • Ramdisk path: /boot/initrd.img-2.6.32-21-server
    • Kernel arguments: root=UUID=c49dc1b4-3f20-409e-a757-2158bc52ff4b ro quiet
  • Shutdown the VM

Convert the machine to PV mode

  • Connect to the Xen host via SSH as root
  • Run ~/makepv.sh my-vm-name to modify the VM settings (replace my-vm-name with the name of the VM you created before)

XenServer Tools installation

  • In XenCenter, mount xs-tools.iso on the VM
  • Boot VM and log in (either on the console or via SSH)
  • Replace dash shell with bash needed for installation, run this command. When asked to install dash as /bin/sh, choose No.
sudo apt-get -y install bash && sudo dpkg-reconfigure dash
  • Mount the tools disc and install:
sudo mount /dev/cdrom1 /mnt/
sudo dpkg -i /mnt/Linux/xe-guest-utilities_5.5.0-466_amd64.deb
  • Reboot VM & log in again
  • Fix the service so it runs at boot:
sudo update-rc.d -f xe-linux-distribution remove
sudo update-rc.d xe-linux-distribution defaults

Code - makepv.sh

#!/bin/bash
 
confirm() {
    echo -n "$1   OK [Y/n]?"
    read ANSWER
    if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ -z "$ANSWER" ]
    then
        eval $1
        echo "...parameter set"
    else
        echo "...parameter NOT set"
    fi
}
 
 
if [ -z $1 ]
then
    echo -n "Name of VM [l for list]: "
    read VM
else
    VM=$1
fi
 
 
if [ "$VM" == "l" ] || [ "$VM" == "L" ]
then
    xe vm-list | grep name-label | grep -v "Control domain"
    exit
fi
 
 
echo ""
echo "Looking up UUID for VM $VM"
 
UUID=$(xe vm-list name-label=$VM params=uuid --minimal)
if [ -z $UUID ]
then
    echo "No UUID found for $VM."
    exit 0
fi
 
echo ""
echo "UUID=$UUID"
echo ""
echo "Setting parameters for VM $VM"
confirm "xe vm-param-set uuid=$UUID HVM-boot-policy="
confirm "xe vm-param-set uuid=$UUID PV-bootloader=pygrub"
 
 
echo ""
echo -n "Specify path to Kernel (e.g. /boot/vmlinuz...): "
read KERNEL_PATH
 
echo ""
echo -n "Specify Kernel arguments (root=UUID=... ro quiet): "
read KERNEL_ARGS
 
echo ""
echo -n "Specify path to ramdisk (e.g. /boot/initrd...): "
read RAMDISK_PATH
 
echo ""
confirm "xe vm-param-set uuid=$UUID PV-bootloader-args=\"--kernel=$KERNEL_PATH --ramdisk=$RAMDISK_PATH\""
echo ""
confirm "xe vm-param-set uuid=$UUID PV-args=\"$KERNEL_ARGS console=hvc0 xencons=hvc0\""
 
 
 
 
echo ""
echo "List of discs for VM $VM"
xe vm-disk-list uuid=$UUID
 
 
echo ""
echo "Looking up UUID for VBD of VM $VM"
VBD=$(xe vm-disk-list uuid=$UUID | grep -A1 VBD | tail -n 1 | cut -f2 -d: | sed "s/ *//g")
if [ -z $VBD ]
then
    echo "No VBD UUID found for $VBD."
    exit 0
fi
 
echo "VBD UUID=$VBD"
echo ""
echo "Setting parameters for VBD $VBD"
confirm "xe vbd-param-set uuid=$VBD bootable=true"
exit 0

References

howto/lucidonxenserver.txt · Last modified: 2011/02/23 17:27 by craigrodway
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0