Using physical disk in Oracle VirtualBox

Here is how you can use your local physical disk in Oracle VirtualBox virtual machine:

  • Windows: Open Disk Management. You’ll see the associated drive numbers on the left and will identify them later as Disk 0, Disk 1, etc.
  • GNU\Linux: Use the command: sudo fdisk -l. You’ll see a list of partitions. Make note of the desired drive in the format of dev/sda0, dev/sda1, etc.
  • Mac OSx: Use the command: diskutil list. You’ll see a list of 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 Open cmd in elevated mode. You will also need to go to the root of the VirtualBox directory.

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 replace the # with your desired drive number.

  • Windows: VBoxManage internalcommands createrawvmdk -filename “C:\folder\phy_disk.vmdk” -rawdisk \\.\PhysicalDrive#
  • GNU\Linux: VBoxManage internalcommands createrawvmdk -filename “phy_disk.vmdk” -rawdisk /dev/sda#
  • Mac OSx: VBoxManage internalcommands createrawvmdk -filename “phy_disk.vmdk” -rawdisk /dev/disk#

You will be presented with the success message: (In my case) “RAW host disk access VMDK file c:\folder\USB.vmdk created successfully.”

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 (run in elevated mode), select the desired VM, click Settings, click Storage, click Add Hard Disk button, select Choose existing drive, and then select the VMDK file you just created.

You may need to take the disk offline in order to boot the VM from the physical drive you defined when creating the VMDK file. Note that if the USB devie is recognized as a removable media, you fill not be able to take it offline.

Enter your comment:
21 +8 = 
  • software/virtualbox/phy_disk.txt
  • Last modified: 2019-10-31 09:05
  • (external edit)