Wednesday, July 10, 2013

Recovering lost partition table on a VMFS

It’s just a procedure tried and worked
So I can’t assure 100% guarantee and it’s just an experimental procedure to recover latest vmfs 5.0.
Steps I tried to experiment the same.
  • Created two 4GB iSCSI LUN and presented to ESXi 5.0.
    • From vSphere Client create a datastore from first 4 GB LUN.
    • Create a TestVM on this new datastore; remove the VM from the vCenter inventory and then delete the datastore.
Since we know that LUN was presented of 4 GB size and added to ESXi as a datastore,  even after deleting the datastore from ESXi it will have data but partition table is deleted (as long as datastore not formatted).
1)      For Recovering the datastore that was deleted followed below steps.
  • Create a new datastore 4 GB using the second LUN in ESXi using vSphere client.
  • Find the device id name under “/vmfs/devices/disks” as below
“/vmfs/devices/disks/t10.945445000000000006A5E78EBFE3E80752D80A61917785A87” ——– datastore
“/vmfs/devices/disks/t10. 945445000000000006A5E78EBFE3E80752D80A61917785A87:1” —— partition.
2)      After finding the new datastore Device id, execute to find geometry of the datastore as below using partedUtil on datastore and partition.
Make a SSH connection to your ESXi host run the following command:
~ # partedUtil get /vmfs/devices/disks/945445000000000006A5E78EBFE3E80752D80A61917785A87\:1 <Enter>
521 255 63 8383882
~ # partedUtil get /vmfs/devices/disks/945445000000000006A5E78EBFE3E80752D80A61917785A87 <Enter>
522 255 63 8388608
1 2048 8385929 0 0
So as shown above “1—partition number, 2048—vmfs 5.0 starting sector, 8388608— ending sector”
Now we have geometry of 4GB datastore as shown above.
3)    Now we need to detect the old datastore which was deleted and which doesn’t have partition on it under “/vmfs/devices/disks/”
4)   Once we found the device id and we have geometry of 4GB datastore as “1 2048 8385929 0 0” we can execute partedUtil to recreate partition and mount the datastore on ESXi as follows.

~#partedUtil setptbl  ”/vmfs/devices/disks/ t10.9454450000000000CA31402955A7D419F31EFDA042B1986E ” gpt “1 2048 8385929 AA31E02A400F11DB9590000C2911D1B8 0″
Output:
gpt
0 0 0 0
1 2048 8385929 AA31E02A400F11DB9590000C2911D1B8 0
Whereas “AA31E02A400F11DB9590000C2911D1B8”—standard id for vmfs tag 0xfb
5)       Finally we have recreated the partition for the old datastore which was missing and now go to ESXi connected via vSphere client and refresh the datastore and mount the previous datastore.
6)      Browse the datastore the TestVM is existing there.
Conclusion: whenever we delete the VMFS from vSphere client GUI datastore data is not delete but the partition table is deleted.

    

0 comments:

Post a Comment