Hyper-V VM on physical disk instead of VHD file


Storing a Hyper-V virtual machine directly on physical disk, instead of a VHD file, is a practical method to speed up the VM. In addition, it makes it easy to switch from VM to real, physical dual boot, when required. Confusing? Let me explain.

Set disk offline

All internal and external disks (HDD & SSD) except Windows system disk can be set offline. When offline, a disk can be attached to a Hyper-V virtual machine.

To set disk offline, you can use DISKPART in an elevated Command Prompt. First, start DISKPART (#1 in next screenshot) and check the disk ID with command LIST DISK (#2). Select the disk to be set offline with command SEL DISK X (#3), where X is the ID of disk to be set offline. Be sure to select correct disk! Enter command OFF DISK (#4) to set disk offline, and finally quit DISKPART with command EXIT (#5):

Click screenshots to open them enlarged in a new tab.

Alternatively, you can use Windows Disk Management to set a disk offline:

Create a VM

Create a new virtual machine. In New Virtual Machine Wizard, select Attach a virtual hard disk later:

When VM is created, open its settings and add a disk:

Select a disk you set offline earlier:

That’s it. You can now install Windows (or any other OS) on your VM. Because one step is missing, creating a VHD file and installing OS on file instead of real disk, the VM is and will be about as fast an OS on real, physical installation.

Backup?

Unfortunately, when a VM uses physical disk instead of a VHD file, you cannot create checkpoints. This is because Hyper-V requires a VHD or VHDX file in order to be able to create a checkpoint AVHD or AVHDX checkpoint file. As the VM has no VHD or VHDX, checkpoint can’t be created. If you want to backup your VM before doing some testing, you must use a third party tool like Macrium Reflect to create a system image backup.

The same with exporting VM. You can export a VM which uses a physical disk instead of a VHD file, but only machine settings will be exported, not the disk. When importing this VM back to Hyper-V, it has no disk.

However, if you have activated Windows on your VM on a physical disk, I recommend you export it. Because the Windows digital license is not depending on disk, when imported back to Hyper-V, any Windows installation on that VM will be automatically activated based on machine’s digital license, regardless if you will use a physical disk or VHD file to install Windows on it.

Short: if your Windows installation on a Hyper-V VM using a physical disk is activated, export it. This way, when you discard the VM and want to start from scratch, you can just import it back to Hyper-V, install Windows on a VHD file or physical disk, and it will be automatically activated based on an existing digital license.

More about reusing and preserving VM licenses: How to reuse and move Hyper-V VM digital license (activation)

Dual boot instead of VM ?

Only con in using a VM is, that it is not using the real, physical hardware of your host. When you really need to use the existing real hardware devices, you must first set the disk back online, and then add it to Windows boot menu for dual / multi boot.

Fortunately, that’s easy. Shut down the VM and open an elevated Command Prompt, use command ONL DISK in DISKPART (#1 in next screenshot) instead off OFF DISK, as shown above in Set disk offline, or use Disk Management to set the disk back online.

Windows will assign a drive letter to Windows partition on that disk. Check the drive letter, and add it to Windows boot menu in an elevated Command Prompt with command BCDBOOT X:\Windows (#2), replacing drive letter X with the actual drive letter. Last, change the boot menu description to something that helps you separate it from your current OS with command bcdedit /set {default} description “Any name” (#3). Default boot menu entry for all Windows 10 installations is Windows 10, so it’s a good idea to change the description:

You can now restart computer, and boot to this additional OS:

The new OS was added as default OS to boot menu. You can change the default OS, the one which will be booted if user does not select any OS within 30 seconds, or remove the secondary OS from boot menu, using System Configuration tool. Press WIN + R to open RUN dialog, type MSCONFIG to start the tool, select BOOT tab, and make your changes:

To boot the virtual machine again, remember to set the disk offline and remove it from boot menu!

That’s it. Easy, fast and flexible!

Kari

Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.