Version 2 (modified by fabior, 4 anos atrás) (diff)


Como migrar uma instalação Ubuntu para Xen com Paravirtualização

Ensina a migrar uma instalação Ubuntu para uma instalação com paravirtualização, utilizando o script

XenServer supports a lot of Linux and Windows operating systems out of the box, but Ubuntu isn’t one of them. This means that running Ubuntu is slower, because it uses HVM (hardware-assisted virtualisation) instead of PV (paravirtualization). This article will explain how to create a paravirtualized Ubuntu 10.04 VM with the XenServer Tools installed. Many thanks go to the author of the article “Ubuntu 10.04 LTS paravirtualised on Citrix XenServer” (link no longer available).

We start with creating and installing a VM with HVM.

  • Create a VM from the Other install media template
  • Attach the Ubuntu 10.04 ISO to the DVD drive of the VM
  • Start the VM
  • At the disk partitioning stage make sure to replace Ext4 with Ext3, or create a specific boot partition with Ext3
  • Select at least the OpenSSH server package to be able to log in to the VM remotely
  • Finish installation and boot the VM

We now create a new console and edit the boot settings.

  • Connect to the VM using SSH
  • Create a new console for Xen
sudo cp /etc/init/tty1.conf /etc/init/hvc0.conf
sudo vi /etc/init/hvc0.conf

  • Replace all occurrences of tty1 with hvc0
  • Read /boot/grub/grub.cfg
sudo vi /boot/grub/grub.cfg

  • Copy the contents of menuentry near the bottom to a temporary text file, to be used as input for the script that we will use later on
menuentry 'Ubuntu, with Linux 2.6.32-21-server' --class ubuntu --class gnu-linux --class gnu --class os {
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 02899ea9-1876-4e7b-8ef8-2b09b598cedb
        linux   /boot/vmlinuz-2.6.32-21-server root=UUID=02899ea9-1876-4e7b-8ef8-2b09b598cedb ro quiet
        initrd  /boot/initrd.img-2.6.32-21-server

  • Make special note of /boot/vmlinuz…, root=UUID=… and /boot/initrd.img
  • Shutdown the VM

We now convert the VM to PV.

  • Connect to the XenServer host with SSH
  • Copy the script (download from here) to the XenServer host and make it executable
chmod +x

  • Run the script, replacing my-vm-name with the actual name of your VM my-vm-name

Finally we install the XenServer tools.

  • Boot the VM and log in with SSH
  • In XenCenter, attach xs-tools.iso to the DVD drive of the VM
  • Mount xs-tools.iso, install the correct XenServer Tools package (replace amd64 with i386 if necessary) and unmount xs-tools.iso
sudo mount /dev/cdrom1 /mnt
sudo dpkg -i /mnt/Linux/xe-guest-utilities_5.5.0-466_amd64.deb
sudo umount /mnt

  • In XenCenter, detach xs-tools.iso from the DVD drive of the VM (this ensures that XenServer does not complain about too many bootable devices)
  • Reboot the VM and log in with SSH
  • Make sure the services run at boot time
sudo update-rc.d -f xe-linux-distribution remove
sudo update-rc.d xe-linux-distribution defaults

  • Reboot the VM for the last time
  • Restart XenCenter to be able to log in to the console of the VM



confirm() {
    echo -n "$1"
    echo -n "OK [Y/n]?"
    read ANSWER
    if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ -z "$ANSWER" ]
        eval $1
        echo "... parameter set"
        echo "... parameter NOT set"

if [ -z "$1" ]
    echo -n "Name of VM [l for list]: "
    read VM

if [ "$VM" == "l" ] || [ "$VM" == "L" ]
    xe vm-list | grep name-label | grep -v "Control domain"

echo ""
echo "Looking up UUID for VM $VM"

UUID=$(xe vm-list name-label="$VM" params=uuid --minimal)
if [ -z $UUID ]
    echo "No UUID found for $VM."
    exit 0

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...): "

echo ""
echo -n "Specify Kernel arguments (root=UUID=... ro quiet): "

echo ""
echo -n "Specify path to ramdisk (e.g. /boot/initrd...): "

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 disks 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 ]
    echo "No VBD UUID found for $VBD."
    exit 0

echo "VBD UUID=$VBD"
echo ""
echo "Setting parameters for VBD $VBD"
confirm "xe vbd-param-set uuid=$VBD bootable=true"
exit 0

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.