I’ve been a Home Assistant user for years now, and have gone through using RPi 2, RPi 3, VMware, Intel NUC and various Lenovo’s. Except for SD-card wearout it worked ok with the older Raspberries. However, as I needed more cpu power I upgraded to more powerful gear along the way.
My current setup is a Lenovo Yoga460, and works ok. However, with the RPi 4 I believe I can save some power and have some fun along the way, tinkering with new stuff.
First goal was to get the RPI to run from an SSD, giving me far more I/O capabilities than the regular SD cards.
I found two sites giving me all relevant information, and for my own convenience and future reference I made a short version. All information and more are to be found on the following sites
https://www.stewright.me/2019/10/run-raspbian-from-a-usb-or-ssd-on-a-raspberry-pi-4/
https://jamesachambers.com/raspberry-pi-4-usb-boot-config-guide-for-ssd-flash-drives/
Steps to make your RPi shine like a star with a fast SSD and USB 3 adapter
- Flash both SD and SSD with the latest Raspian of your choice
- Boot the RPI with the SD card only and wait until login prompt appears
- Login as «pi» and connect your SSD through one of the USB3-ports (the blue ones)
- Find your adapter with
$ sudo lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. Name: ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Mine is the ASMedia, and you also get the ID listed (174c:55aa)
- Add the «usb-quirks» part to /boot/cmdline.txt with the ID from your adapter, plus «:u» to unblock it
usb-storage.quirks=174c:55aa:u console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
- Reboot the PI and verify that the settings works (if no boot – remove the SD-card and edit the /boot/cmdline.txt on a different computer). It should look something like this if successful
sudo dmesg | grep usb [ 1.332924] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00 [ 1.332957] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1 [ 1.332983] usb 2-1: Product: ASM105x [ 1.333006] usb 2-1: Manufacturer: ASMT [ 1.333028] usb 2-1: SerialNumber: 123456789B79F [ 1.335967] usb 2-1: UAS is blacklisted for this device, using usb-storage instead [ 1.336071] usb 2-1: UAS is blacklisted for this device, using usb-storage instead [ 1.336103] usb-storage 2-1:1.0: USB Mass Storage device detected [ 1.336479] usb-storage 2-1:1.0: Quirks match for vid 174c pid 55aa: c00000 [ 1.336611] scsi host0: usb-storage 2-1:1.0
- The next step is to make the PI run the OS from your SSD. For this to work properly you should change the PARTUUID of the SSD. I follow the instructions from James Chambers and use d34db33f. Run the following command:
$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors Disk model: ASM105x Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x6c586e13 Device Boot Start End Sectors Size Id Type /dev/sda1 8192 532479 524288 256M c W95 FAT32 (LBA) /dev/sda2 532480 500118191 499585712 238.2G 83 Linux Command (m for help): x Expert command (m for help): i Enter the new disk identifier: 0xd34db33f Disk identifier changed from 0x6c586e13 to 0xd34db33f. Expert command (m for help): r Command (m for help): w The partition table has been altered. Syncing disks.
- Verify that the changes are working
$ sudo blkid /dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5203-DB74" TYPE="vfat" PARTUUID="6c586e13-01" /dev/mmcblk0p2: LABEL="rootfs" UUID="2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e" TYPE="ext4" PARTUUID="6c586e13-02" /dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5203-DB74" TYPE="vfat" PARTUUID="d34db33f-01" /dev/sda2: LABEL="rootfs" UUID="2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e" TYPE="ext4" PARTUUID="d34db33f-02"
- Now you have to tell the bootloader which partition the PI should use as «root». Edit /boot/cmdline.txt again and replace the partuuid with the one you just changed. It should look something like this, and
usb-storage.quirks=174c:55aa:u console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
Replace it with this
usb-storage.quirks=174c:55aa:u console=serial0,115200 console=tty1 root=PARTUUID=d34db33f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
- Reboot the PI and verify that you are now using the SSD
$ findmnt -n -o SOURCE / /dev/sda2
- The update /etc/fstab to reflect the changes you’ve made. It should look like this
cat /etc/fstab proc /proc proc defaults 0 0 PARTUUID=6c586e13-01 /boot vfat defaults 0 2 PARTUUID=6c586e13-02 / ext4 defaults,noatime 0 1
Replace the second line reflecting the «root partiton» with the new partuuid
proc /proc proc defaults 0 0 PARTUUID=6c586e13-01 /boot vfat defaults 0 2 PARTUUID=d34db33f-02 / ext4 defaults,noatime 0 1
The final step is to resize the partition on your bright and shiny SSD
- Log in and become root ($ sudo su -). The run the following commands
cp /usr/bin/raspi-config ~
sed -i 's/mmcblk0p/sda/' ~/raspi-config sed -i 's/mmcblk0/sda/' ~/raspi-config
Then run the modified version of raspi-config
~/raspi-config
Once it launches, go to Advanced Options and then Expand Filesystem. This may take a while, depending on your attached USB storage device. Once it’s finished, you’ll see the following message:
After a final reboot you should see the partition fully expanded