Converting Xen guest VM to ESX

Guest prep

For this guide the guest Xen VM is named “foo”

Check current kernel version (XEN)

$uname -a 
2.6.18-194.11.4.el5xen

Install kernel

$yum install kernel
Downloading Packages:
Kernel-2.6.18-308.16.1.el5.x86_64.rpm

The new kernel will now show up in /boot

 $lst -ltr /boot
 initrd-2.6.18-308.16.1.el5.img

Now edit the grub menu.lst

 $vi /boot/grub/menu.lst

and set initrd-2.6.18-308.16.1.el5.img to be default, this is the new NON Xen kernel you’ve just downloaded and installed.

# grub.conf generated by anaconda
  #
  # Note that you do not have to rerun grub after making changes to this file
  # NOTICE:  You have a /boot partition.  This means that
  #          all kernel and initrd paths are relative to /boot/, eg.
  #          root (hd0,0)
  #          kernel /vmlinuz-version ro root=/dev/xvda2
  #          initrd /initrd-version.img
  #boot=/dev/xvda
  default=1   <===== Change to "0"
  timeout=5
  splashimage=(hd0,0)/grub/splash.xpm.gz
  hiddenmenu
  title CentOS (2.6.18-308.16.1.el5)
  root (hd0,0)
  kernel /vmlinuz-2.6.18-308.16.1.el5 ro root=LABEL=/
  initrd /initrd-2.6.18-308.16.1.el5.img
  title CentOS (2.6.18-194.11.4.el5xen)
  root (hd0,0)
  kernel /vmlinuz-2.6.18-194.11.4.el5xen ro root=LABEL=/
  initrd /initrd-2.6.18-194.11.4.el5xen.img

Edit /etc/modeprobe.conf from this

 alias eth0 xennet
 alias scsi_hostadapter xenblk

To this

 alias eth0 e1000
 alias scsi_hostadapter mptbase
 alias scsi_hostadapter1 mptspi
 alias scsi_hostadapter2 ata_piix

Edit /etc/sysconfig/network-scripts/ifcfg-eth0, remove HWADDR line

# Xen Virtual Ethernet
  DEVICE=eth0
  BOOTPROTO=static
  HWADDR=00:18:3E:45:BA:71  <==== Remove this
  IPADDR=10.1.200.10
  NETMASK=255.255.0.0
  ONBOOT=yes

Edit the /etc/inittab and comment out the line “co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav

# Run gettys in standard runlevels
  # xen
 #co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav <==== Comment out
 1:2345:respawn:/sbin/mingetty --noclear tty1
 1:2345:respawn:/sbin/mingetty tty1
 2:2345:respawn:/sbin/mingetty tty2
 3:2345:respawn:/sbin/mingetty tty3
 4:2345:respawn:/sbin/mingetty tty4
 5:2345:respawn:/sbin/mingetty tty5
 6:2345:respawn:/sbin/mingetty tty6

Create new initrd file

$mkinitrd -f /boot/initrd-2.6.18-308.16.1.el5.img 2.6.18-308.16.1.el5

If it complains about “no module xenblk found – aborting” then do this:

 $mkinitrd --builtin=xenblk  -f /boot/initrd-2.6.18-308.16.1.el5.img 2.6.18-308.16.1.el5

Now poweroff the guest

Host

Now go to the host where the old Xen VM use to run

Check the Xen VM is off, the VM should NOT be listed

 xm list

Note LV paths

 grep -RniI foo /etc/xen/config

Convert the image

 qemu-img convert -f raw /dev/xend_vg/foo.lv -O vmdk ./foo.vmdk

Create the vmdk, a quick explanation of the options used:

-r (the source disk)
-t 4 (Specify the virtual disk type)

0 – create a growable virtual disk contained in a single file (monolithic sparse).
1 – create a growable virtual disk split into 2GB files (split sparse).
2 – create a preallocated virtual disk contained in a single file (monolithic flat).
3 – create a preallocated virtual disk split into 2GB files (split flat).
4 – create a preallocated virtual disk compatible with ESX server (VMFS flat).
5 – create a compressed disk optimized for streaming.

Option 4 fitted my environment, so do the following:

$vmware-vdiskmanager -r foo_ide.vmdk -t 4 ./fo_t4.vmdk
 Creating disk './n01_t4.vmdk'
  Convert: 16% done.mware-vdiskmanager -r n01_ide.vmdk -t 4 ./n01_t4.vmdk
  Virtual disk conversion successful.

Edit foo_t4.vmdk to change the adapter type from “ide” to “lsilogic”

 # Disk DescriptorFile
 version=1
 CID=4fbd3245
 parentCID=ffffffff
 createType="vmfs"
 # Extent description
 RW 25165824 VMFS "foo_t4-flat.vmdk" 0
 # The Disk Data Base
 #DDB
 ddb.virtualHWVersion = "4"
 ddb.encoding = "UTF-8"
 ddb.uuid = "60 00 C2 94 ec 00 b0 4f-bd b4 02 3d e6 c5 09 c5"
 ddb.geometry.cylinders = "24966"
 ddb.geometry.heads = "16"
 ddb.geometry.sectors = "63"
 ddb.adapterType = "lsilogic"  <==== change this



Advertisement

About hedscratchers

A UK ex-pat now living in the USA.
This entry was posted in Linux & Solaris. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s