How to make the VirtualBox guest OS to boot from a physical drive attached to the host system?

Although, this idea sounds scary and it is claimed to be ill advised by many, it is in fact something that I need to do quite often as I install and configure systems that need to be moved around quite a lot. Having done it safely for a number of years I thought it would be good to share my experience. Whether your host OS is Windows or Linux you will achieve the same result following the appropriate methodology below.

If the OS hosting your VirtualBox virtualizer is of Microsoft Windows type then follow these steps:

1) Open the Start Menu and search for “Disk Management”, or run “Computer Management” as administrator and navigate to “Disk Management” under “Storage”.
2) Launch it, and find the disk number of your physical drive (IDE, ATA, SCSI or USB) in the bottom pane. If it says “Disk 9”, for example, the number you’re looking for is 9.
3) Open the Start Menu again and search for “Command Prompt”. Right-click on the “Command Prompt” icon/menu selection that appears and choose “Run as administrator”.
4) Navigate to the VirtualBox installation directory by running:
> c:
> cd %programfiles%\Oracle\VirtualBox
(or cd C:\Program Files\SunVirtualBox)
5) Enter this command to create a .vmdk file in your C drive, which will point to the USB drive:
> VBoxManage internalcommands createrawvmdk -filename C:\t\MyExternalDisk.vmdk -rawdisk \\.\PhysicalDrive#
where # should be replaced with the disk number you found in step 1, for instance 9. Ensure that c:\t exists. Your command line will look like this: VBoxManage internalcommands createrawvmdk -filename C:\t\MyExternalDisk.vmdk -rawdisk \\.\PhysicalDrive9
6) Go back to the start menu and search for VirtualBox.
Right-click the VirtualBox icon and select “Run as administrator” to run the program with administrative rights.
Create a new virtual machine, and as you identify its resources, when you see the window labeled “Hard Drive”, select “Use an existing hard drive file”, and select the .vmdk file you just created from the dropdown as your new virtual hard drive.
7) Select the new virtual machine that you have just created and run it. VirtualBox will boot to the operating system on the USB drive.
Hold onto that .vmdk file in “c:\t” so you don’t have to repeat the steps to create it every time. Its name can be anything, it doesn’t have to be “MyExternalDisk.vmdk”.

If your host OS is LINUX then follow this recipe:
1) Plug your USB drive into your Linux based VirtualBox host computer (where you have VirtualBox installed).
2) Open a terminal and use the “fdisk -l” command to find the designation associated with your USB disk. For instance “/dev/sdc”
3) Enter this command to create a .vmdk pointer file somewhere on your hard drive, which will point to the actual USB drive:
$ VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda
4) Now start VirtualBox. Create a new virtual machine, and as you identify its resources, when you see the window labeled “Hard Drive/Storage” select “Use an existing hard drive file”, and pick the .vmdk file you just created from the dropdown as your new virtual hard drive.
5) Select the new virtual machine that you have just created and run it.
VirtualBox will boot to the operating system on the USB disk.
Hold onto that .vmdk pointer file on your hard disk so that you don’t have to repeat the steps to create it every time. Its name can be anything, it doesn’t have to be “MyExternalDisk.vmdk”.

(© cilicia.us – originally published on January 4, 2016)

cilicia.us & The Cilician Gazette © Copyright 1991-2018 - All rights reserved