问题
硬盘无法挂载,通过下面的命令查看
sudo fdisk -l
得到如下结果
$ sudo fdisk -l
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
Disklabel type: dos
Disk identifier: 0xef452a6b
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 340082819 340080772 162.2G 7 HPFS/NTFS/exFAT
/dev/sda2 340084736 341837823 1753088 856M 27 Hidden NTFS WinRE
/dev/sda3 341839870 466861356 125021487 59.6G 5 Extended
/dev/sda4 466862080 468860927 1998848 976M 82 Linux swap / Solaris
/dev/sda5 * 341839872 466861356 125021485 59.6G 83 Linux
Partition table entries are not in disk order.
The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdb: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D4753271-ACBB-46E5-8A80-D391CA1EF007
Device Start End Sectors Size Type
/dev/sdb3 673792 182977958 182304167 87G Microsoft basic data
/dev/sdb4 182978560 183918591 940032 459M Windows recovery environment
解决方法
首先执行
sudo gdisk /dev/sdb
得到
GPT fdisk (gdisk) version 1.0.3
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: damaged
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Command (? for help):
可以看到磁盘的GPT分区有问题(不知道为什么windows可以读,linux不可以读)
然后输入r进行修复
Command (? for help): r
Recovery/transformation command (? for help):
然后我们输入问号
Recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Recovery/transformation command (? for help):
这里列出了一些我们可能用到的指令,这里我们只会用到b
输入b
Recovery/transformation command (? for help): b
然后什么也不会显示,继续输入w,写入备份的GPT分区数据重建磁盘
Recovery/transformation command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
ok,到这里,磁盘就修复完成了(不知道是windows的bug还是linux的bug)
再执行sudo fdisk -l
$ sudo fdisk -l
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
Disklabel type: dos
Disk identifier: 0xef452a6b
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 340082819 340080772 162.2G 7 HPFS/NTFS/exFAT
/dev/sda2 340084736 341837823 1753088 856M 27 Hidden NTFS WinRE
/dev/sda3 341839870 466861356 125021487 59.6G 5 Extended
/dev/sda4 466862080 468860927 1998848 976M 82 Linux swap / Solaris
/dev/sda5 * 341839872 466861356 125021485 59.6G 83 Linux
Partition table entries are not in disk order.
Disk /dev/sdb: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D4753271-ACBB-46E5-8A80-D391CA1EF007
Device Start End Sectors Size Type
/dev/sdb3 673792 182977958 182304167 87G Microsoft basic data
/dev/sdb4 182978560 183918591 940032 459M Windows recovery environment
磁盘已经不会报错了,可以正常挂载了。