This is more a note to myself than a full blow tutorial on how to pass-through a physical hard disk drive (or SSD) to a VirtualBox (VB) guest operating system (OS) or even boot an existing disk with an OS as a virtual machine.
For my example, I used a Windows 10 host machine and an existing install of Pop!_OS on an external SSD.
Pre-requisites
- Windows 10 host machine running the latest version of VirtualBox (e.g. >6.1)
- A spare SSD or HDD to test with and you are OK to lose data from if you mess up
- A good cup of tea and around 15min of your time
Step 1 – Find the disk and create a reference for VB
Open your PowerShell prompt using Administrator rights (important)
Tip: locate PowerShell in your Start menu and right click it to see the run as admin option
Enter the following commands to view your disks
diskpart

Then tell diskpart to show us all the disks
LIST DISK

Check the number of the disk (in my case I was looking at Disk 11, yours will be different!)

Next, we need to take the disk offline (in my example I already did). But first: tell diskpart which disk we want to operate on by selecting it:
SELECT DISK (your number!)

Now we can take it offline:
OFFLINE DISK
And finally clear some attributes that otherwise will result in ‘verr_access_denied’ when we try using it:
ATTRIBUTES DISK CLEAR READONLY

Get out of diskpart
EXIT
Let’s wrap up step 1 by creating a reference file for VirtualBox that points to our disk
cd 'C:\Program Files\Oracle\VirtualBox\'
.\VBoxManage.exe internalcommands createrawvmdk -filename c:\Users\axel\.Virtualbox\passthroughtest.vmdk -rawdisk \.\PhysicalDrive11
Note that you must replace the text highlighted in bold with your own details! You can place the vmdk file pretty much anywhere as it’s just a 1kb text file with a bunch of code telling VirtualBox to look for our raw disk to access 🙂

Step 2 – Setting up our VM in VirtualBox
Open VirtualBox and navigate to the virtual media manager

Tip: Just press CTRL+D to open it
When in the manager, click on Medium and Add… (or press CTRL+SHIFT+A)

Give it a name and storage location that matches your project.

Click next until you hit the Hard Disk part. You need to select the file we added to the virtual media manager earlier if you want to use it as your only boot device.

In Settings -> System -> Tick the Enable EFI checkbox!

Step 3 – Boot your virtual machine and bask in the glory of raw disk access in VirtualBox 😀

Bonus round
Make sure to install VirtualBox guest additions!
Note that the disk speeds are good. At least in my limited example benchmarking the SSD (connected via USB3/SATA adapter no less). It’s a Crucial CT250 in case you are wondering.

Over to you
- How did you get on with following this quick and dirty set of instructions?
- What project are you using VirtualBox raw disks (aka SSD/HDD pass-through) in?
- Give me a shout in the comments below and thanks for reading.