NotRequired
Posts: 196
Joined: Sat Apr 29, 2017 10:36 am
Location: Denmark

USB drive disconnects and reconnects

Wed May 10, 2017 5:37 pm

The drive is a non-faulty 1TiB HGST 2.5" laptop drive and it is powered directly from a power supply so this is not a power issue. It almost seems like the entire USB-to-SATA bridge is dropped and picked up immediately thereafter. Here is the dmesg starting from where it goes wrong and until the problem is "corrected":

Code: Select all

[22169.795056] usb 1-1.5: USB disconnect, device number 4
[22169.844445] sd 0:0:0:0: [sda] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x01 driverbyte=0x00
[22169.844464] sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 30 5b 47 f8 00 00 08 00
[22169.844475] blk_update_request: I/O error, dev sda, sector 811288568
[22169.844614] sd 0:0:0:0: [sda] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x01 driverbyte=0x00
[22169.844626] sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 00 00 00 c8 00 00 08 00
[22169.844634] blk_update_request: I/O error, dev sda, sector 200
[22169.844642] Buffer I/O error on dev sda, logical block 25, lost async page write
[22169.845164] EXT4-fs warning (device sda): ext4_end_bio:314: I/O error -5 writing to inode 28838593 (offset 923533312 size 258048 starting block 101411071)
[22169.845174] Buffer I/O error on device sda, logical block 101411007
[22169.845184] Buffer I/O error on device sda, logical block 101411008
[22169.845193] Buffer I/O error on device sda, logical block 101411009
[22169.845201] Buffer I/O error on device sda, logical block 101411010
[22169.845209] Buffer I/O error on device sda, logical block 101411011
[22169.845217] Buffer I/O error on device sda, logical block 101411012
[22169.845225] Buffer I/O error on device sda, logical block 101411013
[22169.845233] Buffer I/O error on device sda, logical block 101411014
[22169.845241] Buffer I/O error on device sda, logical block 101411015
[22169.845249] Buffer I/O error on device sda, logical block 101411016
[22169.845593] JBD2: Detected IO errors while flushing file data on sda-8
[22169.845624] Aborting journal on device sda-8.
[22169.845647] JBD2: Error -5 detected when updating journal superblock for sda-8.
[22169.845679] EXT4-fs (sda): ext4_writepages: jbd2_start: 3008 pages, ino 28838593; err -30
[22169.855622] EXT4-fs error (device sda): ext4_wait_block_bitmap:503: comm XXX: Cannot read block bitmap - block_group = 3112, block_bitmap = 101711880
[22169.860156] EXT4-fs error (device sda): ext4_discard_preallocations:4046: comm XXX: Error -5 reading block bitmap for 3112
[22169.864926] EXT4-fs (sda): previous I/O error to superblock detected
[22169.865281] EXT4-fs error (device sda): ext4_wait_block_bitmap:503: comm XXX: Cannot read block bitmap - block_group = 3112, block_bitmap = 101711880
[22169.870424] EXT4-fs (sda): previous I/O error to superblock detected
[22169.870465] EXT4-fs error (device sda): ext4_discard_preallocations:4046: comm XXX: Error -5 reading block bitmap for 3112
[22169.876051] EXT4-fs (sda): previous I/O error to superblock detected
[22169.876424] EXT4-fs error (device sda): ext4_wait_block_bitmap:503: comm XXX: Cannot read block bitmap - block_group = 3112, block_bitmap = 101711880
[22169.882293] EXT4-fs (sda): previous I/O error to superblock detected
[22169.882346] EXT4-fs error (device sda): ext4_discard_preallocations:4046: comm XXX: Error -5 reading block bitmap for 3112
[22169.888540] EXT4-fs (sda): previous I/O error to superblock detected
[22169.888723] EXT4-fs error (device sda): ext4_wait_block_bitmap:503: comm XXX: Cannot read block bitmap - block_group = 3097, block_bitmap = 101187593
[22169.895383] EXT4-fs (sda): previous I/O error to superblock detected
[22169.895451] EXT4-fs error (device sda): ext4_discard_preallocations:4046: comm XXX: Error -5 reading block bitmap for 3097
[22169.902323] EXT4-fs (sda): previous I/O error to superblock detected
[22169.902461] EXT4-fs error (device sda): ext4_wait_block_bitmap:503: comm XXX: Cannot read block bitmap - block_group = 3084, block_bitmap = 100663308
[22169.909796] EXT4-fs (sda): previous I/O error to superblock detected
[22169.909847] EXT4-fs error (device sda): ext4_discard_preallocations:4046: comm XXX: Error -5 reading block bitmap for 3084
[22169.917925] EXT4-fs (sda): previous I/O error to superblock detected
[22169.925879] Buffer I/O error on dev sda, logical block 101411071, async page read
[22169.938955] EXT4-fs error (device sda): ext4_journal_check_start:56: Detected aborted journal
[22169.963838] EXT4-fs warning (device sda): dx_probe:742: inode #28835841: lblock 0: comm XXX: error -5 reading directory block
[22170.003760] EXT4-fs warning (device sda): dx_probe:742: inode #28835841: lblock 0: comm XXX: error -5 reading directory block
[22170.029103] EXT4-fs warning (device sda): dx_probe:742: inode #28835841: lblock 0: comm XXX: error -5 reading directory block
[22170.081860] EXT4-fs warning (device sda): dx_probe:742: inode #28835841: lblock 0: comm XXX: error -5 reading directory block
[22170.254389] usb 1-1.5: new high-speed USB device number 5 using dwc_otg
[22170.388166] usb 1-1.5: New USB device found, idVendor=1bcf, idProduct=0c31
[22170.388174] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[22170.388178] usb 1-1.5: Product: USB to Serial-ATA bridge
[22170.388182] usb 1-1.5: Manufacturer: Sunplus Innovation Technology 
[22170.388186] usb 1-1.5: SerialNumber: FFFF0FFF54000000FD100ADF1AFFFF
[22170.390249] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[22170.390444] scsi host1: usb-storage 1-1.5:1.0
[22171.448737] scsi 1:0:0:0: Direct-Access     HGST HTS XXX     0200 PQ: 0 ANSI: 4
[22171.449371] sd 1:0:0:0: Attached scsi generic sg0 type 0
[22171.450143] sd 1:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[22171.456977] sd 1:0:0:0: [sdb] Write Protect is off
[22171.456988] sd 1:0:0:0: [sdb] Mode Sense: 38 00 00 00
[22171.463797] sd 1:0:0:0: [sdb] No Caching mode page found
[22171.463803] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[22171.774063] sd 1:0:0:0: [sdb] Attached SCSI disk
The drive is not accessible after this and all programs that depends on the drive crashes when the drive flunks out. The drive is mounted with fstab: "UUID=a-lot-of-hex-values /media/MOUNTPOINT ext4 defaults,noatime 0 0".

