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
1 2 3 4 5 6 7 8 9 10 11 12 13 | PS D:\> Get-WmiObject -Query "Select * from Win32_DiskDrive"Partitions : 3DeviceID : \\.\PHYSICALDRIVE0Model : Samsung SSD 850 PRO 512GSize : 512105932800Caption : Samsung SSD 850 PRO 512GPartitions : 1DeviceID : \\.\PHYSICALDRIVE2Model : Generic USB CF Reader USB DeviceSize : 4030387200Caption : 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.
1 2 3 | C:\> cd /d D:\Programs\VirtualBoxD:\Programs\VirtualBox> VBoxManage internalcommands createrawvmdk -filename D:\VMs\usb.vmdk -rawdisk \\.\PHYSICALDRIVE2RAW 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.
1 2 3 4 5 6 7 8 9 10 11 | D:\Programs\VirtualBox> VBoxManage.exe showmediuminfo d:\VMs\usb.vmdkUUID: fc60ba58-5074-45b9-a33f-62a87bf61262Parent UUID: baseState: createdType: normal (base)Location: d:\VMs\usb.vmdkStorage format: VMDKFormat variant: fixed unknownCapacity: 3847 MBytesSize on disk: 3847 MBytesEncryption: disabled |
If you do not use it anymore unmount the USB device. Detach it from the VM
1 2 3 4 5 6 7 8 9 | 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 noneD:\Programs\VirtualBox> VBoxManage.exe closemedium d:\VMs\usb.vmdk --delete |
Usage in Linux is straight forward 🙂
1 2 3 | 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