lunes, 20 de abril de 2020

How to migrate VMware Virtual Machine to Oracle Cloud (Linux 5 32-bits)


The Virtual Machine  I am migrating is an Oracle Linux 5  32-bits,  running on VMware ESXi 6.0.0 and the version of the VM is 11. You can see the a Summary bellow:



Just as a mark, I am creating a file with the text "This is a Deiby's File" so that at the end of the procedure we can confirm that indeed is our machine.


Preparation of the VMware VM in ESX:

Oracle Documentation specify the following requirements:


My VMware VM comply with most of them, the only thing to check is the virtio drivers, then first step is to confirm that virtio drivers are available in the kernel:

[root@localhost ~]# grep -i virtio /boot/config-`uname -r`
CONFIG_NET_9P_VIRTIO=m
CONFIG_VIRTIO_BLK=m
CONFIG_VIRTIO_NET=m
CONFIG_VIRTIO_CONSOLE=y
CONFIG_HW_RANDOM_VIRTIO=m
CONFIG_VIRTIO=y
CONFIG_VIRTIO_RING=y
CONFIG_VIRTIO_PCI=m

CONFIG_VIRTIO_BALLOON=m

The three lines highlighted have to be set to "m".

Check to confirm the virtio modules are built in initrd:

[root@localhost ~]# cp -p /boot/initrd-`uname -r`.img /tmp/initrd-`uname -r`.img.gz
[root@localhost ~]# zcat /tmp/initrd-`uname -r`.img.gz | cpio -it | grep virtio
10521 blocks
[root@localhost ~]#

The virtio lines are not present (you should receive some lines with the string "virtio" as a result). Stop here, otherwise you will get problesm trying to boot your machine once is running in Oracle Cloud. For more details about this booting problem, read the article Not booting disk after importing VMware VM to Oracle Cloud 

Since the virtio modules are not present, we have to rebuild the initrd. Before It's recommended to create a backup:

[root@localhost ~]# cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak

Next step is to rebuild the initrd:

