Page 1 of 1

Booting from USB questions.

Posted: Thu May 18, 2017 1:01 pm
by Tdi-Me
So I saw this here: https://www.raspberrypi.org/documentati ... des/msd.md which basically shows how to boot from a usb hard drive. I understand once this is set that it is permanent. I primarily have windows devices though so i am a little nervous. When it comes to making an image i use win32 disk imager, i have also heard for us windows folks ether is good but i have not yet used it.
I am curious though once this bit is set to have the pi boot from usb is it set to boot from 1 specific usb slot, drive or anything like that or basically is this more like just changing it to look at the usb ports for bootable media rather than looking at the microsc card?
I am also curious if there is a way i can test this before making a change that is permanent?

I also have one other assumption i am curious if its correct, in raspbian there is that nice option to clone the sd card and it looks like i can clone it to the usb drive, now if i clone it and then set this option to boot from usb should that make this a pain free transition?

Re: Booting from USB questions.

Posted: Thu May 18, 2017 1:22 pm
by RaTTuS
it will try to boot from the sdcard first but if nothing is there then it will go to to the USB

Re: Booting from USB questions.

Posted: Thu May 18, 2017 3:14 pm
by procount
As Rattus said, setting the bit ENABLES extra functionality, but does not remove any features you had previously, so if you want to go back to booting from an SD card, just put one in and it will take preference.
If you have no SD card fitted, a Pi with the bit set will look at all USB media and boot from the first one it finds that is bootable.

Regarding the SD clone capability in Raspbian, this will clone one device (e.g. SD card) to another device (e.g. USB memory stick), taking account of the different size of the target device by adjusting the size of the last partition to fill up the device. But this does not mean you can just boot off your USB memory stick straight away.

An OS usually consists of 2 partitions - the FAT32 boot partition and the EXT4 rootfs partition. There are files in each of these partitions that link to the other. E.G. cmdline.txt in boot points to the rootfs partition to load the main operating system. /etc/fstab in the rootfs typically points to the boot partition so that it is accessible from a running system.
On a typical Raspbian SD card, boot is /dev/mmcblk0p0 and rootfs is /dev/mmcblk0p1. But USB devices are typically called /dev/sdX, so the first USB memory stick will be called /dev/sda and the partitions will be called /dev/sda1 and /dev/sda2 respectively. So provided you update such files, it should then work.

HOWEVER, if you have 2 USB memory sticks plugged in, it's a bit hit or miss as to which one is /dev/sda and which is /dev/sdb. For this reason, the USB partitions are typically referenced by their PARTUUIDS, which don't change regardless of how Linux names the devices.