今天在使用linux系统时,由于异常断电,在重启时,发现自己的一块磁盘/dev/sdb,变成了未分区状态.初步断定是分区表坏掉了.
之前有人使用testdisk修复这种情况,自己下载了testdisk,根据网上操作指示,尝试进行修复.create ->select->EFI GPT(不同于Intel)->Analyse->Quicksearch->之后开始了漫长的等待
Analyse cylinder 12173/121600: 10%
MS Data 63 97675198 97675136 [llllll]
MS Data 63 97675199 97675137
MS Data 97675199 195350335 97675137
MS Data 195561506 3999795233 3804233728
等了一个多小时,还未扫描完,放弃.寻找更简便的放法.
由于GPT分区会在磁盘的最后34个扇区保存分区表等信息的备份,就考虑是否有一种简便方法可以将备份分区表拿过来使用.这时发现了gdisk命令.
./gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.0
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): p
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 68C0B00E-CB14-4587-9ED5-6BAE6F02D352
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4972 sectors (2.4 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 5856337920 2.7 TiB 0700 primary
2 5856339968 5860532223 2.0 GiB 0700 primary
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N):
首先gdisk [device名称]
然后p,打印出备份表,虽然磁盘头部分区表已经没了,但是p仍然可以打印出分区表,应该是备份表的作用.
最后一步 w,保存.会提示你是否开始,选Y,这时备份分区表就会重写到磁盘头部.
重启系统,磁盘恢复,大功告成.
希望这次经历会帮助到有遇到这个问题的人.