Booting from USB is easy on a Pi1, Pi2, or Pi3. This can be useful in mamy cases to speed up the performance of your pi when using a slow sd card. It can also provide a reliable location where you operating system data resides. Sd cards are prone to data corruption from writes a operating system ussually does.
- Write the latest Raspbian image to an SD card and boot it.
- Write the latest Raspbian image to a USB drive and plug it into the Pi.
- Boot the raspberry pi and ssh into it.
- Get the UUID of your device with
sudo blkid
- If you have duplicate UUID on your devices (most likely) you can run the following command on the usb drive to regenerate the UUID:
sudo apt install gdisk
sudo sgdisk --partition-guid=1:R /dev/sda2
- If you have duplicate UUID on your devices (most likely) you can run the following command on the usb drive to regenerate the UUID:
- Create initramfs
mkinitramfs -o /boot/initrd
- Add initramfs
nano /boot/config.txt
initramfs initrd
- Add
rootdelay=5
(orrootdelay=10
if your drive takes longer to spin up) to/boot/cmdline.txt
- Change
root=
to use the new device id, you can use any of the following methodsroot=UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333
(best way, most reliable)root=PTUUID=XXXXXXXXX
root=PARTUUID=XXXX-XXXXX
root=/dev/sda2
(not recomended)
dwc_otg.lpm_enable=0 console=tty1 root=UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 rootfstype=ext4 elevator=deadline rootwait rootdelay=5
- change to UUID or whichever option you used above to
/etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 / ext4 defaults,noatime 0 1
-
Optinally if you have a higher power device you can increase the output power of usb by adding
max_usb_current=1
to the/boot/config.txt
file. -
Reboot. The Pi should be running from the USB drive.
-
Bonus: You can gain some usable space by mounting the sd card and usb drive on a linux machine and deleting the unused partitions on those devices.
- Delete root partition on sd card
- Expand boot partition on sd card
- Delete boot partition on usb drive
- Expand root partition on sd card