GuidesHow to Use a Physical Hard Drive with a VirtualBox VM

How to Use a Physical Hard Drive with a VirtualBox VM

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

VirtualBox is a popular open-source virtualization software that allows you to create and run virtual machines (VMs) on your computer. While virtual machines provide many benefits, such as increased security and flexibility, there are times when you may need to use a physical hard drive with your VM.

Though it’s possible to create a virtual hard disk image from the existing contents of a physical drive, you might find it useful to directly mount or boot a physical drive on a VM.

And while this is fairly easy to do with the GUI of VMware and Hyper-V when configuring a VM, that isn’t the case with creating a VirtualBox physical disk, or a VirtualBox raw disk, in VirtualBox, as the process requires some command-line interface (CLI) usage.

VirtualBox can mount entire physical hard disks as well as only selected partitions of a drive. This tutorial will only discuss mounting entire VirtualBox physical hard disks.

How to Enable VirtualBox Raw Hard Disk Access

This method is called VirtualBox “raw hard disk access.” This allows you to mount or boot additional storage such as a secondary hard drive or external USB. We’ll show how to do this when running VirtualBox on a Windows, Linux, or macOS host machine.

Warning: Do not attempt to mount or boot the partition that runs the host OS with a VM, as that can lead to severe data corruption. And no matter which drive or partition you want to mount, it’s always a good idea to back up any existing data on it before continuing.

You’ll first want to create a VM within the VirtualBox GUI. Choose all options as normal, but when asked about the virtual hard drive, select Do not add a virtual hard drive.

Next, you’ll need to find the path and drive number of the physical drive you’d like to mount:

  • In Windows, open Disk Management. You’ll see the associated drive numbers on the left and will identify them later as PhysicalDrive0, PhysicalDrive1, etc.
  • In Linux, run the following command: sudo fdisk -l. You’ll see a listing of the partitions. Make note of the desired drive in the format of dev/sda0, dev/sda1, etc.
  • In macOS, use the following command: diskutil list. You’ll see a listing of the partitions. Make note of the desired drive in the format of /dev/disk0, /dev/disk1, etc.

Now open the CLI of your OS. If you’re using Windows as the host OS you will also need to go to the root directory of VirtualBox using the following command: cd C:Program FilesOracleVirtualBox

Creating the VirtualBox Hard Drive

Now you can run the command to create the virtual hard drive file that points to your desired physical drive. For each of the following examples, ensure that you input the desired names between the arrows and replace the number or pound sign with your desired drive number.


VBoxManage internalcommands createrawvmdk -filename "C:Users<user_name>VirtualBox VMs<VM_folder_name><file_name>.vmdk" -rawdisk .PhysicalDrive#


VBoxManage internalcommands createrawvmdk -filename "</path/to/file>.vmdk" -rawdisk /dev/sda


VBoxManage internalcommands createrawvmdk -filename "</path/to/file>.vmdk" -rawdisk /dev/disk#

This VMDK will be a very small file that simply points to your physical drive. Now you can attach the VMDK to your VM. To do so, open the VirtualBox GUI, select the desired VM, click Settings, click Storage, click the Add Hard Disk button, select Choose existing drive, and then select the VMDK file you just created.

You can now run the VM that will boot from the physical drive you defined when creating the VMDK file. 

If you need additional help you can refer to the official VirtualBox documentation on this topic.

Why You Might Want to Use a Physical Hard Drive with VirtualBox

There are several reasons why you might want to use a physical hard drive with VirtualBox, such as retaining your old OS and data as you move to a new system, isolating two OS versions, or simply because it offers better flexibility and compatibility.

Retention of old OS and data

You can retain an old OS and data by using VirtualBox with a physical hard drive, creating a VM that runs the previous OS and accessing the data stored on the physical hard drive.

This can be useful if you have an old computer with essential data that you want to keep but can no longer use due to hardware failures or other issues. By using VirtualBox with a physical hard drive, you can create a VM that runs the old OS and access the data stored on the physical hard drive.

Isolation of OSs

