LOGO

Access Local & USB Hard Drives in Hyper-V Virtual Machines

August 3, 2015
Access Local & USB Hard Drives in Hyper-V Virtual Machines

Accessing Local Drives in Hyper-V Virtual Machines

Gaining access to a local hard drive – whether it resides internally within your computer or is connected externally – from a virtual machine operating within Hyper-V offers significant convenience.

However, determining the precise method for achieving this functionality can often prove challenging.

This guide will provide a step-by-step walkthrough to facilitate this process.

Enhanced Session Mode

The most straightforward approach involves utilizing Enhanced Session Mode. This feature allows for seamless integration between the host machine and the virtual machine.

Ensure that Enhanced Session Mode is enabled within your Hyper-V settings for the specific virtual machine you intend to use.

Drive Redirection

Once Enhanced Session Mode is active, you can redirect local drives to the virtual machine.

This is typically accomplished during the connection process to the virtual machine.

When connecting, a window will appear presenting a list of local drives.

Selecting Drives for Redirection

Simply check the boxes next to the drives you wish to make available within the virtual machine.

These drives will then appear as network locations within the guest operating system.

Alternative Method: Shared Folders

If Enhanced Session Mode isn't suitable, shared folders provide an alternative solution.

Within Hyper-V Manager, navigate to the settings of your virtual machine.

Configuring Shared Folders

Locate the "Integration Services" section and select "Shared Folders".

Click "Add" to specify the host folder you want to share.

You can choose whether the folder is read-only or allows both read and write access.

Accessing Shared Folders in the VM

Within the virtual machine, shared folders will typically be accessible under the "Network" section in File Explorer.

They will be identified with a specific share name.

Troubleshooting

If you encounter issues, verify that the Hyper-V Integration Services are up-to-date within the virtual machine.

Outdated integration services can sometimes cause compatibility problems.

Also, confirm that the user account within the virtual machine has the necessary permissions to access the shared folders or redirected drives.

Understanding the Need for Direct Hard Drive Access in Hyper-V

Numerous situations may necessitate accessing a physical hard drive from within a Hyper-V virtual machine. These include data transfer, importing information, exporting virtual machine data to an external drive, and working with disc images.

Related: A Guide to Creating and Running Virtual Machines with Hyper-V

Regardless of the specific requirement, granting a Hyper-V virtual machine access to a locally connected hard drive isn't straightforward. Unlike some other virtualization platforms, Hyper-V doesn't offer a simple resource-sharing mechanism between the host and its virtual machines.

Successfully utilizing a drive within a Hyper-V environment requires a specific process. The drive, currently connected and mounted on the host machine, must first be taken offline before it can be redirected for use by the virtual machine.

It’s important to note a limitation before proceeding: this method is compatible with traditional hard drives – including magnetic, solid-state, and removable USB drives – but will not function with removable media such as USB flash drives.

The Process of Offline Drive Access

The core principle involves detaching the drive from the host operating system and presenting it to the virtual machine as a direct access device. This differs from shared folder approaches common in other virtualization software.

This method provides a direct pathway for the virtual machine to interact with the physical drive, bypassing the usual host-level mediation. However, it requires careful execution to avoid data corruption or system instability.

  • The drive must be fully offline from the host.
  • The virtual machine must be configured to recognize the direct access device.
  • Proper precautions should be taken to ensure data integrity.

Understanding these prerequisites is crucial for a successful implementation. Incorrectly configuring the drive access can lead to unexpected results.

Why This Approach is Necessary

Hyper-V’s architecture prioritizes isolation between the host and guest operating systems. This design choice enhances security and stability, but it also introduces complexities when direct hardware access is required.

The lack of a simple "share" function is a consequence of this architectural decision. While potentially inconvenient, it contributes to the overall robustness of the Hyper-V platform.

Therefore, the offline drive redirection method represents a deliberate trade-off between convenience and security within the Hyper-V ecosystem.

Preparing and Mounting Drives in Hyper-V

The process of utilizing a physical drive within a Hyper-V virtual machine involves two key stages. Initially, the disk must be managed within the Windows environment of the host machine, transitioning it to an offline state while remaining powered and connected. Subsequently, Hyper-V needs to be instructed to assume control over this now-offline disk.

Drive Preparation Procedures

The initial step entails bringing the disk offline. To accomplish this, launch the Disk Management application. This can be done by searching for the application’s name or by executing "diskmgmt.msc" in the search field.

While it’s reasonable to assume familiarity with Disk Management given your engagement with Hyper-V and physical disk passthrough, a cautionary note is essential. Disk Management is a potent tool, and improper use can lead to system instability. Verify each action carefully, ensuring you are operating on the correct disk(s).

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-1.jpg

In this instance, we aim to pass Disk 10, a USB backup HDD, to the virtual machine for transferring backup files. To prepare the disk, locate it within the Disk Management list, right-click on it, and select "Offline" from the context menu, as illustrated in the image above.

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-2.jpg

Confirm that the disk is now offline. To restore access to the disk for the host operating system after use within the virtual machine, simply return to this menu, right-click the disk, and select "Online".

Integrating the Drive into the Virtual Machine

With the disk offline on the host, the next step is to add it to the virtual machine within Hyper-V. Initiate Hyper-V and, from the Virtual Machines list, choose the machine to which you want to pass the hard disk.

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-3.jpg

Right-click on the selected machine and choose "Settings..."

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-4.jpg

Within the Settings menu, select "SCSI Controller" from the left-hand navigation. Then, select "Hard Drive" and click the "Add" button.

Note: It is assumed that you intend to pass the hard drive to a virtualized operating system, implying the presence of a SCSI controller and virtual disk for the OS. If a SCSI controller is not yet configured, you must first select "Add Hardware" and add a "SCSI Controller" to your virtual machine.

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-5.jpg

Choose "Physical hard disk" and select the offline disk from the dropdown menu. There is no risk of accidentally selecting a disk from the host machine that wasn't intended for use. Only disks that are powered and attached to the host but in an offline state are available in this menu. A disk must be offline to appear as an option.

Verify the selected disk is correct. Press "Apply" and then "OK". Start your virtual machine.

Accessing the Passed-Through Hard Disk

Typically, the disk will be automatically detected by the guest operating system as if it were a physically attached drive.

As demonstrated in the screenshot, booting into a virtual machine for an image restore procedure using Windows PE and Macrium Reflect resulted in automatic disk detection and mounting.

how-to-access-local-and-usb-hard-drives-in-your-hyper-v-virtual-machine-6.jpg

If the disk is not immediately accessible, you may need to open Disk Management within the virtual machine’s operating system and bring the disk online. Equivalent actions may be required in other operating systems to access the disk.

A crucial caution: The operating system within the virtual machine is unaware that the disk belongs to the host machine and will operate on it accordingly. If the disk doesn't automatically mount, use a mounting procedure (refer to the OS documentation) to mount it non-destructively, ensuring it can be returned to the host operating system later.

When the disk is no longer needed, shut down the virtual machine. Avoid altering the drive state via the host machine until the virtual machine is powered off. You can remove the hard drive from the virtual SCSI controller if it won’t be used again, or leave the entry in place. If the physical drive is disconnected from the host or brought online for the host OS, it will simply appear unavailable to the virtual machine.

#Hyper-V#virtual machine#USB drive#local hard drive#access#connect