VirtualBox: Boot from USB

Hi,

Virtualbox allows to boot from USB. But this feature isn’t exposed to the GUI.

Lets start. First of all determine the physical disk. Open Powershell and query the disks by WMI

PS D:\> Get-WmiObject -Query "Select * from Win32_DiskDrive"

Partitions : 3
DeviceID   : \\.\PHYSICALDRIVE0
Model      : Samsung SSD 850 PRO 512G
Size       : 512105932800
Caption    : Samsung SSD 850 PRO 512G

Partitions : 1
DeviceID   : \\.\PHYSICALDRIVE2
Model      : Generic USB CF Reader USB Device
Size       : 4030387200
Caption    : Generic USB CF Reader USB Device


The device path to the USB device is \\.\PHYSICALDRIVE2.

Open a command shell cmd.exe as Administrator and navigate to the folder where VirtualBox is installed and expose the physical device as a file.

C:\> cd /d D:\Programs\VirtualBox
D:\Programs\VirtualBox> VBoxManage internalcommands createrawvmdk -filename D:\VMs\usb.vmdk -rawdisk \\.\PHYSICALDRIVE2
RAW host disk access VMDK file D:\VMs\usb.vmdk created successfully.

D:\VMs\usb.vmdk can now be used as a (Virtual) Disk in VirtualBox.
Note: You have to start VirtualBox with Administrator Permissions to access a physical device!
If you want to boot from make sure it is disk 0 in your virtual machine.

D:\Programs\VirtualBox> VBoxManage.exe  showmediuminfo d:\VMs\usb.vmdk
UUID:           fc60ba58-5074-45b9-a33f-62a87bf61262
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       d:\VMs\usb.vmdk
Storage format: VMDK
Format variant: fixed unknown
Capacity:       3847 MBytes
Size on disk:   3847 MBytes
Encryption:     disabled

If you do not use it anymore unmount the USB device. Detach it from the VM

D:\Programs\VirtualBox> VBoxManage showvminfo "Linux USB Test"
....
Storage Controller Name (0):            SATA
....
SATA (0, 0): D:\VMs\usb.vmdk (UUID: 851100e0-6423-46fd-b2f6-57c246d031bd)
SATA (1, 0): Empty
....
D:\Programs\VirtualBox> VBoxManage storageattach "D:\Programs\VirtualBox> " --storagectl SATA --port 0 --device 0  --medium none
D:\Programs\VirtualBox> VBoxManage.exe  closemedium  d:\VMs\usb.vmdk  --delete

Usage in Linux is straight forward 🙂

root@devdeb ~ # VBoxManage internalcommands createrawvmdk -filename /tmp/dev.vmdk -rawdisk /dev/sdc
....use the disk....and delete them...
root@devdeb ~ # VBoxManage closemedium --delete /tmp/dev.vmdk

Michael

Reference: VirtualBox Documentation 9.9. Advanced storage configuration

https://phonefindservice.info

Advertisment to support michlstechblog.info

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.