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

Docker – Move boot2docker machine to secondary hard drive – Windows 10 Home edition

Docker images can take a lot of spaces over time.
My primary hard drive is a 128GO SSD so I wanted to move my boot2docker virtual machine to my secondary hard drive (D:/).

I followed those instruction.

Here is the summary:

  1. Open virtualbox
  2. Stop the virtual machine default if it’s in function
  3. File > Virtual Media Manager
  4. Make a copy of disk.vmdk to the desired location on your secondary hard drive
    1. Type is VMDK
    2. Choose Dynamically allocated
    3. Choose the new location
  5. Go the Settings of the machine default
  6. Go to Storage tab
  7. Select disk.vmdk and remove it
    1. Note: take note of the SATA port
  8. Add a new existing hard drive and select the copied one
  9. Make sure the SATA port is the same as previously
  10. Launch docker again

Make sure your images are still there by running

docker images

You can safely delete the old hard drive

Note: It is located under C:\Users\%Username%\.docker\machine\machines\disk.vmdk