Skip to content

USB Storage

Zoltán Loderer edited this page Sep 16, 2021 · 9 revisions

Using a USB drive with Mini404 currently requires a raw image of the drive to be taken. You can use dd or any other tool as you wish, or create an empty FAT32 image with MK404 and copy files to it using mcopy. If cloning a drive to an image, be sure to image only the partition (e.g. /dev/sdcX and not the full drive /dev/sdc)

To attach the drive to the system, pass the following command line arguments to qemu-system-buddy:

  • -drive id=usbstick,format=raw,file=[filename.img] to tell QEMU you wish to use a file as a virtual disk
  • -device usb-storage,drive=usbstick to instruct it to attach the named drive (usbstick) as a USB Mass Storage Controller.

Read-only images can be mounted by explicitly requesting readonly=on in the -drive option:

  • -drive id=usbstick,format=raw,readonly=on,file=[filename.img]

⚠️ QEMU does support passing through host USB devices, but this has NOT been tested/verfied with the Mini404 USB controller at this time - do not attempt it with a drive containing data you care about! ⚠️

⚠️ There is a known bug that QEMU will hang if you attempt to hot-plug a USB device. (#59).

  • Workaround: Do not hotplug usb drives with device_add in the QEMU console. Connect them at startup with -device usb-storage options.

❌ Do not attach devices other than USB storage, including virtual hubs. The Mini firmware does not like that, and we've had to prevent QEMU automatically adding a hub as part of the mainline chainges for this project!

If you get this error: qemu-system-buddy: -device usb-storage,drive=usbstick: 'usb-storage' is not a valid device model name it just means you need to rerun the configure build tool with the --enable-libusb argument.

Alternative - Mounting a directory as a drive.

QEMU has a vvfat driver which can mount a directory of files acting act as the contents of the USB stick. This is read-only by default and can be done with the following argument set:

-drive id=usbstick,readonly=on,file=fat:some/directory

The vvfat device can optionally be made read-write with the following:

-drive id=usbstick,file=fat:rw:some/directory

Note that read-write support is experimental and care should be taken not to modify the directory on the host machine while the guest is running.

Do not forget after the drive definition to put there also

  • -device usb-storage,drive=usbstick to instruct it to attach the named drive (usbstick) as a USB Mass Storage Controller.