为什么 sda1 没有出现在 dev 中,我该如何解决这个问题?

为什么 sda1 没有出现在 dev 中,我该如何解决这个问题?

我有一个嵌入式 Linux 设备,我试图将一些文件复制到其中。我插入 USB 记忆棒,dmesg 显示它已被识别,但由于某种原因/dev/sda1从未出现。

我试图了解发生了什么事......为什么/dev/sdaX根本没有出现,我该怎么办?

这是 dmesg:

[  434.006104] usb 1-1: new full-speed USB device number 2 using musb-hdrc
[  434.066132] hub 1-0:1.0: unable to enumerate USB device on port 1
[  434.466078] usb 1-1: new high-speed USB device number 3 using musb-hdrc
[  434.606941] usb 1-1: New USB device found, idVendor=14cd, idProduct=125c
[  434.614008] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[  434.621548] usb 1-1: Product: Mass Storage Device
[  434.626512] usb 1-1: Manufacturer: Generic
[  434.630825] usb 1-1: SerialNumber: 125C20100726
[  434.637445] scsi0 : usb-storage 1-1:1.0
[  435.636998] scsi 0:0:0:0: Direct-Access     Mass     Storage Device        PQ: 0 ANSI: 0 CCS
[  435.649935] sd 0:0:0:0: [sda] 15644672 512-byte logical blocks: (8.01 GB/7.45 GiB)
[  435.658578] sd 0:0:0:0: [sda] Write Protect is off
[  435.663874] sd 0:0:0:0: [sda] No Caching mode page present
[  435.669696] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  435.678648] sd 0:0:0:0: [sda] No Caching mode page present
[  435.684443] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  435.692168]  sda: sda1
[  435.697256] sd 0:0:0:0: [sda] No Caching mode page present
[  435.703051] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  435.709499] sd 0:0:0:0: [sda] Attached SCSI removable disk

我检查了一下/proc/partitions,可以看到它在那里:

-sh-4.2# cat partitions
major minor  #blocks  name

  31        0        128 mtdblock0
  31        1        256 mtdblock1
  31        2         64 mtdblock2
  31        3       1408 mtdblock3
  31        4       2560 mtdblock4
  31        5       3776 mtdblock5
  31        6       8192 mtdblock6
 179        0    7822336 mmcblk0
 179        1      72261 mmcblk0p1
 179        2    7735297 mmcblk0p2
   8        0    7822336 sda
   8        1    7818240 sda1

这是 的快照/dev,如您所见,没有sda1

-sh-4.2# ls /dev
Buzzer              mem                 ram5                tty39
MAKEDEV             mice                ram6                tty4
XOR                 mmcblk0             ram7                tty40
apm_bios            mmcblk0p1           ram8                tty41
console             mmcblk0p2           ram9                tty42
core                mouse0              ramdisk             tty43
cpu_dma_latency     mtd0                random              tty44
crypto              mtd0ro              rfkill              tty45
event0              mtd1                root                tty46
fb0                 mtd1ro              rtc0                tty47
fd                  mtd2                stderr              tty48
full                mtd2ro              stdin               tty49
gpioLeds            mtd3                stdout              tty5
gpioOperate         mtd3ro              timer               tty50
hda                 mtd4                tscadc-test         tty51
hda1                mtd4ro              tty                 tty52
hda10               mtd5                tty0                tty53
hda11               mtd5ro              tty1                tty54
hda12               mtd6                tty10               tty55
hda13               mtd6ro              tty11               tty56
hda14               mtd7                tty12               tty57
hda15               mtdblock0           tty13               tty58
hda16               mtdblock1           tty14               tty59
hda17               mtdblock2           tty15               tty6
hda18               mtdblock3           tty16               tty60
hda19               mtdblock4           tty17               tty61
hda2                mtdblock5           tty18               tty62
hda3                mtdblock6           tty19               tty63
hda4                mtdblock7           tty2                tty7
hda5                network_latency     tty20               tty8
hda6                network_throughput  tty21               tty9
hda7                nfsd                tty22               ttyO0
hda8                null                tty23               ttyO1
hda9                psaux               tty24               ttyO2
hw_random           ptmx                tty25               ttyO3
i2c-1               pts                 tty26               ttyO4
initctl             pvrsrvkm            tty27               ttyS0
kmem                ram                 tty28               ttySA0
kmsg                ram0                tty29               ubi_ctrl
log                 ram1                tty3                urandom
loop-control        ram10               tty30               usbdev1.1
loop0               ram11               tty31               vcs
loop1               ram12               tty32               vcs1
loop2               ram13               tty33               vcsa
loop3               ram14               tty34               vcsa1
loop4               ram15               tty35               zero
loop5               ram2                tty36
loop6               ram3                tty37
loop7               ram4                tty38

