Mount a USB to Hyper-V Virtual Machine

 

Since I wanted to test the new features of SCCM 2012 on my test server, I decided to install Hyper-V on a Windows 2008 R2 SP1. After everything was installed and worked fine, I needed to mount a USB removable storage to the VM.

To do this on my Ubuntu host and VMware I chose “Removable Storage” on my VM and select the USB attached to my host machine. Or even easier; I copy the file or folder from the USB on my Ubuntu host and paste it on the VM...very easy :)
This didn't work on Hyper-V. I checked the settings on Hyper-V server and the VM. There was no option to mount a USB removable storage to the guest VM and no option for “file sharing”.

I came across some different solutions on some tech-forums, but non of them satisfied me. While playing and trying around, I found the shortest and easiest way that worked for me. Mounting the USB removable storage as a VHD.

Before you start, you have to now the size of your removable storage that you will need in step 3. To learn the real size, on your host machine clickComputer → right-click removable disk → properties: On general tab you will see it written as Bytes and GB.

 

1. First right click on your Hyper-V server or chose from Actions: New → Hard Disk

 

2. After clicking twice Next write the name you want (I named my vhd driveUSB.vhd). Click Next 

  

3. Select “copy the content of the specified physical disk” and select the physical drive that is corresponding to your removable storage. In my case, it is the “Physicaldrive3 - 7 GB”

 

 

4. Now it is copying the content of the removable storage and creating the USB.vhd file. Depending on the size this can take some minutes. It doesn't matter how much free space you have on your removable storage, because it creates a vhd file with the entire size of the removable storage

 

5. Now on your VM, go to settings, on the left pane select SCSI Controller, on the right pane select Hard drive then click Add

 

6. Click Browse and chose the vhd-file that you have mounted your removable storage to. In my case it is USB.vhd. Click open. That's it.. 

 

 

7. Now you should be able to see the removable storage as a drive, when going to Computer. In my case it is Local Disk (E:) with 7.61 GB 

 

Troubleshooting:
If you can't see your removable storage on “My computer”, it is possible that the drive is off-line.
On your VM, go to computer Management (right-click Computer manage or administrative tools → computer management).

Expand Storage and select Disk Management. If there is red arrow icon, this means that the disk is off-line. Right-click the disk (in my case Disk 1) and select Online

 

And now the disk becomes online and a drive letter is assigned to it. Now you can see the drive when you you go to Computer

 

 

Removing (unmount) the drive:

If you don't need the drive anymore and want to remove it, on your Hyper-V Manager, right-click your VM, select Settings → SCSI Controller → Hard Drive (your USB.vhd). On the right pane click Remove → Apply → OK

Tip: Mounting the drive to multiple VMs. You can use the drive on multiple VMs as long as every VM has its dedicated vhd file. To do that, copy the USB.vhd file and rename it as needed. Then mount it to another VM.

By default, the vhd files are under "C:\Users\Public\Documents\Hyper-V\Virtual hard disks”

 

P.S. One disadvantage with this method is, that you have to re-do every single step for every new USB drive that you want to connect to your VM on Hyper-V. Another disadvantage is, that at the first time when creating the vhd file, it takes a while also depending on the size of your USB disk. You should use USB disks with small sizes.

 

 

Trackback URL for this post:

http://www.gokhancanpolat.com/trackback/130

Comments

Nice post! recommended for

Nice post! recommended for reading. good alternative way for mounting USB/make USB data work (read-write) from USB stick

#sorry for my bad English hehehe..

Great method to get around

Great method to get around the USB passthru limitation! Installed Server 2012 on a guest from a USB installation drive. Thanks for sharing!

USB Dongle...

I'm trying to install software on a Hyper-V VM that requires a dongle for security. How would you go about configuring a dongle to work with Hyper-V??? I don't think I can just copy it to a drive...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.