![fdisk 显示设备的分区表,但 udev 不创建设备](https://linux22.com/image/163571/fdisk%20%E6%98%BE%E7%A4%BA%E8%AE%BE%E5%A4%87%E7%9A%84%E5%88%86%E5%8C%BA%E8%A1%A8%EF%BC%8C%E4%BD%86%20udev%20%E4%B8%8D%E5%88%9B%E5%BB%BA%E8%AE%BE%E5%A4%87.png)
我正在尝试安装外部 USB 硬盘。具体来说,是 USB 密钥。但udev
不显示驱动器上的分区。
我正在运行 Debian 10 (buster),带有一个库存内核,即4.19.0-6-amd64
.
fdisk
报告
root@orwell:/mnt# fdisk -l /dev/sdh
Disk /dev/sdh: 1.9 GiB, 2001076224 bytes, 3908352 sectors
Disk model: Cruzer Blade
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x03b1e8fa
Device Boot Start End Sectors Size Id Type
/dev/sdh1 2048 3908351 3906304 1.9G b W95 FAT32
但是如果我尝试挂载分区,我会得到
root@orwell:/mnt# mount -t vfat /dev/sdh1 joseph
mount: /mnt/joseph: special device /dev/sdh1 does not exist.
虽然这可能不是很相关,但该分区似乎也没有 UUID。至少,该设备没有出现在blkid
.
journalctl
在插入设备时显示以下日志。
Nov 06 19:01:09 orwell kernel: usb 1-1: new high-speed USB device number 6 using ehci-pci
Nov 06 19:01:09 orwell kernel: usb 1-1: New USB device found, idVendor=0781, idProduct=5567, bcdDevice= 1.00
Nov 06 19:01:09 orwell kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Nov 06 19:01:09 orwell kernel: usb 1-1: Product: Cruzer Blade
Nov 06 19:01:09 orwell kernel: usb 1-1: Manufacturer: SanDisk
Nov 06 19:01:09 orwell kernel: usb 1-1: SerialNumber: 20063486020EF1B285D3
Nov 06 19:01:09 orwell kernel: usb-storage 1-1:1.0: USB Mass Storage device detected
Nov 06 19:01:09 orwell kernel: scsi host11: usb-storage 1-1:1.0
Nov 06 19:01:09 orwell mtp-probe[30090]: checking bus 1, device 6: "/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1"
Nov 06 19:01:09 orwell mtp-probe[30090]: bus: 1, device: 6 was not an MTP device
Nov 06 19:01:10 orwell mtp-probe[30094]: checking bus 1, device 6: "/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1"
Nov 06 19:01:10 orwell mtp-probe[30094]: bus: 1, device: 6 was not an MTP device
Nov 06 19:01:10 orwell kernel: scsi 11:0:0:0: Direct-Access SanDisk Cruzer Blade 1.01 PQ: 0 ANSI: 2
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: Attached scsi generic sg9 type 0
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: [sdh] 3908352 512-byte logical blocks: (2.00 GB/1.86 GiB)
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: [sdh] Write Protect is off
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: [sdh] Mode Sense: 03 00 00 00
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: [sdh] No Caching mode page found
Nov 06 19:01:10 orwell kernel: sd 11:0:0:0: [sdh] Assuming drive cache: write through
Nov 06 19:01:11 orwell kernel: sd 11:0:0:0: [sdh] Attached SCSI removable disk
Nov 06 19:01:11 orwell systemd[1]: Starting [email protected]...
Nov 06 19:01:11 orwell usbmount[30113]: loaded usbmount configurations
Nov 06 19:01:11 orwell usbmount[30114]: usbmount is disabled, see /etc/usbmount/usbmount.conf
Nov 06 19:01:11 orwell systemd[1]: Started [email protected].
Nov 06 19:01:11 orwell audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=usbmount@dev-sdh comm="systemd" exe="/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
答案1
由于某种原因,Linux 内核无法识别分区表,因此它不知道应该有一个sdh1
.除非你做了一些奇怪的事情(比如编译一个不支持 DOS 分区表的内核),否则这可能意味着分区表格式并不完全符合内核的预期(fdisk
是解析分区表的不同实现,因此可能就是为什么 fdisk 可以使用它)。可能用(等)重写分区表fdisk
可以修复它。
但是,如果您想挂载分区而不重写表(例如,不修改磁盘),那么您可以使用以下命令手动将分区详细信息提供给内核addpart
:
addpart /dev/sdh 1 2048 3906304
# ^ ^ ^
# partition#────┘ | \
# start sector length (sectors) ← both from fdisk -l output
运行之后(并等待 udev 一点点),您应该有一个/dev/sdh1
,您可以继续安装它。