我经常遇到这样的情况:USB 记忆棒或 SD 卡的分区表突然不再被内核识别,而 (g)parted 和 fdisk 仍然可以看到它,其他系统也是如此。我什至可以指示 gparted 对其中一个分区执行 fsck,但它当然会失败,因为设备文件(假设 /dev/sdbX )不存在。
我将附上 dmesg 输出:
[ 8771.136129] usb 1-5: new high-speed USB device number 4 using ehci_hcd
[ 8771.330322] Initializing USB Mass Storage driver...
[ 8771.330766] scsi4 : usb-storage 1-5:1.0
[ 8771.331108] usbcore: registered new interface driver usb-storage
[ 8771.331118] USB Mass Storage support registered.
[ 8772.329734] scsi 4:0:0:0: Direct-Access Generic STORAGE DEVICE 0207 PQ: 0 ANSI: 0
[ 8772.334359] sd 4:0:0:0: Attached scsi generic sg1 type 0
[ 8772.619619] sd 4:0:0:0: [sdb] 31586304 512-byte logical blocks: (16.1 GB/15.0 GiB)
[ 8772.620955] sd 4:0:0:0: [sdb] Write Protect is off
[ 8772.620971] sd 4:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 8772.622303] sd 4:0:0:0: [sdb] No Caching mode page present
[ 8772.622317] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 8772.629970] sd 4:0:0:0: [sdb] No Caching mode page present
[ 8772.629992] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 8775.030231] sd 4:0:0:0: [sdb] Unhandled sense code
[ 8775.030240] sd 4:0:0:0: [sdb] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 8775.030249] sd 4:0:0:0: [sdb] Sense Key : Medium Error [current]
[ 8775.030259] sd 4:0:0:0: [sdb] Add. Sense: Data phase CRC error detected
[ 8775.030271] sd 4:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
[ 8775.030291] end_request: I/O error, dev sdb, sector 0
[ 8775.030300] quiet_error: 30 callbacks suppressed
[ 8775.030306] Buffer I/O error on device sdb, logical block 0
[ 8775.033781] ldm_validate_partition_table(): Disk read failed.
[ 8775.033813] Dev sdb: unable to read RDB block 0
[ 8775.037147] sdb: unable to read partition table
[ 8775.047170] sd 4:0:0:0: [sdb] No Caching mode page present
[ 8775.047185] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 8775.047196] sd 4:0:0:0: [sdb] Attached SCSI removable disk
另一方面,这是parted 必须同时对同一个磁盘说的话:
(parted) print
Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sdb: 16.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 4194kB 62.9MB 58.7MB primary fat16 lba
2 62.9MB 16.2GB 16.1GB primary ext4
它不仅是分区的,即使是较旧的 fdisk 也没有遇到该分区表的问题:
Command (m for help): p
Disk /dev/sdb: 16.2 GB, 16172187648 bytes
64 heads, 32 sectors/track, 15423 cylinders, total 31586304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dbfc6
Device Boot Start End Blocks Id System
/dev/sdb1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/sdb2 122880 31586303 15731712 83 Linux
我实在是一无所知。很容易说分区表已损坏,但是为什么 gparted 仍然可以毫无抱怨地读取它(并且没有任何抱怨)或者我如何从 (g)parted 奇迹般地发现的内容重建分区表?
答案1
由于某种原因,您的内核无法读取分区表:
[ 8775.030291] end_request: I/O error, dev sdb, sector 0
[ 8775.030300] quiet_error: 30 callbacks suppressed
[ 8775.030306] Buffer I/O error on device sdb, logical block 0
[ 8775.033781] ldm_validate_partition_table(): Disk read failed.
因此,它无法为分区创建设备,因为它没有读取分区表。稍后,当您尝试使用parted或fdisk查看分区表时,IO将成功执行。
partprobe /dev/sdX
当您的内核在启动时无法识别分区时尝试使用。
男人部分探针:
PARTPROBE(8) GNU Parted Manual PARTPROBE(8)
NAME
partprobe - inform the OS of partition table changes
SYNOPSIS
partprobe [-d] [-s] [devices...]
DESCRIPTION
This manual page documents briefly the partprobe command.
partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the
partition table.
答案2
这可能是你的情况,以防万一其他人遇到这个问题,我以前遇到过这个问题并发现拥有gparted
或其他分区编辑器可以阻止分区表读取。关闭gparted
并重试,可能就这么简单。