udev monitor也是日志:

KERNEL[1431.270571] add      /de[ 1431.278179] scsi1 : usb-storage 1-1:1.0
vices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1 (usb)
KERNEL[1431.271543] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0 (usb)
KERNEL[1431.277947] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1 (scsi)
KERNEL[1431.278561] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/scsi_host/host1 (scsi_host)
KERNEL[1431.280381] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/usb_device/usbdev1.6 (usb_device)
[ 1432.287008] scsi 1:0:0:0: Direct-Access     Mass     Storage Device        PQ: 0 ANSI: 0 CCS
KERNEL[1432.291899] add      /devices/platform/o[ 1432.301160] sd 1:0:0:0: [sda] 15644672 512-byte logical blocks: (8.01 GB/7.45 GiB)
map/musb-ti81xx/[ 1432.310858] sd 1:0:0:0: [sda] Write Protect is off
musb-hdrc.1/usb1[ 1432.317254] sd 1:0:0:0: [sda] No Caching mode page present
/1-1/1-1:1.0/hos[ 1432.323863] sd 1:0:0:0: [sda] Assuming drive cache: write through
t1/target1:0:0 (scsi)
KERNEL[14[ 1432.334323] sd 1:0:0:0: [sda] No Caching mode page present
32.292637] add  [ 1432.340312] sd 1:0:0:0: [sda] Assuming drive cache: write through
    /devices/platform/omap/musb-[ 1432.349590]  sda: sda1
ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/target[ 1432.356659] sd 1:0:0:0: [sda] No Caching mode page present
1:0:0/1:0:0:0 (s[ 1432.363347] sd 1:0:0:0: [sda] Assuming drive cache: write through
csi)
KERNEL[143[ 1432.371188] sd 1:0:0:0: [sda] Attached SCSI removable disk
2.293192] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/target1:0:0/1:0:0:0/scsi_disk/1:0:0:0 (scsi_disk)
KERNEL[1432.293657] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/target1:0:0/1:0:0:0/scsi_device/1:0:0:0 (scsi_device)
KERNEL[1432.326141] add      /devices/virtual/bdi/8:0 (bdi)
KERNEL[1432.347981] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/target1:0:0/1:0:0:0/block/sda (block)
KERNEL[1432.348571] add      /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/host1/target1:0:0/1:0:0:0/block/sda/sda1 (block)

答案1

好吧,我刚刚找到了问题的一半答案:

……我能做什么呢?

显然我可以自己制作设备节点。我将 U 盘插入我的笔记本电脑,发现它枚举为:

brw-rw---- 1 root disk 8,  0 Apr  3 13:15 /dev/sda
brw-rw---- 1 root disk 8,  1 Apr  3 13:15 /dev/sda1

因此,块设备的主版本号为 8,次版本号为 0 和 1。我检查了嵌入式设备上的长列表/dev,发现没有其他设备使用主版本号 8,因此我手动创建了节点:

-sh-4.2# mknod /dev/sda b 8 0
-sh-4.2# mknod /dev/sda1 b 8 1

然后我创建了一个目录并将新的 sda1 安装到该目录:

-sh-4.2# cd /mnt/
-sh-4.2# mkdir usbdrive
-sh-4.2# mount /dev/sda1 /mnt/usbdrive/
-sh-4.2# ls /mnt/usbdrive/
libEGL.so     libsrv_um.so

现在我可以看到 USB 驱动器的内容了。这就回答了“我能做什么”。我仍然有一个问题,为什么我需要在嵌入式板上手动执行此操作。一定有什么东西......也许在 USB 驱动程序中,可以自动完成这一切。

相关内容