wiki:VMwareESX3ToUSBDisk
Last modified 9 years ago Last modified on 12/17/10 05:47:46

Transfer Virtual Machine Between VMware ESX 3 Hosts On a USB Drive

On ESX 3.0.3 host: export VM to a USB drive

1) Create a mount point.

# mkdir /mnt/usb

2) Attach a USB drive.

# fdisk -l /dev/sdb

Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1      9729  78148161   83  Linux
#

3) Mount the EXT3 file system (that was created in advance by running the "mkfs -t ext3 /dev/sdb1" command on a Linux computer).

# mount -t ext3 /dev/sdb1 /mnt/usb

4) Shutdown the virtual machine, locate its files.

# ls -log /vmfs/volumes/storage1/Cerveza
-rw-------    1 21474836480 Dec 15 16:17 Cerveza-flat.vmdk
-rw-------    1        8664 Dec 15 16:17 Cerveza.nvram
-rw-------    1         339 Nov 17 11:03 Cerveza.vmdk
-rw-------    1           0 Nov 26  2007 Cerveza.vmsd
-rwxr-xr-x    1        1477 Oct 29 21:05 Cerveza.vmx
-rw-------    1         251 Oct 29 20:58 Cerveza.vmxf
-rw-r--r--    1       26693 Nov 22  2009 vmware-26.log
-rw-r--r--    1       26330 Mar 15  2010 vmware-27.log
-rw-r--r--    1       25531 Oct 29 14:28 vmware-28.log
-rw-r--r--    1       22416 Dec 15 16:17 vmware.log
#

5) Export the virtual disk (took 5 minutes to complete).

# vmkfstools -i /vmfs/volumes/storage1/Cerveza/Cerveza.vmdk \
    /mnt/usb/Cerveza.vmdk -d 2gbsparse
Destination disk format: sparse with 2GB maximum extent size
Cloning disk '/vmfs/volumes/storage1/Cerveza/Cerveza.vmdk'...
Clone: 100% done.
#

6) Copy virtual machine configuration files.

# ( cd /vmfs/volumes/storage1/Cerveza ; \
    tar cvf /mnt/usb/Cerveza.tar *.{nvram,vmsd,vmx,vmxf,log} )
Cerveza.nvram
Cerveza.vmsd
Cerveza.vmx
Cerveza.vmxf
vmware-26.log
vmware-27.log
vmware-28.log
vmware.log
#

7) Un-mount the USB drive.

# ls -log /mnt/usb
total 3706752
-rw-------    1 1502150656 Dec 15 16:24 Cerveza-s001.vmdk
-rw-------    1  373096448 Dec 15 16:24 Cerveza-s002.vmdk
-rw-------    1   38862848 Dec 15 16:24 Cerveza-s003.vmdk
-rw-------    1  251199488 Dec 15 16:24 Cerveza-s004.vmdk
-rw-------    1   70057984 Dec 15 16:24 Cerveza-s005.vmdk
-rw-------    1  221839360 Dec 15 16:24 Cerveza-s006.vmdk
-rw-------    1   65339392 Dec 15 16:24 Cerveza-s007.vmdk
-rw-------    1  670367744 Dec 15 16:24 Cerveza-s008.vmdk
-rw-------    1  598802432 Dec 15 16:24 Cerveza-s009.vmdk
-rw-------    1     589824 Dec 15 16:24 Cerveza-s010.vmdk
-rw-------    1      65536 Dec 15 16:24 Cerveza-s011.vmdk
-rw-r--r--    1     184320 Dec 15 16:26 Cerveza.tar
-rw-------    1        734 Dec 15 16:24 Cerveza.vmdk
drwx------    2      16384 Dec 15 15:46 lost+found
#
# sync ; umount /mnt/usb

On ESX 3.5 host: restore VM from a USB drive

1) Create a mount point.

# mkdir /mnt/usb

2) Attach a USB drive. Mount the file system.

# mount /dev/sdb1 /mnt/usb

3) Import the virtual disk (took 17 minutes to complete).

# mkdir /vmfs/volumes/storage1/Cerveza
#
# vmkfstools -i /mnt/usb/Cerveza.vmdk \
    /vmfs/volumes/storage1/Cerveza/Cerveza.vmdk
Destination disk format: VMFS thick
Cloning disk '/mnt/usb/Cerveza.vmdk'...
Clone: 100% done.
#

4) Copy virtual machine configuration files.

# cd /vmfs/volumes/storage1/Cerveza
# tar xf /mnt/usb/Cerveza.tar
#
# ls -log
total 20972224
-rw-------    1 21474836480 Dec 16 15:05 Cerveza-flat.vmdk
-rw-------    1        8664 Dec 15 16:17 Cerveza.nvram
-rw-------    1         400 Dec 16 15:05 Cerveza.vmdk
-rw-------    1           0 Nov 26  2007 Cerveza.vmsd
-rwxr-xr-x    1        1477 Oct 29 21:05 Cerveza.vmx
-rw-------    1         251 Oct 29 20:58 Cerveza.vmxf
-rw-r--r--    1       26693 Nov 22  2009 vmware-26.log
-rw-r--r--    1       26330 Mar 15  2010 vmware-27.log
-rw-r--r--    1       25531 Oct 29 14:28 vmware-28.log
-rw-r--r--    1       22416 Dec 15 16:17 vmware.log
#

5) Register the virtual machine.

# vmware-cmd -s register /vmfs/volumes/storage1/Cerveza/Cerveza.vmx
register(/vmfs/volumes/storage1/Cerveza/Cerveza.vmx) = 1
#
# vmware-cmd -l |grep Cerveza
/vmfs/volumes/4d0a6ad8-64d962f4-116a-0015c5f67030/Cerveza/Cerveza.vmx
#