Linux – Manually cloning a Live USB Arch distro to a VMware virtual disk

bootlive-usbpartitionsyslinuxvmware

I installed Arch Linux on a pen drive with yumi, based on syslinux. I would like to test the USB distro in VMware.
To speed up things I would like to clone the UFD as a VMware virtual disk (vmdk).

This can be simple. I attach to the virtual machine the physical UFD drive, the vmdk virtual disk and the Arch ISO.
Bootstrapping from the latter, I can clone.

My problem is that the UFD is very large and I would like to copy/clone only the actual UFD used sectors.

I don't know if there are specific tools for cloning only used sectors. My idea is to manually format the vmdk disk and then copy the UFD files.

Given the following disk mapping:

Virtual vmdk disk -> sda
Physical UFD disk -> sdb

I issued these commands:

# Format vmdk disk as FAT32
(echo o; echo n; echo p; echo 1; echo ; echo ; echo a; echo t; echo c; echo w) | fdisk /dev/sda
mkdosfs -F 32 /dev/sda1

#Copy UFD MBR to vmdk MBR
dd if=/dev/sdb of=/dev/sda bs=446 count=1
partprobe /dev/sda

#Mount vmdk 
mkdir /vmdk
mount -t vfat /dev/sda1 /vmdk

#Mount UDF
mkdir /usb
mount -t vfat /dev/sdb1 /usb

#Copy files from UFD to vmdk
cp -a  /usb/* /vmdk

After them, fdisk -l gives:

Disk /dev/sda: 858 MB, 858783744 bytes, 1677312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc3072e18

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1677311 837632 c W95 FAT32 (LBA)

Disk /dev/sdb: 4048 MB, 4048551936 bytes, 7907328 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc3072e18

Device Boot Start End Blocks Id System
/dev/sdb1 * 2976 7907327 3952176 c W95 FAT32 (LBA)

Disk /dev/mapper/arch_root-image: 1563 MB, 1563426816 bytes, 3053568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Unfortunately, when I shutdown the VM, detach the UFD and the ISO, and restart the machine, VMware says:

This is not a bootable disk... 

Can you help me?

Best Answer

I think you can use one of the methods discussed in this U&L Q&A titled: How can I zero files out inside a VMware image file so that their space can be reclaimed? to zero out any unused space in the image prior, so that it can be reclaimed, prior so that the image size can be reduced.

Related Question