USB SCSI Disconnects when Idle

Problem: An external USB harddrive disconnects and immediately reconnects with different device name. You find log entries like these:

Jan 17 00:46:52 workstation kernel: [212306.086568] sd 33:0:0:0: [sdj] Attached SCSI disk
Jan 17 01:51:14 workstation kernel: [216168.064075] usb 2-4: USB disconnect, device number 11
Jan 17 01:51:15 workstation kernel: [216168.596514] usb 2-4: new SuperSpeed USB device number 12 using xhci_hcd
Jan 17 01:51:16 workstation kernel: [216169.613657] sd 34:0:0:0: Attached scsi generic sg7 type 0
Jan 17 01:51:51 workstation kernel: [216169.616792] sd 34:0:0:0: [sdg] Spinning up disk........
Jan 17 01:51:52 workstation kernel: [216205.941531] sd 34:0:0:0: [sdg] Attached SCSI disk

This happens especially when the drive is idle.

Solution: This seems to be related to the SCSI standby feature which is enabled on new drives per default. You can disable this “feature” with:

sdparm -S -c STANDBY /dev/sdg

“-c STANDBY” clear STANDBY flag.
“-S” save for next power cycle
“/dev/sdg” device name of the usb harddrive

Tested with: Debian 7.0, WD Elements USB 3.0 harddisk.

1:1 Copy of Hard Disks with Errors

Problem: When you get I/O errors on your computers hard disk, it’s usually urgent to copy all data to a new disk. If you try to do a 1:1 copy using dd, you will see that dd stops when it reaches the first bad sector.

Solution: use the following command to copy from one hard disk to second hard disk, with every bad sector replaced with an all zero sector on the target hard disk

dd if=/dev/sda of=/dev/sdb conv=noerror,sync

With “/dev/sda” as source disk and “/dev/sdb” as destination disk. You can add “bs=4096” or higher to speed up the copy process.