到手一块 TOSHIBA DTB305 500G 移动硬盘,计划用来备份电脑的数据,先加密
cryptsetup -s 512 luksFormat /dev/sdb
居然失败,磁盘一直报错:
May 23 23:38:20 mom kernel: scsi 6:0:0:0: Direct-Access TOSHIBA External USB 3.0 0114 PQ: 0 ANSI: 6 May 23 23:38:20 mom kernel: sd 6:0:0:0: [sdb] Spinning up disk... May 23 23:38:21 mom kernel: .ready May 23 23:38:21 mom kernel: sd 6:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/466 GiB) May 23 23:38:21 mom kernel: sd 6:0:0:0: [sdb] Write Protect is off May 23 23:38:21 mom kernel: sd 6:0:0:0: [sdb] Mode Sense: 47 00 10 08 May 23 23:38:21 mom kernel: sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA May 23 23:38:21 mom kernel: sdb: sdb1 May 23 23:38:21 mom kernel: sd 6:0:0:0: [sdb] Attached SCSI disk May 23 23:38:22 mom kernel: FAT-fs (sdb1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive! May 23 23:40:22 mom kernel: sdb: May 23 23:42:35 mom kernel: sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 May 23 23:42:35 mom kernel: sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] May 23 23:42:35 mom kernel: sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 May 23 23:42:35 mom kernel: sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 00 00 08 00 00 00 08 00 May 23 23:42:35 mom kernel: print_req_error: critical target error, dev sdb, sector 2048 May 23 23:44:57 mom kernel: sdb: May 23 23:45:26 mom kernel: sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 May 23 23:45:26 mom kernel: sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] May 23 23:45:26 mom kernel: sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 May 23 23:45:26 mom kernel: sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 00 00 08 00 00 00 08 00 May 23 23:45:26 mom kernel: print_req_error: critical target error, dev sdb, sector 2048 May 23 23:45:58 mom kernel: sdb: May 23 23:46:05 mom kernel: sdb: May 23 23:47:55 mom kernel: sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 May 23 23:47:55 mom kernel: sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] May 23 23:47:55 mom kernel: sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 May 23 23:47:55 mom kernel: sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 00 00 00 00 00 00 08 00 May 23 23:47:55 mom kernel: print_req_error: critical target error, dev sdb, sector 0 May 23 23:59:15 mom kernel: sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 May 23 23:59:15 mom kernel: sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] May 23 23:59:15 mom kernel: sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 May 23 23:59:15 mom kernel: sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 00 00 00 00 00 00 08 00 May 23 23:59:15 mom kernel: print_req_error: critical target error, dev sdb, sector 0
难道硬盘坏了,查了下SMART完全没问题啊,算了,换veracrypt加密,这次可以了,接着创建ext4,挂载正常, 但是,随手看了下日志,也不行:
[ 123.936031] usb 1-2.4: new high-speed USB device number 6 using ehci-pci [ 124.107699] usb 1-2.4: New USB device found, idVendor=0480, idProduct=a001 [ 124.107703] usb 1-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 124.107705] usb 1-2.4: Product: USB device [ 124.107707] usb 1-2.4: Manufacturer: USB device [ 124.107709] usb 1-2.4: SerialNumber: WQ670000000009252 [ 124.108238] usb-storage 1-2.4:1.0: USB Mass Storage device detected [ 124.114141] scsi host6: usb-storage 1-2.4:1.0 [ 124.176728] usbcore: registered new interface driver uas [ 125.154152] scsi 6:0:0:0: Direct-Access TOSHIBA External USB 3.0 0114 PQ: 0 ANSI: 6 [ 125.162002] sd 6:0:0:0: [sdb] Spinning up disk... [ 126.176026] .ready [ 126.177651] sd 6:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/466 GiB) [ 126.180276] sd 6:0:0:0: [sdb] Write Protect is off [ 126.180279] sd 6:0:0:0: [sdb] Mode Sense: 47 00 10 08 [ 126.182271] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA [ 126.197549] sdb: sdb1 sdb2 [ 126.203273] sd 6:0:0:0: [sdb] Attached SCSI disk [ 126.818539] FAT-fs (sdb1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive! [ 126.940855] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. [ 140.651217] sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 [ 140.651222] sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] [ 140.651224] sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 [ 140.651227] sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 01 40 18 00 00 00 08 00 [ 140.651229] print_req_error: critical target error, dev sdb, sector 20977664 [ 140.651242] Buffer I/O error on dev dm-1, logical block 0, lost sync page write [ 140.661143] EXT4-fs (dm-1): mounted filesystem with ordered data mode. Opts: (null) [ 146.950106] sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 [ 146.950111] sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] [ 146.950114] sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 [ 146.950117] sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 1d 84 18 18 00 00 08 00 [ 146.950120] print_req_error: critical target error, dev sdb, sector 495196184 [ 146.950142] Aborting journal on device dm-1-8. [ 146.953093] sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 [ 146.953097] sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] [ 146.953099] sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 [ 146.953103] sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 1d 84 18 00 00 00 08 00 [ 146.953105] print_req_error: critical target error, dev sdb, sector 495196160 [ 146.953111] Buffer I/O error on dev dm-1, logical block 59277312, lost sync page write [ 146.953124] JBD2: Error -5 detected when updating journal superblock for dm-1-8. [ 178.941515] EXT4-fs (dm-1): previous I/O error to superblock detected [ 178.945445] sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 [ 178.945451] sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] [ 178.945453] sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 [ 178.945457] sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 01 40 18 00 00 00 08 00 [ 178.945460] print_req_error: critical target error, dev sdb, sector 20977664 [ 178.945472] Buffer I/O error on dev dm-1, logical block 0, lost sync page write [ 178.945494] EXT4-fs error (device dm-1): ext4_journal_check_start:61: Detected aborted journal [ 178.945499] EXT4-fs (dm-1): Remounting filesystem read-only [ 178.945506] EXT4-fs (dm-1): previous I/O error to superblock detected [ 178.949462] sd 6:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08 [ 178.949466] sd 6:0:0:0: [sdb] tag#0 Sense Key : 0x5 [current] [ 178.949468] sd 6:0:0:0: [sdb] tag#0 ASC=0x24 ASCQ=0x0 [ 178.949472] sd 6:0:0:0: [sdb] tag#0 CDB: opcode=0x2a 2a 08 01 40 18 00 00 00 08 00 [ 178.949475] print_req_error: critical target error, dev sdb, sector 20977664 [ 178.949485] Buffer I/O error on dev dm-1, logical block 0, lost sync page write
莫非这硬盘对Linux有什么限制?日志文件系统不行,那换成FAT试试,居然好了!这不科学,搜索一通发现可能是硬盘cache的问题: scsi: introduce a quirk for false cache reporting
补丁里没有我这块盘的型号,依葫芦画瓢写一个补丁 toshiba_dtb305-sync_cache.patch
重新编译内核,加密,创建文件系统,读写正常,搞定!
[179343.585880] usb 1-2.4: New USB device found, idVendor=0480, idProduct=a001 [179343.585884] usb 1-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [179343.585886] usb 1-2.4: Product: USB device [179343.585888] usb 1-2.4: Manufacturer: USB device [179343.585890] usb 1-2.4: SerialNumber: WQ670000000009252 [179343.586680] usb-storage 1-2.4:1.0: USB Mass Storage device detected [179343.590799] usb-storage 1-2.4:1.0: Quirks match for vid 0480 pid a001: 20000000 [179343.591052] scsi host6: usb-storage 1-2.4:1.0 [179344.610048] scsi 6:0:0:0: Direct-Access TOSHIBA External USB 3.0 0114 PQ: 0 ANSI: 6 [179344.617874] sd 6:0:0:0: [sdb] Spinning up disk... [179345.632026] .ready [179345.633253] sd 6:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/466 GiB) [179345.633258] sd 6:0:0:0: [sdb] Assuming Write Enabled [179345.633260] sd 6:0:0:0: [sdb] Assuming drive cache: write back [179345.639144] sdb: sdb1 sdb2 [179345.640371] sd 6:0:0:0: [sdb] Attached SCSI disk [179346.383257] FAT-fs (sdb1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive! [179346.404356] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. [179349.378210] EXT4-fs (dm-1): mounted filesystem with ordered data mode. Opts: (null)
找到一篇写的更详细的: Linux下USB 3.0移动硬盘读写错误问题分析
Last comments