Hdparm with Seagate disk drive on Raspberry Pi
In certain situations the Linux “UAS” driver disables SAT passthrough transfers, which prevents some tools for direct communication (e.g. hdparm, smartmontools) to work properly with the attached SATA device. This problem often occurs with Seagate hard drives. Here is one example of an error condition – “drive state” is standby, but the disk reports incorrect data:
pi@raspberry:~ $ sudo hdparm -C /dev/sda /dev/sda: SG_IO: bad/missing sense data, sb: 70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 drive state is: standby
The problem is that certain USB to SATA bridge chipsets do not properly pass SAT commands on to the SATA device when running in UAS mode. To work around this problem Linux automatically turns off SAT passthrough functionality for these problematic chipsets. This results in situations that some software tools like hdparm are not able to communicate with the USB drive. For many of these chipsets, SAT passthrough works correctly in the old BOT mode, and may suddenly stop working when the kernel is upgraded to a version which supports UAS.
Among other manufacturers, this affects, in particular, all models (!) of hard drives from Seagate. According to Linux kernel developers, Seagate disks have a long-term compatibility problem, so they decided to deal with it radically in the new driver version. You can find a detailed description of the problem on this page – SAT with UAS under Linux.
Solution on Raspberry Pi
Generally there are two possible solutions:
- Use old BOT driver, or
- You can risk it and use new UAS driver, but with enabled SAT passthrough communication.
My only intention was to control the disk spindown time – old known command “sudo hdparm -S /dev/sda“. So I decided to use the method number two, which I have been using successfully for several weeks.
First, you need to find out the manufacturer ID of your hard drive and the device ID. To do this, use the lsusb command. The information we are looking for is the two strings separated by a colon before “Seagate” – in my case 0bc2:ab28.
pi@raspberry:~ $ lsusb Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 0bc2:ab28 Seagate RSS LLC 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
As the second step open the /boot/cmdline.txt file and paste the following configuration command into the end. Use your own ID:ID. Don’t forget the colon at the end, it’s supposed to be there!
Save the cmdline.txt file and reboot Raspberry Pi. After restart try hdparm -C /dev/sda command again – it should return an answer without error messages around.
pi@raspberry:~ $ sudo hdparm -C /dev/sda /dev/sda: drive state is: active/idle
This manual has been successfully tested on Raspberry Pi 4 model B 64-bit 4GB RAM, with Raspbian GNU/Linux 10 (buster), kernel: Linux 4.19.75-v7l+.