Mounting a physical disk or external disk to a VM in Hyper-V

Mounting a physical disk or external disk to a VM in Hyper-V

I think that mounting a physical disk or external disk to a VM in Hyper-V is really interesting, especially if you’re looking to attach a USB stick or an external HDD to a virtual machine.
The operation is very simple but I suggest you not to abuse it: mounting a disk through a USB port will result in getting a pretty slow data transfer, but at the same time it’ll result in instant data-portability.

So, in order to do that we just need to mark the disk as inactive. Open a command prompt and type the following.

Diskpart
List Disk

Now note the disk number you want to attach to the virtual machine, let’s say it’s number 3.
Run this.

Inactive Disk 3

You may now exist disk part and go in Hyper-V and attach a new disk to the virtual machine. In the screenshot below I attached it as an iSCSI controller.

attachexternaldisktohyper-vVM

The reason why I mounted a USB disk (once) was due a disaster occurred on one of the hypervisors where the File Server (VM) was running on.
So, once we were able to get all the data on the external disk, we plugged it into another hypervisor (Hyper-V on Windows Server 2012 R2) and started moving the data across to the new VM. It was taking ages and I needed this data available even if it would have been really slow for a day or so until I could get a larger maintenance window.
Attaching the disk to a virtual machine that way meant having production to keep running and almost nobody complained of the speed! Obviously you could just attach a physical disk connected to the Hyper-V host in order to dedicate it to the virtual machine.

IT Droplets

IT Droplets