Convert a USB drive into a Virtual Machine HDD

6

1

I am creating a bootable USB flash drive. Before using it I would like to test it with VMware Player (or VirtualBox).

I could make a raw image of the UFD and convert it with "qemu"

qemu-img convert -O vmdk imagefile.img imagefile.vmdk

or I can use raw2vmdk.

My problem is that my UFD is very large when compared to the actual data stored on it (larger than the primary HDD on my system). So there is no room for the raw image and the vmdk file on my system.

Is it possible to make a raw image of the UFD based only on the actual data (used sectors)?

Or is it at least possible to have a direct process? UFD to VMDK without passing via a raw image?

I would like to avoid solutions with physical UFD which oblige me to keep my UFD plugged.

Obviously, after playing with the virtual machine, the reverse should be possible, i.e. copy the virtual drive onto the UFD.

antonio

Posted 2013-08-22T10:07:55.577

Reputation: 647

If you want to do this you will need to have additional storage. – Ramhound – 2013-08-22T11:29:40.777

Answers

2

You can use VBoxManage, it comes with VirtualBox.

This'll create "transparent" virtual disk, which gives you direct access to specified device. VBoxManage internalcommands createrawvmdk -filename mydrive.vmdk -rawdisk \\.\PhysicalDrive0

Look here for more examples: http://www.sysprobs.com/access-physical-disk-virtualbox-desktop-virtualization-software

week

Posted 2013-08-22T10:07:55.577

Reputation: 3 128

Thanks. Just one thing. Should my UFD be plugged only when running VBoxManage internalcommands createrawvmdk... or also after when I use mydrive.vmdk in the guest VM? – antonio – 2013-08-22T14:02:47.893

That image file act as kind of proxy, so you have to plug UFD. Never tried it, but I think that you can use clonehd parameter to clone your UFD partition through that mydrive.vmdk, to image with variable size. – week – 2013-08-22T14:30:31.657

5

for those wanting to convert the drive instead of using a transparent virtual disk, or link... (took me around 20 minutes to convert a 32GB USB drive to vmdk)

VBoxManage convertfromraw \\.\PhysicalDrive2 D:\VirtualMachines.vmdk --format vmdk
  • *\.\PhysicalDrive = number of your USB drive found in Disk Management
  • *D:\VirtualMachines = this is the path I used. can be anywhere.
  • *.vmdk / --format vmdk = the extension and chosen format should match.

A. Richards

Posted 2013-08-22T10:07:55.577

Reputation: 71