The outline of the process is the following:
1. Identify the device name that represents the affected LUN.
i. List the VMFS datastores and their associated device names
esxcli storage vmfs extent list
ii. List all devices on this host
iii. To verify that you located the affected device, you can run fdisk -lu to list its partition table.
Note: What If the Datastore Has Extents? using vmkfstools -P /vmfs/volume/<volume-name>
2. Locate the LVM header offset.
The LVM header offset would show d00d c001 as the first 4 bytes. The following 2 bytes show the major VMFS version. In this example it is 0003, which means that this volume was VMFS3 version. If it were VMFS5, the value would have been 0005.
Based on the dump shown above, the LVM header offset is at 0200000 address.
3. Calculate the partition offset.
Now, let’s use the LVM header offset to count backward 1MB, which is how far it lies from the partition offset:
i. Convert the LVM header offset value from hex to decimal:
0200000 Hex = 2097152 Decimal
ii. Convert the byte count to sectors (divide by 512, which is the sector size):
2097152 / 512 = 4096 sectors
iii. Subtract the number of sectors that add up to 1MB (2048 sectors of 512 bytes each):
4096–2048 = 2048
This means that the partition starts at sector 2048.
4. re-create partition table
a. Use fdisk to re-create the partition table for VMFS3
fdisk -u /dev/disks/naa.6006016055711d00cff95e65664ee011
b. Use partedUtil to re-create the partition table for VMFS5
a healthy gpt VMFS5 partition table:
partedUtil setptbl "/dev/disks/<DeviceName>" DiskLabel "partNum startSector endSector type/guid attribute"
Required parameters:
i.DeviceName: useing NAA ID, see step 1
ii.DiskLabel: must be gpt
iii.partNum: is always 1
iv.startSector: the value you get from step 3
v.endSector: total sector subtract 34, using "partedUtil get /dev/disks/<device-ID>" or "fdisk -lu /dev/disks/<device-ID>" to get total sector
vi.GUID: using "partedUtil showGuids" for vmfs type
vii.attibute: is always 0
example: partedUtil setptbl "/dev/disks/naa.6006016055711d00cff95e65664ee011" gpt "1 2048 20971486 AA31E02A400F11DB9590000C2911D1B8 0"
5. Mount the datastore.
To mount the VMFS datastore, rescan the device for VMFS datastore by running
vmkfstool -V
To verify if the datastore was mounted successfully, check the content of /vmfs/volumes directory using
ls /vmfs/volume