For security reasons, you may want to avoid a situation where you will be transferring files between your hard drive and VM. By using VirtualBox with a physical hard drive, you can create a VM that runs an OS or application in isolation, which can help prevent conflicts or security issues on the host system.

Better compatibility

Some OSs or applications may not work correctly with virtual hard drives, but can work seamlessly when installed on a physical hard drive and accessed through VirtualBox. By installing such applications on your physical hard drive and accessing them through your VirtualBox, you can avoid these compatibility issues and ensure that everything continues to run smoothly.

Provides flexibility 

Using a physical hard drive with a VirtualBox provides more flexibility in using your computer. For example, you can run multiple OSs on your computer simultaneously, which can be useful if you need to test software or if you need to use different OSs for other tasks. You can also use your computer as a test environment for software development, which can help you avoid conflicts with your main OS and applications.

Risks of Using a Physical Hard Drive in VirtualBox

Although using a physical hard drive in VirtualBox VM has a lot of benefits, it comes with some risks. These include data loss, security concerns, and compatibility and performance issues.

Possibility of data loss

If the physical hard drive is not properly configured for use with the VirtualBox VM, it may cause data loss or corrupt your files. For instance, if the physical hard drive is not set up correctly to work with the VM, it may not be able to handle the volume of data being transferred between the host OS and the VM. This can result in data loss or corruption, which can be difficult to mitigate.

To avoid this risk, it’s important to properly configure the physical hard drive and ensure that it is compatible with both VirtualBox and the guest OS. In other words, it is also a good practice to regularly back up important data before running any virtualization software on your system to prevent data loss of this kind in case something goes haywire.

Security risks

While VirtualBox is built to execute its operations in a protected and isolated environment on the host OS, it does not totally insulate your machine’s hard drive from security risks. When using a physical hard drive with a VM, the VM can get infected with malware, potentially spreading to the host OS through the physical hard drive. 

This is the case for many computers with the addition of the MMU virtualization feature to their processors, which allows direct memory access (DMA). This addition allows guest VMs like VirtualBox to directly access peripheral devices, such as accelerated graphics cards, Ethernet, and hard-drive controllers, through interrupt remapping, also known as PCI passthrough. To mitigate this risk, it’s important to ensure that the VM is properly secured and running up-to-date anti-malware software. 

Compatibility issues

You might run into compatibility issues when trying to run VirtualBox on some OS versions. For instance, in a statement, Microsoft acknowledged that users experienced compatibility issues when running VirtualBox on Windows 11. Although Microsoft has provided some updates to resolve this compatibility issue, it is illustrative of the importance of ensuring that the hard drive and OS version are compatible with the VirtualBox. 

You should consider going through the VirtualBox end-user and technical documentation pages to ensure your physical hard drive and OS meet the requirements.

Performance risks 

Using a physical hard drive with a VM may result in reduced performance, particularly if the host and guest OSs access the physical hard drive simultaneously. If you have such a scenario, you risk causing delays or other issues that can affect the user experience. 

To avoid this type of experience, consider using a physical hard drive with high-performance specifications, such as a solid-state drive (SSD). Configure your VM to limit the amount of data transferred between the host and guest OSs. You should also avoid running resource-intensive applications simultaneously on the host and guest OSs.

Bottom Line: Using a Physical Drive with a VirtualBox VM

Using a physical hard drive with a VirtualBox VM can be a useful way to access data stored on a separate disk, run multiple OSs, and enjoy flexibility on your computer. However, it is essential to note that some limitations and risks are associated with that.

One of the main limitations is the risk of data loss or file corruption if the physical hard drive is not properly configured when using it with the VM. It is also worth noting that using a physical hard drive with a VirtualBox may require advanced technical knowledge and may not be suitable for beginners or those unfamiliar with virtualization technology. 

Therefore, in addition to going through the VirtualBox documentation page, it‘s recommended that you have a good understanding of virtualization, disk partitioning, and file systems before attempting to use a physical hard drive with a VM.

If you’re considering other virtualization options, we reviewed the best server virtualization software for various use cases.

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories