Linux下GPT分区,gdisk修复损坏的分区表

   今天在使用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,这时备份分区表就会重写到磁盘头部.

重启系统,磁盘恢复,大功告成.

希望这次经历会帮助到有遇到这个问题的人.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值