[root@localhost ~]# mkinitrd --with="virtio_blk virtio_pci" -f -v /boot/initrd-`uname -r`.img `uname -r`
Creating initramfs
Modulefile is /etc/modprobe.conf
Looking for deps of module sd_mod: crc-t10dif
Looking for deps of module crc-t10dif
Looking for deps of module ehci-hcd
Looking for deps of module ohci-hcd
Looking for deps of module uhci-hcd
Looking for deps of module ext3: mbcache jbd
Looking for deps of module mbcache
Looking for deps of module jbd
Looking for driver for device sda2
Looking for deps of module scsi:t-0x00: crc-t10dif sd_mod
Looking for deps of module pci:v00008086d00007111sv000015ADsd00001976bc01sc01i8a: ata_generic ata_generic ata_piix ata_piix pata_acpi
Looking for deps of module ata_generic
Looking for deps of module ata_piix
Looking for deps of module pata_acpi
Looking for deps of module ide-disk
Looking for deps of module ahci: libahci
Looking for deps of module libahci
Looking for deps of module dm-mod
Looking for deps of module dm-mirror: dm-mod dm-log dm-region-hash
Looking for deps of module dm-log: dm-mod
Looking for deps of module dm-region-hash: dm-mod dm-log
Looking for deps of module dm-zero: dm-mod
Looking for deps of module dm-snapshot: dm-mod
Looking for deps of module dm-mem-cache
Looking for deps of module dm-region_hash: dm-mod dm-log dm-region-hash
Looking for deps of module dm-message
Looking for deps of module dm-raid45
Looking for deps of module virtio_blk
Looking for deps of module virtio_pci
Using modules:   /lib/modules/2.6.39-400.215.10.el5uek/kernel/lib/crc-t10dif.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/mbcache.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/jbd/jbd.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/ext3/ext3.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ata_generic.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ata_piix.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/pata_acpi.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/libahci.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ahci.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-mod.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-log.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-region-hash.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-mirror.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-zero.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-snapshot.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/block/virtio_blk.ko /lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/virtio/virtio_pci.ko
/sbin/nash -> /tmp/initrd.K10847/bin/nash
/sbin/insmod.static -> /tmp/initrd.K10847/bin/insmod
/etc/udev/rules.d/05-udev-early.rules -> /tmp/initrd.K10847/etc/udev/rules.d/05-udev-early.rules
/sbin/firmware_helper.static -> /tmp/initrd.K10847/sbin/firmware_helper
/sbin/udevd.static -> /tmp/initrd.K10847/sbin/udevd
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/lib/crc-t10dif.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/crc-t10dif.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/scsi/sd_mod.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/sd_mod.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/mbcache.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/mbcache.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/jbd/jbd.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/jbd.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/fs/ext3/ext3.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/ext3.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ata_generic.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/ata_generic.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ata_piix.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/ata_piix.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/pata_acpi.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/pata_acpi.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/libahci.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/libahci.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/ata/ahci.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/ahci.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-mod.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-mod.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-log.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-log.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-region-hash.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-region-hash.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-mirror.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-mirror.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-zero.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-zero.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/md/dm-snapshot.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/dm-snapshot.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/block/virtio_blk.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/virtio_blk.ko' [elf32-i386]
copy from `/lib/modules/2.6.39-400.215.10.el5uek/kernel/drivers/virtio/virtio_pci.ko' [elf32-i386] to `/tmp/initrd.K10847/lib/virtio_pci.ko' [elf32-i386]
/sbin/lvm.static -> /tmp/initrd.K10847/bin/lvm
/sbin/dmraid.static -> /tmp/initrd.K10847/bin/dmraid
/sbin/kpartx.static -> /tmp/initrd.K10847/bin/kpartx
Adding module crc-t10dif
Adding module sd_mod
Adding module mbcache
Adding module jbd
Adding module ext3
Adding module ata_generic
Adding module ata_piix
Adding module pata_acpi
Adding module libahci
Adding module ahci
Adding module dm-mod
Adding module dm-log
Adding module dm-region-hash
Adding module dm-mirror
Adding module dm-zero
Adding module dm-snapshot
Adding module virtio_blk
Adding module virtio_pci
[root@localhost ~]#

Now let's confirm if virtio modules are present:

[root@localhost ~]# cp -p /boot/initrd-`uname -r`.img /tmp/initrd-`uname -r`.img.gz
[root@localhost ~]# zcat /tmp/initrd-`uname -r`.img.gz | cpio -it | grep virtio
17527 blocks
lib/virtio_blk.ko
lib/virtio_pci.ko
[root@localhost ~]#

Excellent. The VM is ready to be uploaded to Oracle Cloud.


Exporting the VMware VM from ESX:


Follow the instructions in the article  How to export VMware VM using Oracle Ravello VM Tool.


Uploading the VM's Files to Oracle Cloud

Follow the instructions in the article How to create an Instance Custom Template in Oracle Cloud using VMware VMDK Files.


Creating the Instance


Specify the name of the new OCI Instance, in my example is "LinuxVM". Then Select the Image by clicking on the button "Change Image", here is where you have to select the Custom Image Template we just created previously, in my example "VMWare Image". Finally Select the Shape for your instance, and then click on the button "Create":




The Instance will start to get created:




After some seconds the OCI Instance will be fully created and ready to be used, you can use the Public IP to test the connectivity:





Verification of the Migration


The basic test, just a Ping:




Create a Console Connection to Visualize with VNC the Desktop following the instruction in my previous article "How to create a VCN in Oracle Cloud Infrastructure (OCI)"


Check the File we created at the beginning of the article, to confirm it's our former VMware VM :)



3 comentarios:

Oracle ACE Director Award - Deiby Gómez

Thanks #OracleACE Program for this awesome certificate recognizing the work I have done in the community for the last year. Looking forwa...