Recovering a lost partition table on a VMFS volume

ESX 3.x
To recreate the partition table:
Log in to the ESX host service console.
Type esxcfg-vmhbadevs -q and press Enter to get a list of Linux devices and their VMkernel name.
Type fdisk -l /dev/sdX and press Enter to confirm that the partition is no longer here.
Recreate the partition table:
Start fdisk with the command fdisk /dev/sdX and press Enter.
Create the partition:
Press n and press Enter to create a new partition.
Press p and press Enter to select that this is a primary partition.
Press 1 and press Enter to make the first partition.
Press Enter to keep the default value.
Press Enter again to keep the default value.

Change the partition to type fb (VMFS):
Press t and press Enter.
Press 1 and press Enter.
Enter fb and press Enter.

Align the partition to sector 128. Do not execute the realign procedure if the volume was originally created from the ESX command line or if the volume was upgraded from an ESX 2.x as the starting sector is 63, which is the default when using fdisk.

If the VMFS volume was originally created using VMware Infrastructure Client, the beginning of the partition was set to sector 128 and the alignment is required to match the beginning of the partition to where the volume used to be.

Note: Looking at other VMFS partitions with fdisk -lu in the same environment reveals if the current practice is to align the partition start to block 128 or not.

Type x and press Enter to move to expert mode.
Type b and press Enter to change the beginning of the partition.
Type 1 and press Enter to select the first partition.
Type 128 and press Enter to move to the block 128 the beginning of the partition.

Type w and press Enter to save.

Note: This exits fdisk and returns you to the command prompt.
Type vmkfstools -V and press Enter to discover the VMFS.
If the VMFS datastore is still not showing up, see A VMFS volume is not available and vmkernel reports displays the error: Device size mismatch (1003133).

Note: This procedure may not work on VMFS volumes that are participating in a spanned set (extents). Contact VMware Technical Support and work with them to resolve the issue.

ESX 4.x
Log in to the ESX host service console.
Run the command:

esxcfg-scsidevs -c

The output appears similar to:

Device UID Device Type Console Device Size Plugin Display Name
mpx.vmhba0:C0:T0:L0 Direct-Access /dev/sdb 139890MB NMP Local ServeRA Disk (mpx.vmhba0:C0:T0:L0)
mpx.vmhba3:C0:T0:L0 CD-ROM /dev/sr0 0MB NMP Local HL-DT-ST CD-ROM (mpx.vmhba3:C0:T0:L0)
naa.5005076c02045649 Enclosure Svc Dev/vmfs/devices/genscsi/naa.5005076c02045649 0MB NMP Local IBM Enclosure Svc Dev (naa.5005076c02045649)
naa.600601606a20160084afee93bce8de11 Direct-Access /dev/sdf 153600MB NMP DGC Fibre Channel Disk (naa.600601606a20160084afee93bce8de11)
naa.60060160b4111600624c5b749c7edd11 Direct-Access /dev/sda 153600MB NMP DGC Fibre Channel Disk
(naa.60060160b4111600624c5b749c7edd11)
naa.6090a038f0cd4e5bdaa8248e6856d4fe Direct-Access /dev/sde 256005MB NMP EQLOGIC iSCSI Disk
(naa.6090a038f0cd4e5bdaa8248e6856d4fe)
naa.6090a038f0cd6e5165a344460000909b Direct-Access /dev/sdd 153600MB NMP EQLOGIC iSCSI Disk
(naa.6090a038f0cd6e5165a344460000909b)

Identify the disk in question, and make note of the value under the Console Device column.
Run the command:

fdisk -l

Where is the value recorded in step 2.

The output appears similar to:

Disk /dev/sde: 268.4 GB, 268440698880 bytes
255 heads, 63 sectors/track, 32636 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sde1 1 32636 262148606 fb VMware VMFS

Start fdisk with the command following command and press Enter.

fdisk /dev/sdX
Create the partition:
Press n and press Enter to create a new partition.
Press p and press Enter to select that this is a primary partition.
Press 1 and press Enter to make the first partition.
Press Enter to keep the default value.
Press Enter again to keep the default value.
Change the partition to type fb (VMFS):
Press t and press Enter.
Press 1 and press Enter.
Enter fb and press Enter.

Align the partition to sector 128.

Caution: Do not execute the realign procedure if the volume was originally created from the ESX command line or if the volume was upgraded from ESX 2.x as the starting sector is 63, which is the default when using fdisk.If the VMFS volume was originally created using VMware Infrastructure Client, the beginning of the partition was set to sector 128 and the alignment is required to match the beginning of the partition to where the volume used to be.

Note: Looking at other VMFS partitions with fdisk -lu in the same environment reveals if the current practice is to align the partition start to block 128 or not.

Type x and press Enter to move to expert mode.
Type b and press Enter to change the beginning of the partition.
Type 1 and press Enter to select the first partition.
Type 128 and press Enter to move to the block 128 the beginning of the partition.
Type w and press Enter to save.

Note: This exits fdisk and returns you to the command prompt.

Run vmkfstools -V and press Enter to discover the VMFS.
Note: This procedure may not work on VMFS volumes that are participating in a spanned set (extents). Contact VMware Technical Support and work with them to resolve the issue.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002281

Pretty useful if your VMFS volume goes missing after a reboot!

Advertisements

Leave a comment

Filed under VMware

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s