7374756666

Fixing SG_IO: bad/missing sense data on a raspberry pi using Seagate USB hard drives

When using hdparm -I on a group of Seagate USB hard drives attached to a raspberry pi 4 the output included the following error:

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

After some rummaging on the internet I find this is due to the kernel setting some quirks on certain devices.

This is due to broken ATA bridge implementations in the drives. Since these drives are all spinning disks, hooked up to a pi and going to be accessed over a wifi network USB3 is a bit of overkill. To work around the issue I set the usb_storage.quirks kernel parameter with a u flag to disable uas and force the kernel to use USB2 commands with the drives.

To apply this to a raspberry pi you need to edit /boot/cmdline.txt and add the following

usb_storage.quirks=VENDOR_ID:DEVICE_ID:u,VENDOR_ID2:DEVICE_ID2:u

You can confirm it's applied by running cat /sys/module/usb_storage/parameters/quirks

References:

https://askubuntu.com/questions/768373/hard-drive-error-bad-missing-sense-data/1106020#1106020 https://raspberrypi.stackexchange.com/questions/3487/editing-quirks-for-a-usb-driver/79025#79025 https://en.opensuse.org/SDB:USB_3.0_Hard_Drive_troubleshooting https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/usb/storage/unusual_uas.h?h=v5.4.12 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/usb/storage/usb.c?h=v5.4.12#n512 https://patchwork.kernel.org/patch/10058075/