可以使用fdisk -l
查看到磁盘分区信息但实际上并未成功
(base) root@ywb:~# fdisk -l
......
The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sde: 4.6 TiB, 5000981077504 bytes, 9767541167 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: 01000000-0000-0000-4E41-435239463342
Device Start End Sectors Size Type
/dev/sde1 40 409639 409600 200M EFI System
/dev/sde2 411648 9767540735 9767129088 4.6T Microsoft basic data
我们这里可以看到明显的报错
The primary GPT table is corrupt, but the backup appears OK, so that will be used.
(base) root@ywb:~# ll -d /dev/sde2
ls: cannot access '/dev/sde2': No such file or directory
我们可以使用gdisk命令进行修复损坏的分区
(base) root@ywb:~# gdisk /dev/sde
GPT fdisk (gdisk) version 1.0.3
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!
Warning! One or more CRCs don't match. You should repair the disk!
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.
****************************************************************************
# 可以看到磁盘的GPT分区有问题
# 然后输入r进行修复
Command (? for help): r
# 然后我们输入问号
# 这里列出了一些我们可能用到的指令,这里我们只会用到b
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
# 输入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/sde.
The operation has completed successfully.
# ok,到这里,磁盘就修复完成了
再次查看磁盘分区就没有报错了
(base) root@ywb:~# fdisk -l
......
Disk /dev/sde: 4.6 TiB, 5000981077504 bytes, 9767541167 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: 01000000-0000-0000-4E41-435239463342
Device Start End Sectors Size Type
/dev/sde1 40 409639 409600 200M EFI System
/dev/sde2 411648 9767540735 9767129088 4.6T Microsoft basic data
# 成功挂载
(base) root@ywb:~# mount /dev/sde2 /datasets
标签:partition,backup,ubuntu,bytes,dev,挂载,GPT,gdisk,table
From: https://www.cnblogs.com/ywb123/p/17483703.html