This really annoys me since the only way to recover from this is to restart the pi :?

EDIT: It's a RPi 3 Model B btw..
Please do not ask questions in private messages, they will not help others.

NotRequired
Posts: 196
Joined: Sat Apr 29, 2017 10:36 am
Location: Denmark

Re: USB drive disconnects and reconnects

Mon May 29, 2017 6:20 pm

I do not know if this instability was caused by the bad Kingston SD-card (*) or if this is a common issue with the Pi. But it seems like I've found a working sollution after some testing. The sollution has allowed my Pi to run stable for more than a week now - before it was at most 10 hours before the drive disconnected, leaving a dirty unmount and crashed apps.

I've promoted the sollution with udev rules in another thread and I really like the method. It allows the drive to be unplugged from the Pi during operation without leaving a dirty mount point (**). It allows the drive to be plugged into the Pi during operation and it will always be auto-mounted to the same mounting point. If the drive is plugged in during boot it will be mounted and if the drive is not plugged in it will not be mounted and not cause any boot issues.

For the fun of it I've bashed up a script to automate the procedure of creating and deleting udev rules for a particular drive. Please mind that I'm not an expert in bash scripting and there may be a sleeker way to do it. But the script works and it has been tested on 2 computers (Debian Jessie, Mint 17.3) and a Pi3B (Raspbian Jessie). The script is available on github and I would really like to hear other opinions and suggestions on this.

To get help run (or just read the top of the script):

Code: Select all

./uamount.sh --help
To create a udev mounting rule for /dev/sda on /media/MYDRIVE use:

Code: Select all

sudo ./uamount.sh /dev/sda MYDRIVE
To remove the mounting rule again use:

Code: Select all

sudo ./uamount.sh /dev/sda
Hope it may help someone!

(*) I'm not an expert in the subject but I have a suspicion that some SD-cards are drawing more current during (read and) write operations than the specs allows. This may overload the Pi and cause data corruption and other instabilities.

(**) When unplugging the drive all write operations must have been flushed / synced or loss of data may be an issue!
Please do not ask questions in private messages, they will not help others.

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: USB drive disconnects and reconnects

Tue May 30, 2017 2:52 am

Some USB-SATA bridge chips are good and some bad. Run lsusb to get the USB chip id. Google linux and the chip id. You might find it is one of the chips known to have incomplete USB, chips that require special drivers. I moved a couple of disks to new enclosures to make the drives work.

Return to “General discussion”