USB 硬盘未显示在 /dev/ 下

USB 硬盘未显示在 /dev/ 下

我在带有 LXDE 的 BeagleBone Black 上运行 Ubuntu 14.01。我有一个 USB 硬盘,如果我在计算机启动后连接它,它会自动安装(LXDE 中会出现提示,我必须输入密码)。然后我还可以在 下看到 USB 硬盘/dev/。但如果我在计算机启动时连接了 USB 硬盘,那么我就看不到 下的硬盘/dev/。有什么建议可以解决此问题吗?

lsusb这是启动过程中连接 USB 硬盘时的输出

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

这是启动过程中连接 USB 硬盘时的输出sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL(我跳过了,/dev/[sh]d因为 USB 硬盘在 下不可用)/dev/

NAME         FSTYPE   SIZE MOUNTPOINT  LABEL
mmcblk0boot0            1M             
mmcblk0boot1            1M             
mmcblk0               1.8G             
├─mmcblk0p1  vfat       1M /boot/uboot boot
└─mmcblk0p2  ext4     1.8G /           rootfs

lsusb这是启动后连接 UBS 硬盘时的输出

Bus 001 Device 002: ID 152d:2338 JMicron Technology Corp. / JMicron USA Technology Corp. JM20337 Hi-Speed USB to SATA & PATA Combo Bridge
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL /dev/sda这是启动后连接 UBS 硬盘并通过 LXDE“自动挂载”时的输出 (出现提示,我必须输入密码)

NAME   FSTYPE   SIZE MOUNTPOINT  LABEL
sda           931.5G                                                    
└─sda1 ext4   931.5G /media/mikael/b4c5600d-f0e0-4bc9-83e4-caf6db38258e

dmesg这是启动后连接 USB 硬盘后的输出

[  347.032628] usb usb1: usb wakeup-resume
[  347.032735] usb usb1: usb auto-resume
[  347.032758] hub 1-0:1.0: hub_resume
[  347.032857] hub 1-0:1.0: port 1: status 0101 change 0001
[  347.135340] hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
[  347.135410] hub 1-0:1.0: port 1, status 0101, change 0000, 12 Mb/s
[  347.240770] usb 1-1: new high-speed USB device number 2 using musb-hdrc
[  347.360705] usb 1-1: default language 0x0409
[  347.361123] usb 1-1: udev 2, busnum 1, minor = 1
[  347.361204] usb 1-1: New USB device found, idVendor=152d, idProduct=2338
[  347.361218] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[  347.361229] usb 1-1: Product: USB to ATA/ATAPI bridge
[  347.361239] usb 1-1: Manufacturer: JMicron
[  347.361249] usb 1-1: SerialNumber: 1208891D9014
[  347.365968] usb 1-1: usb_probe_device
[  347.365997] usb 1-1: configuration #1 chosen from 1 choice
[  347.366360] usb 1-1: adding 1-1:1.0 (config #1, interface 0)
[  347.368713] usb-storage 1-1:1.0: usb_probe_interface
[  347.368747] usb-storage 1-1:1.0: usb_probe_interface - got id
[  347.380506] scsi0 : usb-storage 1-1:1.0
[  347.382266] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002
[  347.382323] hub 1-0:1.0: port 1 enable change, status 00000503
[  350.375785] scsi 0:0:0:0: Direct-Access     ST1000LM 024 HN-M101MBB        PQ: 0 ANSI: 2 CCS
[  350.442820] sd 0:0:0:0: [sda] 244190646 4096-byte logical blocks: (1.00 TB/931 GiB)
[  350.443523] sd 0:0:0:0: [sda] Write Protect is off
[  350.443545] sd 0:0:0:0: [sda] Mode Sense: 28 00 00 00
[  350.444583] sd 0:0:0:0: [sda] No Caching mode page present
[  350.450573] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  350.470712] sd 0:0:0:0: [sda] 244190646 4096-byte logical blocks: (1.00 TB/931 GiB)
[  350.474565] sd 0:0:0:0: [sda] No Caching mode page present
[  350.481187] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  350.547808]  sda: sda1
[  350.550022] sd 0:0:0:0: [sda] 244190646 4096-byte logical blocks: (1.00 TB/931 GiB)
[  350.550965] sd 0:0:0:0: [sda] No Caching mode page present
[  350.557204] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  350.563590] sd 0:0:0:0: [sda] Attached SCSI disk
[  368.429266] EXT4-fs (sda1): recovery complete
[  368.429980] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)

答案1

解决此问题的一种方法是触发 udev 重新扫描设备。以下是该命令的示例和相关输出的摘录。( 表示-v详细)

如果你改变了任何 udev 规则,你应该从以下开始:

sudo udevadm control --reload-rules

sudo udevadm trigger -v

/sys/devices/pci0000:00/0000:00:1d.0/usb2
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-0:1.0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/scsi_host/host6
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/block/sdd
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/block/sdd/sdd1
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/block/sdd/sdd2
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/bsg/6:0:0:0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/scsi_device/6:0:0:0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/scsi_disk/6:0:0:0
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/host6/target6:0:0/6:0:0:0/scsi_generic/sg4
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0

请注意,您的实际输出将远远超过此值,因为 udev 将重新扫描/sys/devices/

笔记:根据我的测试(观察 的输出udevadm monitor),sudo 是必需的。如果省略它,不会出现任何错误,但也不会发生任何事情。

进一步说明:测试是在几乎空闲的系统上进行的,没有发现任何不良影响。我还没有在高负载的系统上测试过这种方法。坦白说,因为我过去在高负载的系统上看到过奇怪的结果。

您可以利用开关将影响范围缩小至特定设备--attr-match=

要获取可用于特定设备的属性,请发出您的块设备在command udevadm info -q all -n /dev/sXY哪里/dev/sXY。我的是/dev/sdd

另一种更有针对性的方法echo change | sudo tee /sys/block/sdd/sdd1/uevent (其中 sdd 是您的驱动器,sdd1 是您的分区)。

这种方法的优点是可以精确定位设备。缺点是你必须真正了解你定位的设备是什么。

资料来源:

https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot

https://unix.stackexchange.com/questions/124817/udev-how-do-i-find-out-which-subsystem-a-device-belongs-to

相关内容