Linux USB恐怖
Linux USB horror
我写了一个程序,它在挂载的 USB
设备上创建一个文件。这可以通过 RS232
连接使用基于文本的 UI 来完成。但是,似乎有些不对劲。 5 次中有 1 次,写入 USB
设备的整个过程失败,我得到以下信息:
显然发生了 I/O 错误,内核决定卸载设备并再次检测它。知道问题可能是什么吗?
此错误与使用的 USB
设备无关,因为我能够使用多个不同的 USB
设备重现此错误。
P.S.: 我不确定这个问题是否属于 Whosebug
。如果没有,请随意移动它。
编辑:有问题的设备是 运行 Linux 2.6.24.6
编辑:
我刚刚检测到一个非常有趣的行为。我将 U 盘连接到设备并使用以下命令创建了一个大目录的 tar:
tar -cvf test.tar ./test_directory
该目录在 SD 卡上,即在一个完全不同的文件系统上。但是,在创建存档时,发生多个 USB 断开和 USB 连接事件:
--> start creating archive
/tmp #
[74901.704258] usb 2-1: new high speed USB device using fsl-ehci and address 18
[74901.914427] usb 2-1: configuration #1 chosen from 1 choice
[74902.020174] scsi18 : SCSI emulation for USB Mass Storage devices
[74904.147779] usb 2-1: USB disconnect, address 18
[74904.573424] usb 2-1: new high speed USB device using fsl-ehci and address 19
[74904.785303] usb 2-1: configuration #1 chosen from 1 choice
[74904.891860] scsi19 : SCSI emulation for USB Mass Storage devices
[74907.748285] usb 2-1: USB disconnect, address 19
[74908.063438] usb 2-1: new high speed USB device using fsl-ehci and address 20
[74908.264751] usb 2-1: configuration #1 chosen from 1 choice
[74908.311019] scsi20 : SCSI emulation for USB Mass Storage devices
[74909.470917] usb 2-1: USB disconnect, address 20
[74909.783331] usb 2-1: new high speed USB device using fsl-ehci and address 21
[74909.983410] usb 2-1: configuration #1 chosen from 1 choice
[74910.031500] scsi21 : SCSI emulation for USB Mass Storage devices
[74915.106340] scsi 21:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74915.184964] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.235993] sd 21:0:0:0: [sda] Write Protect is off
[74915.275597] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.330972] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.379568] sd 21:0:0:0: [sda] Write Protect is off
[74915.411428] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.457712] sda: sda1
[74915.771348] sd 21:0:0:0: [sda] Attached SCSI removable disk
[74915.805114] sd 21:0:0:0: Attached scsi generic sg0 type 0
[74923.462332] usb 2-1: USB disconnect, address 21
[74924.484001] usb 2-1: new high speed USB device using fsl-ehci and address 22
[74924.702678] usb 2-1: configuration #1 chosen from 1 choice
[74924.798064] scsi22 : SCSI emulation for USB Mass Storage devices
[74929.855161] scsi 22:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74929.951158] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.001646] sd 22:0:0:0: [sda] Write Protect is off
[74930.034424] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.077218] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.131909] sd 22:0:0:0: [sda] Write Protect is off
[74930.166881] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.208044] sda: sda1
[74930.260520] sd 22:0:0:0: [sda] Attached SCSI removable disk
[74930.303588] sd 22:0:0:0: Attached scsi generic sg0 type 0
[74931.951336] usb 2-1: USB disconnect, address 22
[74932.272609] usb 2-1: new high speed USB device using fsl-ehci and address 23
[74932.483821] usb 2-1: configuration #1 chosen from 1 choice
[74932.569866] scsi23 : SCSI emulation for USB Mass Storage devices
[74936.434380] usb 2-1: USB disconnect, address 23
[74936.754210] usb 2-1: new high speed USB device using fsl-ehci and address 24
[74937.751966] usb 2-1: configuration #1 chosen from 1 choice
[74937.820607] scsi24 : SCSI emulation for USB Mass Storage devices
[74942.887336] scsi 24:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74942.958666] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.004909] sd 24:0:0:0: [sda] Write Protect is off
[74943.044027] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.101958] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.147503] sd 24:0:0:0: [sda] Write Protect is off
[74943.190786] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.230368] sda: sda1
[74943.258203] sd 24:0:0:0: [sda] Attached SCSI removable disk
[74943.314301] sd 24:0:0:0: Attached scsi generic sg0 type 0
我要为这个问题创建一个新话题!
I/O 错误和目录面包消息在损坏的文件系统上很典型,通常可以使用 fsck 工具修复。
修复文件系统后,我建议您检查连接是否在写入操作过程中中断。由于您的问题可以在多个 USB 设备上重现,因此我会先检查 RS232/USB 接口。
Apparently an I/O error occurred and the kernel decided to unmount the device and detect it again.
可能是相反的情况:设备被移除(通过 USB 子系统)并导致错误,因为它仍然被安装。
这对我来说像是一个硬件问题 - AFAIK 设备检测和删除是在主机控制器或集线器的硬件中完成的。检查电缆和连接,包括焊接连接。
使用示波器查看 USB 上的 +5 伏电压也可能很有价值 - 电压可能超出规格几毫秒,导致 USB 重置。
我写了一个程序,它在挂载的 USB
设备上创建一个文件。这可以通过 RS232
连接使用基于文本的 UI 来完成。但是,似乎有些不对劲。 5 次中有 1 次,写入 USB
设备的整个过程失败,我得到以下信息:
显然发生了 I/O 错误,内核决定卸载设备并再次检测它。知道问题可能是什么吗?
此错误与使用的 USB
设备无关,因为我能够使用多个不同的 USB
设备重现此错误。
P.S.: 我不确定这个问题是否属于 Whosebug
。如果没有,请随意移动它。
编辑:有问题的设备是 运行 Linux 2.6.24.6
编辑:
我刚刚检测到一个非常有趣的行为。我将 U 盘连接到设备并使用以下命令创建了一个大目录的 tar:
tar -cvf test.tar ./test_directory
该目录在 SD 卡上,即在一个完全不同的文件系统上。但是,在创建存档时,发生多个 USB 断开和 USB 连接事件:
--> start creating archive
/tmp #
[74901.704258] usb 2-1: new high speed USB device using fsl-ehci and address 18
[74901.914427] usb 2-1: configuration #1 chosen from 1 choice
[74902.020174] scsi18 : SCSI emulation for USB Mass Storage devices
[74904.147779] usb 2-1: USB disconnect, address 18
[74904.573424] usb 2-1: new high speed USB device using fsl-ehci and address 19
[74904.785303] usb 2-1: configuration #1 chosen from 1 choice
[74904.891860] scsi19 : SCSI emulation for USB Mass Storage devices
[74907.748285] usb 2-1: USB disconnect, address 19
[74908.063438] usb 2-1: new high speed USB device using fsl-ehci and address 20
[74908.264751] usb 2-1: configuration #1 chosen from 1 choice
[74908.311019] scsi20 : SCSI emulation for USB Mass Storage devices
[74909.470917] usb 2-1: USB disconnect, address 20
[74909.783331] usb 2-1: new high speed USB device using fsl-ehci and address 21
[74909.983410] usb 2-1: configuration #1 chosen from 1 choice
[74910.031500] scsi21 : SCSI emulation for USB Mass Storage devices
[74915.106340] scsi 21:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74915.184964] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.235993] sd 21:0:0:0: [sda] Write Protect is off
[74915.275597] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.330972] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.379568] sd 21:0:0:0: [sda] Write Protect is off
[74915.411428] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.457712] sda: sda1
[74915.771348] sd 21:0:0:0: [sda] Attached SCSI removable disk
[74915.805114] sd 21:0:0:0: Attached scsi generic sg0 type 0
[74923.462332] usb 2-1: USB disconnect, address 21
[74924.484001] usb 2-1: new high speed USB device using fsl-ehci and address 22
[74924.702678] usb 2-1: configuration #1 chosen from 1 choice
[74924.798064] scsi22 : SCSI emulation for USB Mass Storage devices
[74929.855161] scsi 22:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74929.951158] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.001646] sd 22:0:0:0: [sda] Write Protect is off
[74930.034424] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.077218] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.131909] sd 22:0:0:0: [sda] Write Protect is off
[74930.166881] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.208044] sda: sda1
[74930.260520] sd 22:0:0:0: [sda] Attached SCSI removable disk
[74930.303588] sd 22:0:0:0: Attached scsi generic sg0 type 0
[74931.951336] usb 2-1: USB disconnect, address 22
[74932.272609] usb 2-1: new high speed USB device using fsl-ehci and address 23
[74932.483821] usb 2-1: configuration #1 chosen from 1 choice
[74932.569866] scsi23 : SCSI emulation for USB Mass Storage devices
[74936.434380] usb 2-1: USB disconnect, address 23
[74936.754210] usb 2-1: new high speed USB device using fsl-ehci and address 24
[74937.751966] usb 2-1: configuration #1 chosen from 1 choice
[74937.820607] scsi24 : SCSI emulation for USB Mass Storage devices
[74942.887336] scsi 24:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
[74942.958666] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.004909] sd 24:0:0:0: [sda] Write Protect is off
[74943.044027] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.101958] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.147503] sd 24:0:0:0: [sda] Write Protect is off
[74943.190786] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.230368] sda: sda1
[74943.258203] sd 24:0:0:0: [sda] Attached SCSI removable disk
[74943.314301] sd 24:0:0:0: Attached scsi generic sg0 type 0
我要为这个问题创建一个新话题!
I/O 错误和目录面包消息在损坏的文件系统上很典型,通常可以使用 fsck 工具修复。 修复文件系统后,我建议您检查连接是否在写入操作过程中中断。由于您的问题可以在多个 USB 设备上重现,因此我会先检查 RS232/USB 接口。
Apparently an I/O error occurred and the kernel decided to unmount the device and detect it again.
可能是相反的情况:设备被移除(通过 USB 子系统)并导致错误,因为它仍然被安装。
这对我来说像是一个硬件问题 - AFAIK 设备检测和删除是在主机控制器或集线器的硬件中完成的。检查电缆和连接,包括焊接连接。
使用示波器查看 USB 上的 +5 伏电压也可能很有价值 - 电压可能超出规格几毫秒,导致 USB 重置。