Connect a physical hard drive to a VirtualBox VM

Following this tutorial:


First, I formatted an external hard drive.

I want to mount the 2nd partition of the external hard drive into a VM.

  1. Create the VM in VirtualBox but don’t attach any hard drive yet.
  2. Open an Admin command prompt
  3. `cd C:\Program Files\Oracle\VirtualBox`
  4. `VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive2` Where the number ‘2’ comes from the Disk Manager utility and identify the hard drive I want to mount. This command gives me the partition number I need to mount
  5. `VBoxManage internalcommands createrawvmdk -filename “D:\VMs\Xubuntu-physical-hard-drive\Xubuntu-physical-hard-drive.vmdk” -rawdisk \\.\PhysicalDrive2 -partitions 2`
  6. In VirtualBox, edit the VM and add an existing hard drive

Note: I also needed to check the option “Use I/O cache from host” when adding the hard drive to the VM

Linux – Mount a shared folder with virtualbox

To mount a shared folder (previously configured in the VM’s parameters), launch the following command:

sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) NameOfSharedFolderInVMConfig PathToMount

as sudo user

For example, I have configured this shared folder : Capture

So in my VM, I launch this command to mount the shared folder under the “Labs” folder of the home folder


sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) Labs ~/Labs/