Most of the time, tutorials on the Internet explain how to connect a physical (real) USB key to a virtual machine for use from the virtual machine.
However, we recently noticed that it was possible to create virtual USB keys (in the form of ".vmdk" files) that we can then plug into our virtual machine.
The virtual machine will therefore think that it's an USB key, whereas in reality it will be a simple VMDK file on the host PC which will be plugged in connected to the virtual USB 2 (EHCI) controller of the virtual machine.
This tutorial will therefore allow you to test different programs that require an USB key without having to buy or use a real USB key.
Thus, in case of problem, your real USB key will not be in danger.
In the VMware Workstation folder, you will find a "vmware-vdiskmanager.exe" executable file which corresponds to : VMware Virtual Disk Manager.
This small utility allows you to create virtual disks in vmdk format.
To use it, open a command prompt (cmd) and navigate to the VMware Workstation folder :
cd "C:\Program Files (x86)\VMware\VMware Workstation"
Then, to create the virtual disk, we will use this "vmware-vdiskmanager.exe" program.
To know all the parameters available for this "VMware Virtual Disk Manager" program, run this program without parameter from the command prompt (cmd) or go to the official VMware website : Running the VMware Virtual Disk Manager Utility.
For this tutorial, we are going to create a 16 GB USB key for our "Win 10 v2004 Pro x64" virtual machine.
For that, we will use the command below, of which here are the explanations :
vmware-vdiskmanager.exe -c -a buslogic -s 16GB -t 0 "H:\Win 10 v2004 Pro x64\virt-usb-key.vmdk"
Once the command is executed, this will be displayed in the console.
Note : you can ignore the error about "VixDiskLib ... PhoneHome library". This message is not supposed to appear and is due to an oversight on the part of a VMware developer.
VixDiskLib: Failed to initialize PhoneHome library. Creating disk 'H:\Win 10 v2004 Pro x64\virt-usb-key.vmdk' Virtual disk creation successful.
To attach the virtual USB key to your virtual machine, you will need to modify its associated ".vmx" file, as this is not possible from the VMware Workstation GUI.
To start, stop your virtual machine (if it's not already done) and close the "VMware Workstation" window where your virtual machine appears.
In the ".vmx" file of the VM, check that these lines are present :
ehci.present = "TRUE" ehci.pciSlotNumber = "xx"
In the VM's ".vmx" file, add this :
ehci:0.present = "TRUE" ehci:0.deviceType = "disk" ehci:0.fileName = "virt-usb-key.vmdk" ehci:0.readonly = "FALSE"
Once the ".vmx" file of your virtual machine has been modified, double-click on it so that VMware Workstation uses the new settings there.
As you can see, your virtual USB drive doesn't appear here.
And it doesn't appear in its virtual hardware either, since it's not normally offered.
Although nothing appears in your virtual machine information, you will see informations displayed after the virtual machine is started.
If you open the Device Manager, you will see your virtual USB key appear in the "Disk drives" section with the "VMware Virtual Storage USB Device" name.
When you create a virtual disk with the utility of VMware, it doesn't contain a file system (such as : FAT32, NTFS, ...) by default.
The USB drive therefore appears in the file explorer of the guest OS, but it can't be used for the moment.
To format it (and therefore create a file system on it), double-click on it.
Windows will tell you that you need to format the drive disk before using it.
Click on "Format disk".
Change the file system to use if you want, then click : Start.
Confirm the formatting of the drive by clicking OK.
Formatting is complete.
Now, our USB drive is available and has a size of 16 GB.
® InformatiWeb-Pro.net - InformatiWeb.net 2008-2021 - © Lionel Eppe - All rights reserved.
Total or partial reproduction of this site is prohibited and constitutes an infringement punishable by articles L.335-2 and following of the intellectual property Code.