USB Boot on Raspberry Pi 4

I just jumped on the SSD wagon and it’s been working flawlessly for like 3 days so far. Updated the EEPROM as soon as I got the rpi4 4gb, and then just flashed the 5.0 beta on the SSD och it worked right away.

The hw is a startech USB 3.1 adapter and a Kingston 120gb SSD. Restored a snapshot from my previous rpi3 setup without any hiccups. Things are fast and fluid, let’s see how it progresses over a longer time. The zigbee setup seems much happier on the new setup.

Edit: in case someone else got curious, the case and ssd holder are 3d printed, and can be found here and here

@MarkB1 I don’t know if it is related, but I have seen in the raspberry forums that some SSD have problems with the way the raspberry handles them.

There is a workaround in the forums:
https://www.raspberrypi.org/forums/viewtopic.php?t=245931

I don’t have time now to see if it fixes the problem for me, but maybe you can try. According to the thread, it has various symptoms, one of them is the error message uas_eh_abort_handler in the logs of the dmesg command.

EDIT: Doing a search, it seems my device is one of the affected:
https://github.com/raspberrypi/linux/issues/3070
So I think I need to disable UAS to make it working…

1 Like

If someone is interested, after more than 24h, my system is totally stable. So seems the problem was fixed with the quirk to the SSD as workaround.
The CPU and memory are slightly higher, I suppose that the culprit is the 64 bit version in opposite of the 32 bit one, but no problem at all.

Hi, Is this what you did?
I followed this guide to get my quirks using command sudo lsusb

This is the output for my adaptor

Bus 002 Device 007: 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

So I added the quirks to cmdline.txt on the hassos-boot SSD?
usb-storage.quirks=174c:55aa:u

is this the correct way to go about it?

See also this topic: https://community.home-assistant.io/t/hass-io-transfer-from-sd-card-to-ssd-or-usb/97452/367?u=jodur

I also got it only stable with usb-storage quirks enabled.

Yes, that is the correct way to do it.

in config.txt or cmdline.txt, I am thinking config?

More information about this:

  • As I commented in the past, I have more CPU usage in the new ssd boot version.
  • Today, it seems I have fixed it (at least partially).
    image

The only difference was to add the:
dtparam=sd_poll_once=on
to the config.txt. In theory is only optional to not show ugly messages in the log, but it seems to affect the cpu too.
Of course, I rebooted the rpi to make the change, so maybe the problem was simply at other place and the reboot fixed it, but I have restarted it other two times before this change and the problem was there.

After Applying the quirks my own instance has started misbehaving again.

Updating amcrest camera took longer than the scheduled update interval 0:00:15
11:40:09 – Camera (WARNING) - message first occurred at 11:21:20 and shows up 31 times
Updating rpi_power sensor took longer than the scheduled update interval 0:00:30
11:40:09 – Sensor (WARNING) - message first occurred at 11:21:32 and shows up 31 times
Update of calendar.contacts is taking over 10 seconds
11:40:08 – runner.py (WARNING) - message first occurred at 11:21:00 and shows up 147 times
Updating amcrest binary_sensor took longer than the scheduled update interval 0:00:05
11:40:06 – Binary Sensor (WARNING) - message first occurred at 11:20:55 and shows up 128 times
Updating samsungtv_encrypted media_player took longer than the scheduled update interval 0:00:10
11:39:55 – Media Player (WARNING) - message first occurred at 11:21:00 and shows up 55 times
Updating darksky weather took longer than the scheduled update interval 0:00:30
11:39:47 – Weather (WARNING) - message first occurred at 11:21:44 and shows up 8 times
Updating google calendar took longer than the scheduled update interval 0:01:00
11:39:13 – Calendar (WARNING) - message first occurred at 11:26:11 and shows up 4 times
Timeout error fetching version information from Hassio,
11:39:11 – runner.py (ERROR) - message first occurred at 11:34:11 and shows up 2 times
Config entry for wled not ready yet. Retrying in 80 seconds
11:39:08 – config_entries.py (WARNING) - message first occurred at 11:21:13 and shows up 13 times

