VirtualBox has a shared folder feature that allows accessing the host computer physical hard drive partition and folders from the virtual machine. Once the VirtualBox guest additions installed properly, by doing additional steps, this can be enabled easily. But in some cases, if you want to attach a physical drive partition to a virtual machine from its settings, then you need to follow the steps to accomplish.
This step by steps method explains how you can access the physical disk in VirtualBox. Unfortunately, this cannot be done easily as how we do VMware workstation. Few commands and hard drive mapping involved in this process to access the physical disk partition in VirtualBox. This access method is called ‘Raw Disk’ access. Read more about what is Raw Disk
Before starting the procedure, let me explain how it’s going to work.
As I said earlier, it’s not easy as giving access to physical disk in VMware workstation. We have to create a configuration VMDK file for the host’s entire physical disk or partition. Then add this VMDK in Virtual Media Manager. Then allocate the disk to any Virtual Machine in VirtualBox.
Ok, now let’s start the steps.
How to Access Entire Physical Disk from VirtualBox
1) Open Command prompt in Host computer then go to the installation folder of the VirtualBox program, in most cases, it will be under this location.
2) Type: (This command is to access entire physical disk as Raw Disk)
VBoxManage internalcommands createrawvmdk -filename c: \Users \sunuser \.Virtualbox \VDI \mydrive.vmdk -rawdisk \ \ . \PhysicalDrive0
c: \Users \sunuser \.Virtualbox \VDI \mydrive.vmdk : Location and ‘ mydrive.vmdk’ is the configuration VMDK file of your entire physical drive.
Do not think that the new VMDK file will take huge size as your physical disk size. It’s just a 1KB size file. After you added this file to Virtual Media Manager, then you will get the full size of the physical disk.
\ \. \PhysicalDrive0 : is the physical drive of the host computer. 0,1, 2 numbers can be seen from Disk management in Windows OS under Computer Management. You insert the number as required physical disk number normally starts with 0.
3) You can confirm that the command worked correctly by visiting the location of the VMDK file created.
4) Now, Open VirtualBox, and go to Virtual Media Manager.
5) Add the newly created ‘mydrive.vmdk’ under the hard disk. Click here to read more about how to add VMDK file in VirtualBox
6) Add the newly added hard disk to the virtual machines in VirtualBox and start accessing them from the Virtual Machine Guest Operating system. Since this access has the write permission, ensure that any overwriting access from guest VM will not create any issues on the host OS.
How to Access Specific Partitions of Physical Disk from VirtualBox
To access specific partitions of host physical disk from VirtualBox, run the same command with additional switches,
VBoxManage internalcommands createrawvmdk -filename c: \Users \sunuser \.Virtualbox \VDI \ mydrive.vmdk -rawdisk \ \. \ PhysicalDrive0 -partitions 1,3
-partitions 1,3 : The partition numbers of PhysicalDrive 0. It will allow you to access the first and third partitions of the physical drive in this example.
This command also will create a VMDK file and you can access the drives as explained in the first method.
Remeber, by using these methods you can attach a physical disk partition and boot the OS if it has a bootable OS.