Convert a USB drive into a Virtual Machine HDD

18,514

Solution 1

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

Solution 2

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.
Share:
18,514

Related videos on Youtube

antonio
Author by

antonio

I use Emacs and R for financial research Consider to post or follow the virtualization proposal.

Updated on September 18, 2022

Comments

  • antonio
    antonio over 1 year

    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.

    • Ramhound
      Ramhound over 10 years
      If you want to do this you will need to have additional storage.
  • antonio
    antonio over 10 years
    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?
  • week
    week over 10 years
    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.
  • stackprotector
    stackprotector about 3 years
    clonehd throws an error on a .vmdk that links to a raw disk. Use A. Richards answer instead to create an unlinked disk file.