A recurring topic of discussion is how to configure and reliably run Raspbian on a USB flash drive, USB hard drive, or USB SSD instead of an SD card.
A Raspberry Pi 3B+ has a native USB boot mode (this mode has to be manually enabled by setting an OTP bit on a Raspberry Pi 3B). This native USB boot mode has serious compatibility issues. A bootcode.bin file is available for older Raspberry Pi models. Unfortunately, both of these approaches have serious limitations and once working, can easily be broken by simply plugging in an additional USB storage device.
The easiest and most reliable way to run Raspbian on a USB device is to leave an SD card containing Raspbian in place, but use it only for starting Raspbian that is residing on a USB device. While setting up such a configuration is not rocket science, it can be confusing to a newcomer or someone unfamiliar with Linux internals. In an effort to simplify the task, I've created the attached script named 'usb-boot' to automate the process.
If usb-boot is running on a Raspberry Pi 3B+ or a Raspberry Pi 3B with its OTP bit set, usb-boot first prompts: 'Use SD card to boot the USB device (recommended)?'
If 'No' is selected, the SD card will not be altered, but booting the USB device may be limited and/or unreliable as described above.
usb-boot then presents a list of available USB mass storage devices and prompts: 'Select the USB mass storage device to boot'
Use the arrow keys on your keyboard to navigate to the desired device and press the spacebar to select it. Then use the tab key to navigate to the 'Ok' or 'Cancel' button and press the return key.
usb-boot will then prompt: 'Replicate BOOT/ROOT contents from /dev/mmcblk0 to /dev/sdX?'
/dev/mmcblk0 is the SD card and /dev/sdX is the USB device.
Select 'No' if the USB device already has Raspbian on it and you wish to use it (nothing will be copied).
Select 'Yes' if you want to copy the Raspbian on your SD card to the USB device (everything will be copied).
If you select 'Yes', you will be warned: 'All existing data on USB device /dev/sdX will be destroyed!' and prompted: 'Do you wish to continue?'
If you select 'Yes', the copy will begin. The time required for this process will depend on the amount of data on your SD card and the speed of your storage devices.
usb-boot will then complete the configuration process and warn you of any potential conflicts it detects.
When usb-boot has finished, you should be able to reboot and be running Raspbian on the USB device (first power off and remove the SD card if not using the SD card to boot the USB device).
=====
sdc-boot provides a convenient way to select which attached device will be booted.
Usage syntax is:
sdc-boot [ /dev/mmcblk0 | /dev/sdX | ptuuid=hhhhhhhh ]
/dev/mmcblk0 is the SD card
/dev/sdX is a USB device
ptuuid=hhhhhhhh is a USB device identified by its PTUUID
If no device is specified, the currently selected boot device will be displayed.