Some operating systems (for example Windows) “don’t like” being installed to a USB device.

Even when installing Linux to a USB device there may be complications in excluding the internal hard disks from being used by the installer, and getting the bootloader installed on the right disk.

A simple method of installing a portable system onto a USB disk is to use virtualisation but with the USB device as a “raw” disk.

Example command

qemu-system-x86_64 -machine accel=kvm \
    -m 4096                           \
    -drive format=raw,file=/dev/sdf   \
    -bios /tmp/ovmf-x86_64.bin        \
    -cdrom Win10_2004_English_x64.iso \
    -boot d

Here /tmp/ovmf-x86_64.bin is the TianoCore firmware
[In openSUSE this is provided by the package qemu-ovmf-x86_64.]
for virtual machines.

The USB disk in this example is /dev/sdf (care needed), and the command needs to be run as root or by a user that is a member of the group disk.

OpenBSD install example

qemu-system-x86_64 -machine accel=kvm         \
    -m 4096                                   \
    -drive format=raw,file=/dev/sdf           \
    -bios /tmp/ovmf-x86_64.bin                \
    -drive format=raw,file=/tmp/install70.img \
    -netdev bridge,br=br0,id=net0             \
    -device virtio-net-pci,netdev=net0