Converting a Linux Virtual Machine With an LVM

I was entrusted with the task to try and migrate a VM from Xen 3.2 to ESX. Well you would think that is a trivial task - it should be. But let us not forget that we are talking here about version 3.2, which is two generations back from the current Citrix Xensource which is in use today. After successfully migrating it I would like to share with you the procedure. This was done on a Xen Guest VM runnning Red Hat Enterprise Linux ES release 3 (Taroon Update 7) Disk Layout was two disks, hda and hdb. The second disk was configured as part of a an Logical Volume as you can see below

[root@xxxx root]# fdisk -l

Disk /dev/hda: 26.8 GB, 26843545600 bytes 255 heads, 63 sectors/track, 3263 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 61 489951 83 Linux
/dev/hda2 62 322 2096482+ 82 Linux swap
/dev/hda3 323 453 1052257+ 83 Linux
/dev/hda4 454 3263 22571325 f Win95 Ext'd (LBA)
/dev/hda5 454 1236 6289416 83 Linux
/dev/hda6 1237 1497 2096451 83 Linux
/dev/hda7 1498 1758 2096451 83 Linux
/dev/hda8 1759 2019 2096451 83 Linux
/dev/hda9 2020 2280 2096451 83 Linux
/dev/hda10 2281 3263 7895916 83 Linux Disk

/dev/hdb: 26.8 GB, 26843545600 bytes 255 heads, 63 sectors/track, 3263 cylinders Units = cylinders of 16065 
* 512 = 8225280 bytes
Disk /dev/hdb doesn't contain a valid partition table

[root@XXXXXX root]# lvscan lvscan -- ACTIVE "/dev/OracleVG/lvol1" [10 GB]
lvscan -- ACTIVE "/dev/OracleVG/lvol2" [5 GB]
lvscan -- 2 logical volumes with 15 GB total in 1 volume group
lvscan -- 2 active logical volumes

Fired Up VMware Converter version 4.0 Beta and started the import as if the machine was a powered on physical machine

Source info

Destination info

And when we get to the options you as you can see below the Data to copy is missing a drive

We continue with process of the import. The way the new converter works with a live Linux machine - it uses a helper VM. What it does is, it creates a VM on your ESX, powers it up and loads a Linux ISO (don’t know which one) to act as a mediator for the cloning process.

This VM has to be able to receive an IP from a DHCP server otherwise the process will not work. This is a picture of what is hapenning inside the console of the helper VM:

Time for conversion

Load on Host

Completed

The configuration of the new VM on ESX as you can see only had one drive.

Powered on the VM and this is what I got. The OS would not come up because it was missing the second part of the volume.

Entered the Root Password

vi /etc/fstab

Uncommented the mount points for the LVM and restarted.

/dev/OracleVG/lvol1 /oradata/[folder] ext3 defaults 1 2 
/dev/OracleVG/lvol2 /oraback/[folder] ext3 defaults 1 2

Kudzu kicked in to recognize all the new hardware, LSI Scsi card, NIC and VGA. Machine came up GUI and all - like it should have. But I was missing the 2nd drive of course.

[root@XXXXX root]# fdisk -l

Disk /dev/sda: 26.8 GB, 26863764480 bytes 255 heads, 63 sectors/track, 3266 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 61 489951 83 Linux
/dev/sda2 62 322 2096482+ 82 Linux swap
/dev/sda3 323 453 1052257+ 83 Linux
/dev/sda4 454 3263 22571325 5 Extended
/dev/sda5 454 1236 6289416 83 Linux
/dev/sda6 1237 1497 2096451 83 Linux
/dev/sda7 1498 1758 2096451 83 Linux
/dev/sda8 1759 2019 2096451 83 Linux
/dev/sda9 2020 2280 2096451 83 Linux
/dev/sda10 2281 3263 7895916 83 Linux

[root@XXXXX root]# lvscan lvscan -- no volume groups found

Added a 2nd Drive identical to the first and rebooted

and got my second drive

[root@XXXXXX root]# fdisk -l

/dev/sdb Disk /dev/sdb: 26.8 GB, 26865020928 bytes 255 heads, 63 sectors/track, 3266 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table

Now comes the fun part: [source_ip] = old Linux Machine From the Destination (i.e. the new VMware VM we just created) run the following command:

ssh root@[source_ip] "dd if=/dev/hdb" | dd of=/dev/sdb

And then wait…. The only thing you will see is on the source that sshd is using resources, no other indications.

PID    USER PRI NI SIZE RSS   SHARE STAT %CPU %MEM TIME CPU COMMAND
16482 root  25  0   2152 2152 1628 R 13.1 0.2                0:03 0     sshd

Once that was done (took about 2.5 hours for a 20gb Disk) Got this in the end

52428800+0 records in 52428800+0 records out 52428800+0 records in 52428800+0 records out

Removed the comments that I made previously in /etc/fstab and another reboot And up she goes…

[root@XXXXX root]# fdisk -l

Disk /dev/sda: 26.8 GB, 26863764480 bytes 255 heads, 63 sectors/track, 3266 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 61 489951 83 Linux
/dev/sda2 62 322 2096482+ 82 Linux swap
/dev/sda3 323 453 1052257+ 83 Linux
/dev/sda4 454 3263 22571325 5 Extended
/dev/sda5 454 1236 6289416 83 Linux
/dev/sda6 1237 1497 2096451 83 Linux
/dev/sda7 1498 1758 2096451 83 Linux
/dev/sda8 1759 2019 2096451 83 Linux
/dev/sda9 2020 2280 2096451 83 Linux
/dev/sda10 2281 3263 7895916 83 Linux Disk

/dev/sdb: 26.8 GB, 26865020928 bytes 255 heads, 63 sectors/track, 3266 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@XXXXX root]# lvscan lvscan -- ACTIVE "/dev/OracleVG/lvol1" 
[10 GB]

lvscan -- ACTIVE "/dev/OracleVG/lvol2" [5 GB]
lvscan -- 2 logical volumes with 15 GB total in 1 volume group 

lvscan -- 2 active logical volumes

and of course GUI and all