How to connect a hard drive to VirtualBox

And while USB drive passthrough 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, Windows Server Tutorials in VirtualBox, as the process requires some CLI usage. VirtualBox can mount entire physical hard disks as well as only selected partitions of a drive.

VirtualBox USB Drive Passthrough

In this tutorial, we will discuss two methods of VirtualBox USB drive access: with the help of special software and native mounting entire VirtualBox physical hard disks.

Software solution to forward USB drive to VirtualBox

USB Network Gate is a software solution that simplifies the implementation of VirtualBox USB passthrough on guest virtual machines. It is a flexible application that addresses the problem of obtaining USB connectivity when working in virtual environments.

Try for FREE USB Network Gate
14-day free trial

You can set up VirtualBox access to USB hard drive with just three steps:

  1. Download and install the USB Network Gate application on the machine with the attached USB drive.
  2. Use the software interface to share the drive.
  3. On a virtual machine, install USB Network Gate. Start the app and connect it to the VirtualBox external hard drive.

Watch our VirtualBox USB passthrough video guide

Using USB redirection technology, USB Network Gate permits a VirtualBox hard drive’s data to be forwarded over the Internet or a LAN. Now you have access to USB drives from your guest VM, even when the device is plugged into a remote PC rather than your local host.

USB Network Gate is an excellent solution for diverse operating system environments. It offers cross-platform compatibility allowing you to forward USB data transmission between Windows, Mac, and Linux systems.

VirtualBox Raw Hard Disk Access

There are multiple methods of accessing the data on a hard drive from within virtual environments. One option is to use the contents of a physical drive to create a virtual hard disk image. At times, it may be more beneficial to mount or boot a physical hard drive directly from a guest VM.

VirtualBox enables you to mount all or part of a hard drive. You can designate specific partitions to be mounted or choose to use the complete disk. We will be discussing the method known as VirtualBox raw hard disk access. This is where the whole VirtualBox physical hard drive is mounted. The advantages of this method include giving users the ability to boot their system from an external USB drive or additional hard disk.

We will demonstrate how to accomplish this on Windows, Mac OS X, and Linux host operating systems.

Note: You should always backup your data before attempting to mount drives or partitions in your virtual machine. Avoid mounting or booting the partition running the host operating system, as it may result in substantial data corruption.

  1. The first step is to use the VirtualBox user interface to create a virtual machine. Use your regular configuration except for the selection of a virtual hard drive. Choose the “Do not add a virtual hard drive” option.

  2. You will need to identify the drive number and path of the physical drive you intend to mount. Use the appropriate method for your host operating system.

Windows: Open Disk Management where the drive numbers will be displayed on the left side. They will be identified as PhysicalDrive0, PhysicalDrive1, etc.

Mac OS X: Enter the “diskutil list” command which returns a list of the available disk partitions. The drive names will be displayed in the format /dev/disk0, /dev/disk1, and so on.

Linux: To list the partitions in Linux, the “sudo fdisk -l” command is used. The format for disks in Linux is dev/sda0, dev/sda1, etc.

  1. Once you have obtained the drive number, you are ready to open the CLI of your operating system. When Windows is the host OS, you need to navigate to VirtualBox’s root directory. Use this command: “cd C:\Program Files\Oracle\VirtualBox”.

  2. At this point, you are ready to create a virtual hard drive file from the contents of the physical device. The generic commands below require you to use the name and number of your drive where appropriate.

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

For Mac OS X: VBoxManage internalcommands createrawvmdk -filename "</path/to/file>.vmdk" -rawdisk /dev/disk#

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

The VMDK that is created is a small file that acts as a pointer to the physical hard drive. To use the disk, you just attach the VMDK to your virtual machine. Perform the following steps after opening to VirtualBox GUI.

  1. Select the desired virtual machine that will access the disk.
  2. Click “Settings > Storage > Add Hard Disk”.
  3. Select the “Choose existing drive” option.
  4. Choose the VMDK file previously created.

Your virtual machine can now boot from the physical drive associated with the VMDK file.

small logo USB Network Gate
#1 at Networking Software
USB Network Gate
Share USB over Ethernet on Windows
4.7 rank based on 72 + users
Get a download link for your desktop
Submit your email address to get a link for quick download on your desktop and get started!
Also Available: USB Network Gate is a cross-platform solution compatible with Mac, Linux and Android OSes:

UNG for Mac

UNG for Linux

UNG for Android