What could be causing this, I cannot see anything in the Logs?

HA can run fine for say 12 hrs then excessive CPU, heat, error logs fill up and everything lags.
See CPU use below

Usually deleting the db clears this behaviour but that is far from ideal having to do that everytime?

First, verify that the quirk is working.
In the supervisor, system tab, select the Host log. I see this in mine:

[    1.092126] usb-storage 2-1:1.0: USB Mass Storage device detected
[    1.092598] usb-storage 2-1:1.0: Quirks match for vid 152d pid 0578: 1800000

If all is ok, try to add the dtparam=sd_poll_once=on to the config.txt file. In theory it is not necessary, and my system was stable, but it helped a lot with my cpu.

I think I don’t have more ideas…

did you put the quirks in cmdline.txt

usb-storage.quirks=174c:55aa:u dwc_otg.lpm_enable=0 console=tty1

or or config.txt?

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# HassOS - don't change it!
disable_splash=1
kernel=u-boot.bin

dtparam=sd_poll_once=on

usb-storage.quirks=174c:55aa:u

# uncomment for aarch64 bit support
arm_64bit=1

This is all i am seeing in system log / Host

[    1.163626] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[    1.184596] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
[    1.187048] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    1.189673] usb 2-1: Product: Best USB Device
[    1.192267] usb 2-1: Manufacturer: ULT-Best
[    1.194833] usb 2-1: SerialNumber: 042003192AC2
[    1.217297] scsi host0: uas
[    1.220072] scsi 0:0:0:0: Direct-Access     CT120BX5 00SSD1           0    PQ: 0 ANSI: 6

when I search for “quirks” all I get is
[ 0.551644] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000001000000890

OK, put the quirks in cmdline.txt and this is my host log now.

1.151849] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[    1.172636] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
[    1.175034] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    1.177652] usb 2-1: Product: Best USB Device
[    1.180294] usb 2-1: Manufacturer: ULT-Best
[    1.182886] usb 2-1: SerialNumber: 042003192AC2
[    1.188950] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[    1.190848] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[    1.192006] usb-storage 2-1:1.0: USB Mass Storage device detected
[    1.193421] usb-storage 2-1:1.0: Quirks match for vid 174c pid 55aa: c00000
[    1.194679] scsi host0: usb-storage 2-1:1.0
[    2.207964] scsi 0:0:0:0: Direct-Access     CT120BX5 00SSD1           0    PQ: 0 ANSI: 6

I presume from the above my quirks have been correctly implemented?

Question I would like to ask now is how to test the speed of the SSD? I have terminal installed.

Yes, this looks far better. The quirk goes into the cmdline.txt and the dtparam in the config.txt.

I’m not an expert in Linux, to check the speed, I’ve used a command from the other thread: hdparm -t [device]

> hdparm -t /dev/sda 

/dev/sda:
Timing buffered disk reads:  752 MB in 3.00 seconds = 256645 kB/s

This is using the ssh&web addon disabling the protection mode. Under standard ssh I suppose you could do the same with sudo in the command.

I think the raw speed will be similar, reading in the net seems that with UAS we can get a little more performance when using several parallel data flows.

Thanks, my results as follows.

Our command line:
$ ha help
➜  ~ hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  805 MB in 3.00 seconds = 274352 kB/s

@McGiverGim, after reading your post, i never checked the logs if the quirk is really applied and after studying the OS log, i saw that the usb.quirks was not applied, so it seems i am now running with UAS enabled stable for already more then 1 week :grinning:

I made the mistake not reading well and applied the quirk in the config.txt instead of cmdline.txt so that explains why usbquirk was not applied in my case.

I report now the following speed (with UAS), :

# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  899 MB in 3.00 seconds = 306662 kB/s
# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  815 MB in 3.00 seconds = 277945 kB/s
# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  976 MB in 3.00 seconds = 333051 kB/s

I am using a Geekworm X825 with a Curcial BX500 240 GB SSD

Would be nice if everybody reports the speed they get with :

hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  802 MB in 3.00 seconds = 273685 kB/s
➜  ~ hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  803 MB in 3.00 seconds = 273752 kB/s

ELUTENG USB 3.0 to SATA Cable for 2.5" HDD or SSD Adapter 5Gbps High Speed Plug and Play Support UASP SATA I II III Hard Disk Drive USB S-ATA Converter

Crucial BX500 120 GB CT120BX500SSD1(Z)-Up to 540 MB/s (Internal SSD, 3D NAND, SATA, 2.5 Inch)

I am using quirks usb-storage.quirks=174c:55aa:u

If you are interested, it seems there is an addon to monitor SMART data of the SSD, that executes a test:

[Thu Aug  6 09:16:39 CEST 2020][Info] Run performance test
     Category                  Test                      Result              
HDParm                    Disk Read                  MB/s                    
HDParm                    Cached Disk Read           MB/s                    
DD                        Disk Write                171 MB/s                 
FIO                       4k random read            4599 IOPS (18396 KB/s)   
FIO                       4k random write            IOPS ( KB/s)            
IOZone                    4k read                   21472 KB/s               
IOZone                    4k write                  16395 KB/s               
IOZone                    4k random read            15465 KB/s               
IOZone                    4k random write           22464 KB/s               
                          Score:                                             
Compare with previous benchmark results at:
https://storage.jamesachambers.com/ 
[Thu Aug  6 09:18:22 CEST 2020][Info] Performance test end

You can get it from here:

EDIT: When I start the addon Home Assistant restarts at the end of the test. It seems only once, but I don’t know why.

1 Like
RandRead: 15004 - RandWrite: 21512 - Read: 22311 - Write: 16936

     Category                  Test                      Result              
HDParm                    Disk Read                 160.46 MB/s              
HDParm                    Cached Disk Read          246.51 MB/s              
DD                        Disk Write                117 MB/s                 
FIO                       4k random read            4139 IOPS (16556 KB/s)   
FIO                       4k random write           4813 IOPS (19252 KB/s)   
IOZone                    4k read                   22311 KB/s               
IOZone                    4k write                  16936 KB/s               
IOZone                    4k random read            15004 KB/s               
IOZone                    4k random write           21512 KB/s               

                          Score: 4988             

My own results

Hi all
may I ask a dummy question
how download the dev image for rasp pi usb boot?
tks

Maybe to much, but for those who want Debian 10(buster) 64Bit running on SSD/USB on RPi4

https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip

Flash image on a SDCard. Add SDcard and your SSD to your RPi4
You can also add already ssh option and you wifi settings on the /boot/ partition of SDcard

Remove the old dphys version

sudo /etc/init.d/dphys-swapfile stop
sudo apt-get remove --purge dphys-swapfile

Refresh your OS

sudo apt-get update
sudo apt-get full-upgrade

Prepare RPi4 for USB Boot

Refresh your OS with the latest firmware

sudo nano /etc/default/rpi-eeprom-update
sudo rpi-eeprom-update -d -a
reboot

Install RPICLONE (For cloning from SDCard to my SSD, my SSD is /dev/sda, yours can be different)

git clone https://github.com/billw2/rpi-clone.git 
cd rpi-clone
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
sudo rpi-clone sda

After RPICLONE is done open a new terminal window

nano /mnt/clone/boot/cmdconfig.txt

Add rootdelay=5 cgroup_memory=1 cgroup_enable=memory to the line and save the file.
Exit the terminal

shutdown now

Remove the SDCard and boot from SSD now.
Correct location and timezone

raspi-config

Install Docker

sudo -i
apt-get install software-properties-common -y
apt-get update
apt-get install modemmanager
reboot now

Reason I install modem manager first and reboot, because when do with network-manager my RPi freeze

apt-get install network-manager
apt-get install apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq socat bash curl 
curl -fsSL get.docker.com | sh

Install Hass.io

systemctl stop ModemManager
systemctl disable ModemManager
curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s -- -m raspberrypi4

DONE

Here some links I get the information from:


https://www.uberbuilder.com/using-rpi-clone/