How to Access Local and USB Hard Drives In Your Hyper-V Virtual Machine

There are dozens of scenarios where you would want to access a physical hard drive from inside your Hyper-V virtual machine ranging from accessing and importing data, dumping data from the virtual machine into the external drive, and importing or exporting disc images.

Whatever reason you have for wanting to access an existing local hard drive in your Hyper-V machine it’s, unfortunately, a bit complicated giving the drives access to the virtual machine. Unlike other virtualization solutions (VMware and VirtualBox) there is no easy way to just share resources between the host machine and the Hyper-V virtual machine.

To use a drive within a Hyper-V machine you need to take the drive, while physically attached and mounted to the host machine, offline and then reroute the offline-to-the-host disk into the virtual machine. Let’s take a look at how to do that now.

A quick note before we proceed: this trick only works with hard drives (magnetic hard drives, solid-state hard drives, and removable USB hard drives) but does not work, alas, with removable media like flash drives.

Drive Preparation and Mounting In Hyper-V

There are two primary steps to the procedure. First we need to manage the disk from within Windows on the host machine to bring it offline (but still powered and attached to the host computer) and then we need to tell Hyper-V to take control of the now-offline disk.

Preparing the Drive

The first step is to bring the disk offline. To do so open up the Disk Management application by searching for the application name or typing “diskmgmt.msc” in the search box and running the app. Within Disk Management look for the drive you wish to pass through to the virtual machine.

Although it’s probably safe to assume, since you’re playing around with Hyper-V and concerned with matters like physical-disk-pass-through, that you’re already familiar with Disk Management it would be remiss of us not to issue a standard warning: Disk Management is a powerful tool and you can do terrible things to your system by mucking about within the management system. Double check each step and make sure you’re working with the right disk(s).

clip_image001

In our case we want to pass Disk 10, a USB backup HDD, through to the virtual machine so we can dump some backup files from our virtual machine onto the disk. To prepare the disk we must first locate it in the list of drives within Disk Management, right click on it, and select “Offline” from the right-click context menu as seen in the screenshot above.

clip_image002

Confirm the disk is offline. If you wish to bring the disk back online, after you’re done using it within the virtual machine, simply return to this menu, right click on the disk, and select “Online” to bring the disk back online for the host operating system.

Adding the Drive to the Virtual Machine

Once the disk is offline to the host operating system it’s time to add the disk to the virtual machine within Hyper-V. Launch Hyper-V and, from your Virtual Machines list, select the machine you wish to pass the hard disk through to.

clip_image003

Right click on the machine and select “Settings…”

clip_image004

From within the Settings menu for that specific virtual machine, select “SCSI Controller” from the left hand navigation pane. Select “Hard Drive” and click the “Add” button.

Note: We’ve presumed you wish to pass the hard drive through to the virtualized operating system which means you already have a SCSI controller and virtual disk for the OS. If you do not yet have a SCSI controller you will need to first select “Add Hardware” at the top of the navigation pane and add a “SCSI Controller” to your virtual machine.

clip_image005

Select “Physical hard disk” and then, from the drop down menu, select the disk you brought offline in the previous section of the tutorial. Don’t worry there’s no chance you’ll accidentally select a disk from the host machine that you didn’t intend to use. The only disks you can select in the physical hard disk menu are disks that are powered and attached to the host machine but in an offline state. If you didn’t put it offline it isn’t even an option.

Confirm the disk selected is the disk you want. Press the “Apply” button and then “OK”. Boot up your virtual machine.

Accessing Your Pass-through Hard Disk

In the vast majority of cases the disk should be automatically detected by the host operating system as if it was simply a physical disk attached to the real machine the virtual machine is emulating.

If the disk isn’t immediately accessible to the virtual machine operating system you may need to open up, in the case of Windows, Disk Management and bring the disk online. When using other operating systems you’ll need to perform an equivalent action to access the disk through the virtual OS.

A very important word of caution here. The OS in the virtual machine has no idea that this disk actually belongs to your host machine and it will act upon the disk however you tell it to act upon the disk. If the disk does not automatically mount in your virtual machine OS you need to use a mounting procedure (refer to documentation for the particular OS in question) to mount the disk in the non-destructive way so that it can be returned to the host operating system later on.

When you no longer need the disk in the virtual machine simply boot down the virtual machine. Do not attempt to make changes to the drive state via the host machine until you’ve turned off the virtual machine the drive is connected to.

You can outright remove the hard drive from the virtual SCSI controller in your virtual machine if you aren’t going to use it again or you can leave the entry. Any time the physical drive is disconnected from the host machine or you’ve made it online for the host operating system the drive will simply appear as unavailable to the virtual machine.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.