Boot directly from USB with Raspberry 3

You can boot directly from USB in latest firmware on Raspbian
https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/msd.md

you only need the SD card to push down firmware once.

could this be implemented in future versions of OSMC ?

I am not keen on updating the bootrom of people’s devices without their consent or knowledge. There would also be a bit of work to get the installer to use the USB to hold /boot.

The problem is the USB boot option in the OSMC Installer would become confusing, so for now I think it is best to keep it as a manual installation option.

When the USB boot option is selected in the OSMC installer I suggest the following workflow:

  1. Install OSMC completely and directly on the USB-stick (including bootloader, /boot, …).
  2. Make sure the “boot”-flag is enabled on the USB-stick partition.
  3. Add the option “# program_usb_boot_mode=1” (commented out) to config.txt
  4. Install BerryBoot boot-loader on the SD-card to forward the boot-loader-process to the USB-stick.
  5. Show a message that the user can enable USB-booting on the RPi3 with the following procedure:
    5.1 Uncomment “# program_usb_boot_mode=1”
    5.2 Reboot RPi once.
    5.2 Comment out “program_usb_boot_mode=1”

This allows to boot OSMC on RPi1, RPi2 and RPi3 without OTP-flag using the SD-card and on RPi3 with OTP-flag without the SD-card. For convenience step 5 can be added to MyOSMC.

The fat32 portion is still expected to reside on an SD card for now. If you want to PR some changes to improve this, I’m happy to accept them.

BerryBoot is not compatible with OSMC at this time and causes changes that we cannot officially support. It uses a shared firmware and kernel which means that OSMC may not work as expected.

I did some testing. My RPi3 boots neither current Raspbian nor OSMC in USB-only mode. :frowning:

While testing I made an interesting discovery. Raspbian only needs bootcode.bin on the SD-card to boot. Everything else can be on the USB-stick. This works on a RPi 1B, too. I can’t reproduce it with OSMC. There seem to be too much changes in OSMC. But it would be great if one only needs bootcode.bin on the SD-card and everything else can be done on the USB-stick. :wink:

Indeed.

If you can PR the necessary changes to the target installer, I’d be happy to accept
them. Otherwise, this is quite low on the list, particularly as the performance differences between USB media and SD cards are minimal and corruption on SD cards is no longer an issue.

Cheers

Sam

Hi @sam_nazarko, thanks for all your great work!

the performance differences between USB media and SD cards are minimal

When using an SSD HD there might be significant performance gain.

USB Mass Storage Boot is now supported using the Raspberry Pi Imager to update the bootloader.
That same Raspberry Pi Imager supports installing OSMC.

So it would be nice if OSMC supported USB-first boot.

Also referring to Rpi3: could not mount bootfs due to misassumption when installing from usb · Issue #448 · osmc/osmc · GitHub.

I’ve outlined the changes need to support this on the GitHub issue.

It’s not media but interface: i/o speed differences between USB interface and SDcard interface are notable.
And I’ve come back to this thread because of a 128G sdcard has dead on my Raspberry Pi 4 and I’ve lost everything in it.

I’m happy to accept a PR to support this – but this is still low priority as almost all Pi users simply use an SD card.

Happy to guide where necessary.

With guiding I don’t know if you mean there is a (not too complicated) procedure to rely on USB media.
I’ve just flashed OSMC on USB media and Raspberry Pi 4 boots until OSMC splash screen shows this message:
“install failed: could not mount bootfs”

That’s expected.

I mean that I’m happy to help anyone with the development and integration of this feature (software).

Hi Sam,

thanks for your continuing great work on OSMC.
I’ve read in the Wiki that there IS way to have OMC on an USB-Stick. But it’s a bit confusing.
It says you have to have a SD-Card also. Ok. Understood. BUT how do i get it to work.
The official installer ask’s from where to boot. I select USB.
It then try to install it on the desired stick (installation fails because:
snipped from the tsmc-installer.log
"Di. Mai 3 21:58:31 2022 pasting admin script to process do shell script “dd if=/Users/martin/OSMC_TGT_rbp2_20220314.img of=/dev/rdisk5 bs=1m conv=sync && sync” with administrator privileges
Di. Mai 3 21:58:31 2022 waiting for finish
Di. Mai 3 21:58:37 2022 osa claims to be done…collect output and verify
Di. Mai 3 21:58:37 2022 Imaging failed!
Di. Mai 3 21:58:37 2022 Messages are:
Di. Mai 3 21:58:37 2022 stdout:
Di. Mai 3 21:58:37 2022 stderr: 0:133: execution error: dd: /dev/rdisk5: Operation not permitted (1)
"

No Problem. simply copied the “dd” command to my terminal and added an “sudo”.
Now i’ve got a stick with the installation.
Inserted to my PI got an Error: “could not mount boots”.
Inserted an additional empty SD Card it fails with “no filesystem”.

Please advise.

Thanks in advance.
Martin.

This is where it is going wrong. The installer has to go onto the SDCard. You then boot the Pi with the SDCard and the empty USB stick connected. The installer will then prepare the boot files on the SDCard and the OS on the USB stick

:see_no_evil: man…
Thank you so much.
I feel like a little noob…

I‘ve got one last question: is there a problem with me manually doing the dd command? I mean it seems like the last step of the osmc-installer but I got the feeling that there might be some configuration missing to tell the setup-routine where to put the OS.

You can dd the image but there is preseeding metadata to inform the installer that you wish the root filesystem to reside on USB.

Nice. I tried this meanwhile. Installation seems to be successful BUT i result in a black screen…
I am able to SSH into the box and it looks like the installer has used the SD Card for installation (which is definitely to small for the whole thing (1 GB).

osmc@osmc:~$ df -h
Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
devtmpfs        204M       0  204M    0% /dev
tmpfs           461M     18M  444M    4% /run
/dev/mmcblk0p2  636M    594M     0  100% /
tmpfs           461M       0  461M    0% /dev/shm
tmpfs           5,0M       0  5,0M    0% /run/lock
tmpfs           461M       0  461M    0% /sys/fs/cgroup
/dev/mmcblk0p1  316M     34M  283M   11% /boot
tmpfs            93M       0   93M    0% /run/user/1000
/dev/sda1        59G    2,4M   59G    1% /boot/disk

I mounted the USB drive and it IS still empty.

osmc@osmc:~$ ll /boot/disk/

insgesamt 100K

drwxr-xr-x 4 root root 32K Jan 1 1970 **.**
drwxr-xr-x 7 root root 4,0K Jan 1 1970 **..**
drwxr-xr-x 2 root root 32K Mai 4 18:08 **.fseventsd**
drwxr-xr-x 3 root root 32K Mai 4 18:08 **.Spotlight-V100**

Could you please tell me how i can manually convince the installer to use the USB drive for the installation?

Sorry for all at the inconvenience.

Regards.
Martin

I suggest you use the installer (run it with sudo) and write the installer image to the SD Card (while choosing for OSMC as the target “USB Drive”. With that the Installer Image + the correct preseeding file will be written to the SD Card. If you then boot the Pi with the SDCard and the USB stick it should all be correct.