4

To update the BIOS on my linux server, I need to run a windows program. My idea was to quickly install windows to a USB drive so that I could just boot into a live windows environment. The installation is going painfully slow because USB drives are very slow to write.

My idea was to create a loopback device the same size as the USB drive and install Windows to that instead, then just dd that image onto the USB. It'd probably be faster.

However, the program that I'm using to install Windows to a USB drive (called WinToUSB) will only install to (you guessed it) a USB Mass storage device. The loopback device that I created and passed into the Windows 7 guest OS that I'm running WinToUSB in presents it as a standard fixed disk. So WinToUSB refuses to try to install to this fixed disk.

So I'm trying to get virtualbox to present the loopback device (as a vmdk) to the guest OS as an emulated USB Mass Storage device so that WinToUSB will install windows to it so that I can dd it to a real USB device and use that to flash my BIOS. What a freakin' Rube Goldberg machine!

Host OS: Arch

Guest OS: Windows 7

Virtualbox: 5.2.6

1 Answer 1

4

To attach a virtual disk as a USB device:

VMNAME="test"
USB_SIZE_MB=$((16*1024))
vboxmanage storagectl "$VMNAME" --add usb --name usb --controller USB
vboxmanage createmedium disk --filename /tmp/test.vmdk --size "$USE_SIZE_MB"
vboxmanage storageattach "$VMNAME" --storagectl usb --medium /tmp/test.vmdk --port 0 --type hdd

Note that once this is done, the disk will be blank so you need to do whatever the guest OS requires you to do to put a partition table on it and use it.

4
  • Does this pass a device of type "removable" ? because that is the main requirement here. When adding a USB disk image via GUI, it is marked as "fixed" and there is no option to change it. There is also a ticket open and discussions about this on the vrtualbox forum. In short: no Commented Aug 4, 2023 at 7:50
  • Yes, @DavidBalažic, it does. When I answered my own question, I did so to record the working answer. Granted, it was 5 years ago so maybe VirtualBox broke it in the mean time, but 5 years ago it worked.
    – Huckle
    Commented Aug 7, 2023 at 22:15
  • The MS Windows ISO download tool (MediaCreationTool22H2.exe) recognizes such disks as USB. But a certain car firmware update tool does not. Also, in Disk Management, real USB keys are marked "Removable" while USB disks created as in your answer are marked "Basic". Tested with VB 7.0.10 on Windows 10 host. Commented Aug 13, 2023 at 14:57
  • My host OS is Linux. YMMV
    – Huckle
    Commented Aug 22, 2023 at 2:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .