How to Use Windows Drive as a Hard Disk On VirtualBox VM

VirtualBox allows you to add new Hard Disks from the UI, you can just goto Virtual machine settings and add new hard disks, but its a bit tricky if you want to use as one of your hard disk partitions as the new hard disk, specially if your host is Windows OS. We are going to use VBoxManage utility which was installed with VirtualBox.

To be able to use any selected hard disk partition on your VirtualBox VM follow the steps below, I am going to give all the details and explanations but my assumption is you at least have an understanding of virtual machines, command line and environment variables.

What is VBoxManage?

VBoxManage utility allows you to configure and control almost all the aspects of VirtualBox which includes creating virtual hard disks, network interfaces configuring your virtual machines and much more.

For the purpose of this howto we are going to use VBoxManage to list the partitions, and then create a virtual disk file which will be pointing to one of the hard drive partitions.

Set up Environment Variable

First we need to set up the “PATH” environment variable, when ever you run a command on command line all the folders specified in “PATH” environment variable are search to find the respective executable.

Click on Start menu and type “system”, click on “System” Control Panel menu item.

System Control Panel App in Start Menu

Click “Environment Variables” in System properties window.

System Properties Window

Under “System Variables” select “Path” variable and click “Edit”.

Select Path Environment variable

Click “New”




Be default VirtualBox is installed in “C:\Program Files\Oracle\VirtualBox”, if you haven’t installed in custom folder location just add this path in the new field.


Find Out The Hard Drive Number

Now we need to find out the Hard Drive number, so we can properly construct the PhsyicalDrive (more on this later) name for VBoxManage utility.

Click on Start Menu and type “hard disk partitions” and click on “Create and format hard disk partitions”.


In the “Disk Management” window note the Disk number from the left side of the disk.


Create Virtual Drive using VBoxManage

Now we are going to create a virtual disk which we will map to one of the partitions of our physical drive. As we have already noted the physical disk number which is “1” so our Physical Drive construct would look something like: “\\.\PhysicalDrive1”

Click on Start Menu and type “cmd”, right-click on “Command Prompt” menu item and click “Run as administrator”.


Run the following command to get the list of partitions, so we can use the partition number in next command:

# VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive1

You should see an output like following


Now that we know the partition numbers we can map them to virtual disk files and then add those virtual disks to our Virtual Machine.

Run the following command to map partition number 5 from above output to HomeDrive.vmdk

# VBoxManage internalcommands createrawvmdk  -filename "C:\Users\hamekhan\VirtualBox VMs\Hawk\HomeDrive.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 5

If the command will execute successfully you should see something like


Now goto your virtual machine settings and select navigate to “Storage” from left side then click on the plus sign with hard drive icon under your desired controller.


Click on “Choose Existing” and navigate to the folder where you created the “.vmdk” file and then select the file.


That’s it, now boot your VM and start using the new hard disk in your virtual machine.

Common Errors


If you get the “VERR_ACCESS_DENIED”, make sure you have started the “Command Prompt” with administrator privileges, see first step in “Create Virtual Drive using VBoxManage”.


Published by

Hameedullah Khan

VR enthusiast, Cloud Architect, Passionate Programmer and Opensource advocate.

One thought on “How to Use Windows Drive as a Hard Disk On VirtualBox VM”

Leave a Reply

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

CommentLuv badge