以下是在VMware ESXi 恢復損壞或錯誤刪除的 VMFS GPT Partition Table
準備工作
啟用並登錄ESXi SSH:
https://kb.vmware.com/s/article/2004746
恢復GPT Partition Table
1. 找出需要處理Partition Table問題的Datastore:
offset="128 2048"; for dev in `esxcfg-scsidevs -l | grep "Console Device:" | awk {'print $3'}`; do disk=$dev; echo $disk; partedUtil getptbl $disk; { for i in `echo $offset`; do echo "Checking offset found at $i:"; hexdump -n4 -s $((0x100000+(512*$i))) $disk; hexdump -n4 -s $((0x1300000+(512*$i))) $disk; hexdump -C -n 128 -s $((0x130001d + (512*$i))) $disk; done; } | grep -B 1 -A 5 d00d; echo "---------------------"; done
輸出結果:
--------------------- /vmfs/devices/disks/mpx.vmhba0:C0:T1:L0 gpt 13054 255 63 209715200 1 2048 209713152 AA31E02A400F11DB9590000C2911D1B8 vmfs 0 Checking offset found at 2048: 0200000 d00d c001 0200004 1400000 f15e 2fab 1400004 0140001d 44 69 73 6b 31 00 00 00 00 00 00 00 00 00 00 00 |Disk1...........| 0140002d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| --------------------- /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0 gpt 13054 255 63 209715200 Checking offset found at 2048: 0200000 d00d c001 0200004 1400000 f15e 2fab 1400004 0140001d 44 69 73 6b 32 00 00 00 00 00 00 00 00 00 00 00 |Disk2...........| 0140002d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ---------------------
發現 Disk2 少了一行 1 2048 209713152 AA31E02A400F11DB9590000C2911D1B8 vmfs 0
2. 找出 Disk2 的 ending sector
partedUtil getUsableSectors /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0
輸出結果:
[root@localhost:~] partedUtil getUsableSectors /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0 34 209715166
209715166 就是 Disk2 的 ending sector
3. 恢復 GPT Partition Table
partedUtil setptbl /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0 gpt "1 2048 209715166 AA31E02A400F11DB9590000C2911D1B8 0"
4. 再看看需要處理Partition Table問題的Datastore:
--------------------- /vmfs/devices/disks/mpx.vmhba0:C0:T1:L0 gpt 13054 255 63 209715200 1 2048 209713152 AA31E02A400F11DB9590000C2911D1B8 vmfs 0 Checking offset found at 2048: 0200000 d00d c001 0200004 1400000 f15e 2fab 1400004 0140001d 44 69 73 6b 31 00 00 00 00 00 00 00 00 00 00 00 |Disk1...........| 0140002d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| --------------------- /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0 gpt 13054 255 63 209715200 1 2048 209715166 AA31E02A400F11DB9590000C2911D1B8 vmfs 0 Checking offset found at 2048: 0200000 d00d c001 0200004 1400000 f15e 2fab 1400004 0140001d 44 69 73 6b 32 00 00 00 00 00 00 00 00 00 00 00 |Disk2...........| 0140002d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ---------------------
發現 Disk2 也有 1 2048 209713152 AA31E02A400F11DB9590000C2911D1B8 vmfs 0
了
完成
現在可以在 Datastore 找到 Disk2 了
文章留言