Home VMware How to Recreate a Missing VMFS Partition in vSphere 5

How to Recreate a Missing VMFS Partition in vSphere 5

by admin

I’ve been posting a few articles on using partedUtil and vmkfstools as part of my VCAP-DCA studies. One of the articles I’ve come across a few times is this one regarding recovering a VMFS partition. Fortunately, this isn’t something I’ve had to go through in a production environment, however I was keen to try out the process.

We’ll start with a VMFS volume called TestVOL:

/vmfs/volumes # vmkfstools --queryfs /vmfs/volumes/TestVOL
VMFS-5.54 file system spanning 1 partitions.
File system label (if any): TestVOL
Mode: public
Capacity 5100273664 (4864 file blocks * 1048576), 4352638976 (4151 blocks) avail
UUID: 4ff9dae8-858c7e95-12f0-000c29e8410a
Partitions spanned (on "lvm"):
        mpx.vmhba1:C0:T2:L0:1
Is Native Snapshot Capable: NO

Next, I’ll delete this VMFS datastore using the vSphere client. Running the same command now shows the following:

/vmfs/volumes # vmkfstools --queryfs /vmfs/volumes/TestVOL
Could not open /vmfs/volumes/TestVOL
Error: No such file or directory

Running partedUtil against the disk where this device was located also shows the partition to be missing:

/vmfs/volumes # partedUtil getptbl /vmfs/devices/disks/mpx.vmhba1:C0:T2:L0
gpt
652 255 63 10485760

We can use this output to work out the end sector we will need to specify when recreating the partition. This is calculated by multiplying the values displayed (652*255*63-1 = 10474379). You can see more about calculating this value in this post.

As directed in the VMware article, we need to run the following:

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

This will show us information about all the disks connected to the host. Scroll through til you see the information relating to the disk we are interested in. The output will be similar to:

/vmfs/devices/disks/mpx.vmhba1:C0:T2:L0
gpt
652 255 63 10485760
Checking offset found at 2048:
0200000 d00d c001
0200004
1400000 f15e 2fab
1400004
0140001d  54 65 73 74 56 4f 4c 00  00 00 00 00 00 00 00 00  |TestVOL.........|
0140002d  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
---------------------

The bit we are interested in is the offset which, in this case as it is VMFS 5, is 2048. This is our starting sector.

Next, we need to know the partition GUID for a VMFS volume. This can be seen by running:

/vmfs/volumes # partedUtil showGuids
 Partition Type       GUID
 vmfs                 AA31E02A400F11DB9590000C2911D1B8
 vmkDiagnostic        9D27538040AD11DBBF97000C2911D1B8
 VMware Reserved      9198EFFC31C011DB8F78000C2911D1B8
 Basic Data           EBD0A0A2B9E5443387C068B6B72699C7
 Linux Swap           0657FD6DA4AB43C484E50933C84B4F4F
 Linux Lvm            E6D6D379F50744C2A23C238F2A3DF928
 Linux Raid           A19D880F05FC4D3BA006743F0F84911E
 Efi System           C12A7328F81F11D2BA4B00A0C93EC93B
 Microsoft Reserved   E3C9E3160B5C4DB8817DF92DF00215AE
 Unused Entry         00000000000000000000000000000000

Now we are ready to recreate the partition. To do so, run the following command, specifying the values we have learned so far:

/vmfs/volumes # partedUtil setptbl /vmfs/devices/disks/mpx.vmhba1:C0:T2:L0 gpt "1 2048 10474379 AA31E02A400F11DB9590000C2911D1B8 0"
gpt
0 0 0 0
1 2048 10474379 AA31E02A400F11DB9590000C2911D1B8 0

Performing a rescan in the vSphere client at this point should show that our datastore is available, although it will need to be mounted.

vmfs_recreate_partition

As ever, use caution when using partedUtil. These steps were carried out in a test environment. If in doubt, always call VMware support first!!

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More