March 19

VMWARE: Recreating a missing VMFS datastore partition in VMware vSphere 5.0/5.1/5.5

Recreating a missing VMFS datastore partition in VMware vSphere 5.0/5.1/5.5 (2046610)

Symptoms

  • A datastore has become inaccessible.
  • A VMFS partition table is missing.

Purpose

The partition table is required only during a rescan. This means that the datastore may become inaccessible on a host during a rescan if the VMFS partition was deleted after the last rescan. The partition table is physically located on the LUN, so all vSphere hosts that have access to this LUN can see the change has taken place. However, only the hosts that do a rescan will be affected.
This article provides information on:
  • Determining whether this is the same problem.
  • Resolving the problem.

Cause

This issue occurs because the VMFS partition can be deleted by deleting the datastore from the vSphere Client. This is prevented by the software, if the datastore is in use. It can also happen if a physical server has access to the LUN on the SAN and does an install, for example.

Resolution

To resolve this issue, you must compare partedUtil output to determine whether the partition is missing.
The first output shows the partition as intact:
# partedUtil getptbl /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011
gpt
52216 255 63 838860800
1 2048 838850039 AA31E02A400F11DB9590000C2911D1B8 vmfs 0

The second output shows the partition as missing:
# partedUtil getptbl /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011
gpt
52216 255 63 838860800

Note: This means the partition is not listed.
To recreate the partition:
  1. Find the beginning and end blocks where the VMFS partition is supposed to be. To find the beginning of the partition, copy and paste this command (one line script):

    # 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

    Note: The above script checks all of the storage devices, so the list may be lengthy. This script is not applicable for local disks.

    An example of the output::

    /vmfs/devices/disks/naa.60060160455025009839a9ed4cfee011
    msdos
    78325 255 63 1258291200
    1 128 1258291124 251 0
    Checking offset found at 128:
    0110000 d00d c001
    0110004
    1310000 f15e 2fab
    1310004
    0131001d 46 43 5f 53 68 61 72 65 64 00 45 76 65 72 5f 47 |old_VMFS3…….|
    0131002d 65 74 74 69 6e 67 5f 55 70 00 00 00 00 00 00 00 |…………….|
    ———————
    /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011
    gpt
    52216 255 63 838860800
    Checking offset found at 2048:
    0200000 d00d c001
    0200004
    1400000 f15e 2fab
    1400004
    0140001d 4a 55 50 48 41 4d 5f 53 52 4d 35 00 00 00 00 00 |new_VMFS5…….|
    0140002d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|
    ———————

    The above output has two example storage devices. The first example was created on an ESX version prior to version 5, so it reports:

    Checking offset found at 128.

    The second example was created on vSphere 5+, so it reports:

    Checking offset found at 2048.

    Note: In this example, you are using the second device, so the beginning of the partition is 2048.

  2. To get the end block for the partition, run this command:

    # partedUtil getUsableSectors /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011
    34
    838860766

    Notes:

    • If you do not get the expected output of two numbers and you get an Unknown partition table on disk error run this command to label the table as a GPT partition table:

      # partedUtil mklabel /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011 gpt

      Rerun the partedUtil getUsableSectors command, if you do not get the expected output of 2 numbers, run the partition type identification commands in the next bullet also.

    • If you do not get the expected output of two numbers and receive an error message stating partition table invalid,unable to satisfy all constraints on the partition or a similar error, run this command:

      # partedUtil setptbl /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011 gpt “1 2048 4123456
      AA31E02A400F11DB9590000C2911D1B8 0″T

      This creates a temporary partition. Once applied, the read disk information can be read, and the correct result from the above query is returned, which then allows you to calculate the correct last usable block

      The partition type identifies the purpose of a partition, and may be represented by either a decimal identifier (for example, 251) or a GUID (for example, AA31E02A400F11DB9590000C2911D1B8). See the list of commonly used partitions in the Additional Information section in Using the partedUtil command line utility on ESXi and ESX (1036609). Partitions created on ESXi 5.x and higher with the gpt disklabel must be specified using the GUID.

      The number in red indicates the last usable block, so the end of the partition cannot be any higher. It is unknown whether this was the number used when the datastore was created, so you can try it and adjust if necessary.

      With the relevant values replaced for your environment, run this command to set the correct value for last usable block:

      # partedUtil setptbl /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011 gpt “1 2048 838860766 
      AA31E02A400F11DB9590000C2911D1B8 0″

  3. Run this command to attempt to mount the VMFS datastore:

    # vmkfstools -V

    Note: If it mounts, the numbers are correct. If the numbers are correct, values do not require adjustment, so you can skip step 4.

  4. If it does not mount, you may see a message in /var/log/vmkernel.log that is similar to:

    … cpu0:44828)LVM: 2891: [naa.6006016045502500c20a2b3ccecfe011:1] Device expanded (actual size 838858719 blocks, stored size 838847992 blocks)

    In this case, add 2047 to the stored size to get the true end, … 838847992 + 2047 = 838850039

    Run the command with the new end value:

    # partedUtil setptbl /vmfs/devices/disks/naa.6006016045502500c20a2b3ccecfe011 gpt “1 2048 838850039 AA31E02A400F11DB9590000C2911D1B8 0″

    Now you have the correct partition. Run the VMFS rescan again:

    # vmkfstools -V

After the datastore is successfully mounted on one host, you can expect that the same VMFS rescan command will mount the VMFS datastore when run on other hosts that have access to this LUN.

Alternatively, you can run a full cluster rescan from the vCenter Server using the vSphere Client.

Category: Virtualization | Comments Off on VMWARE: Recreating a missing VMFS datastore partition in VMware vSphere 5.0/5.1/5.5
February 25

VMWARE: Recovering a lost partition table on a VMFS volume

 (1002281)

Details

  • A VMFS datastore is missing or inaccessible
  • The missing VMFS datastore’s LUN is still presented and detected under the host’s Configuration and Storage Adapters view in the VMware vSphere Client or VMware Infrastructure Client.
  • In the /var/log/vmkernel log file, you see one of these messages:
    • cpu0)WARNING: SCSI: 6011: SCSI IO to non-existent partition 1, np 5
    • cpu0)WARNING: SCSI: 5935: returns 0xbad0011 for vmhba0:0:68
    • cpu0:1031)LVM: 2294: Could not open device , vol [45e3ef74-706b3012-b730-000423cd, 45e3ef74-706b3012-b730-000423cd17ea, 1]: No such partition on target
    • cpu0:1031)FSS: 343: Failed with status 0xbad0012 for f530 28 1 45e3ef75 b000548 400d1b0 ea17cd23 0 0 0 0 0 0 0
    • cpu1:1039)WARNING: Vol3: 607: Couldn’t read volume header from 4816d0dd-804c9a8c-2c76-001e0beb5f56: Address temporarily unmapped

Solution

Warnings:
  • This article guides you through recreating the partition table of a LUN that has a VMFS datastore. Ensure that you are familiar with the way VMware ESX identifies disks and LUNs before proceeding. For more information, see Identifying disks when working with VMware ESX (1014953).
  • The steps outlined here are potentially hazardous for your environment if they are not followed exactly. If you are not comfortable performing these steps, contact VMware Technical Support to resolve the issue. For more information, see How to Submit a Support Request.
  • If a LUN does not have a valid partition table, it may not meet the criteria for VMware vCenter and VMware VirtualCenter’s storage filtering safeguards. Refer to your storage configuration or SAN administrator before making any changes, such as creating a VMFS datastore or Raw Device Mapping (RDM), adding an extent, or increasing a VMFS datastore.

ESX 4.x

To recreate the partition table:

  1. Log in to the ESX host service console. For ESXi, see Tech Support Mode for Emergency Support (1003677).
  2. Run the command:

    esxcfg-scsidevs -c

    The output appears similar to:

    Device UID                            Device Type      Console Device                                            Size      Plugin  Display Name
    mpx.vmhba32:C0:T0:L0                  CD-ROM           /dev/sr0                                                  0MB       NMP     Local USB CD-ROM (mpx.vmhba32:C0:T0:L0)
    mpx.vmhba3:C0:T0:L0                   CD-ROM           /dev/sr1                                                  0MB       NMP     Local PLDS CD-ROM (mpx.vmhba3:C0:T0:L0)
    naa.50060160bce0383c50060160bce0383c  Direct-Access    /dev/sdj                                                  0MB       NMP     DGC Fibre Channel Disk (naa.50060160bce0383c50060160bce0383c)
    naa.60024e8056ca2100119f56f605695091  Direct-Access    /dev/sdk                                                  139392MB  NMP     Local DELL Disk (naa.60024e8056ca2100119f56f605695091)
    naa.6006016045502500d0c748a4198bde11  Direct-Access    /dev/sdh                                                  512000MB  NMP     DGC Fibre Channel Disk (naa.6006016045502500d0c748a4198bde11)
    naa.6006016045502500ec34346d188bde11  Direct-Access    /dev/sdi                                                  512000MB  NMP     DGC Fibre Channel Disk (naa.6006016045502500ec34346d188bde11)
    naa.60060160d2ed18012eea2d1ce42ddf11  Direct-Access    /dev/sdn                                                  819200MB  NMP     DGC iSCSI Disk (naa.60060160d2ed18012eea2d1ce42ddf11)
    naa.60060160d2ed180176d68215e42ddf11  Direct-Access    /dev/sdo                                                  819200MB  NMP     abcDGC iSCSI Disk (naa.60060160d2ed180176d68215e42ddf11)
    naa.60060160d2ed18017ea10024e42ddf11  Direct-Access    /dev/sdm                                                  819200MB  NMP     DGC iSCSI Disk (naa.60060160d2ed18017ea10024e42ddf11)
    naa.60060160d2ed180190df110ee42ddf11  Direct-Access    /dev/sdp                                                  819200MB  NMP     logical
    naa.600a0b80002666d40000000000000000  Direct-Access    /vmfs/devices/disks/naa.600a0b80002666d40000000000000000  20MB      NMP     IBM Fibre Channel Disk (naa.600a0b80002666d40000000000000000)
    naa.600a0b80002666d400003a0a4b99f95c  Direct-Access    /dev/sdd                                                  102400MB  NMP     IBM Fibre Channel Disk (naa.600a0b80002666d400003a0a4b99f95c)
    naa.600a0b80002666d400003a114b99f9b4  Direct-Access    /dev/sdc                                                  102400MB  NMP     IBM Fibre Channel Disk (naa.600a0b80002666d400003a114b99f9b4)
    naa.600a0b80002666d400003a184b99f9ee  Direct-Access    /dev/sdb                                                  102400MB  NMP     IBM Fibre Channel Disk (naa.600a0b80002666d400003a184b99f9ee)
    naa.600a0b80002901aa0000000000000000  Direct-Access    /vmfs/devices/disks/naa.600a0b80002901aa0000000000000000  20MB      NMP     IBM Fibre Channel Disk (naa.600a0b80002901aa0000000000000000)
    naa.600a0b80002901aa0000a11b4a3b51ad  Direct-Access    /dev/sdg                                                  102400MB  NMP     IBM Fibre Channel Disk (naa.600a0b80002901aa0000a11b4a3b51ad)
    naa.600a0b80002901aa0000a1214a3b51ef  Direct-Access    /dev/sdf                                                  81920MB   NMP     IBM Fibre Channel Disk (naa.600a0b80002901aa0000a1214a3b51ef)
    naa.600a0b80002901aa0000a1274a3b5231  Direct-Access    /dev/sde                                                  71680MB   NMP     IBM Fibre Channel Disk (naa.600a0b80002901aa0000a1274a3b5231)
    naa.600a0b80002901aa0000a3774b99f77d  Direct-Access    /dev/sda                                                  102400MB  NMP     IBM Fibre Channel Disk (naa.600a0b80002901aa0000a3774b99f77d)

  3. Identify the disk in question, and note the value under the Console Device column.

    Note: There are no Linux console device names in ESXi. In ESXi you use the NAAs, for example: /vmfs/devices/disks/naa.600a0b80002666d40000000000000000.

    If you need to map an NAA ID to a VMFS datastore name use the following command:

    esxcfg-scsidevs -m

  4. Run the command:

    fdisk -l <dev>

    Where <dev> 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

  5. Start fdisk with this command and press Enter.

    fdisk -u <dev>

    Where <dev> is the value recorded in step 2.

  6. Create the partition:
    1. Press n and press Enter to create a new partition.
    2. Press p and press Enter to select that this is a primary partition.
    3. Press 1 and press Enter to make the first partition.
    4. Press 128 and Enter to  align the partition to sector 128.
    5. Press Enter again to retain the default value.
    6. Change the partition to type fb (VMFS):
      1. Press t and press Enter. Partition 1 is automatically selected.
      2. Enter fb and press Enter.
  7. Press w and press Enter to save.
  8. Run vmkfstools -V and press Enter to discover the VMFS.

ESX 3.x

To recreate the partition table:
  1. Log in to the ESX host service console. For ESXi, see Tech Support Mode for Emergency Support (1003677).
  2. Type esxcfg-vmhbadevs -q and press Enter to get a list of Linux devices and their VMkernel name.
  3. Type fdisk -lu /dev/sdX and press Enter to confirm that the partition is no longer here.
  4. Recreate the partition table:
    1. Start fdisk with the command fdisk -u /dev/sdX and press Enter.
    2. Create the partition:
      1. Press n and press Enter to create a new partition.
      2. Press p and press Enter to select that this is a primary partition.
      3. Press 1 and press Enter to make the first partition.
      4. Press 128 and press Enter to align the partition to sector 128.

        Note
        : If the volume was upgraded from an ESX 2.x , the partition should be aligned to 63, which is the default when using fdisk.

      5. Press Enter to retain the default value.

    3. Change the partition to type fb (VMFS):
      1. Press t and press Enter. Partition 1 is automatically selected.
      2. Enter fb and press Enter.

    4. Type w and press Enter to save. This command exits fdisk and returns you to the command prompt.

  5. Type vmkfstools -V and press Enter to discover the VMFS.

ESX 2.x

To recreate the partition table:
  1. Log in to the ESX host service console.
  2. Typevmkpcidivy -q vmhba_devsand press Enter to get a list of Linux devices and their VMkernel name.
  3. Typefdisk -l /dev/sdXand press Enter to confirm that the partition is no longer here.
  4. Recreate the partition table:
    1. Start fdisk with the commandfdisk /dev/sdXand press Enter.
    2. Create the partition:
      1. Type n and press Enter to create a new partition.
      2. Type p and press Enter to create a primary partition.
      3. Type 1 and press Enter to create the first partition.
      4. Press Enter to keep the default value.
      5. Press Enter to keep the default value.

    3. Change the partition to type fb (VMFS):
      1. Type t and press Enter to change the type of partition.
      2. Type fb and press Enter to set the partition as VMFS.

    4. Type w and press Enter to save.
      This command will exit fdisk and returns you to the command prompt.

  5. Typevmkfstools -Vand 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.
By: VMWARE
Category: Virtualization | Comments Off on VMWARE: Recovering a lost partition table on a VMFS volume
July 8

VMWARE: Removing old hardware from Windows after a P2V conversion

1. Open a Windows command prompt and type the following:

set devmgr_show_nonpresent_devices=1

This sets an environment variable that tells the device manager to show all non-present devices.

2. At the same command prompt, type

devmgmt.msc

…which launches the device manager application. Do not try and launch it through the graphical user interface (GUI) instead as the environment variable set in step one only applies to commands run inside the command prompt.

3. Once the device manager window opens, select View from the top menu, and then Show Hidden Devices.

4. If you expand the device categories you will see both present and non-present devices. The non-present devices are shown by the grayed-out icons next to the device names. You can remove them by right-clicking on them and selecting Uninstall. Unfortunately you have to do this one by one as you can not select multiple devices. Click OK at the warning message that appears. If you accidentally delete a device that is present, don’t panic — once you reboot, Windows will automatically install the device driver for it again.

By: E. Siebert

Category: Virtualization | Comments Off on VMWARE: Removing old hardware from Windows after a P2V conversion
March 11

VMWARE: Cannot delete a datastore from virtual center

Configuring an ESX host fails with the error: DestroyVmfsDatastore: can’t delete partition 1 on lun naa.5000cca216d1588 (1017104)
Symptoms

Unable to configure the ESX host
You see the error:

Error during the configuration of the host:DestroyVmfsDatastore: can’t delete partition 1 on lun naa.5000cca216d1588

A direct session to the ESX host does not resolve this issue

Resolution
This issue occurs if you are unable to delete the datastore of the ESX host.

To work around this issue, you must delete the partition from the command line.

To delete the partition:

Connect to the ESX host using an SSH session or ILO/DRAC.

Note: To access the command line on an ESXi host, you must enable Tech Support Mode. For more information, see Tech Support Mode for Emergency Support (1003677).

Warning: Tech Support Mode should only be used at the request of VMware technical support.

Run the command:

fdisk /vmfs/devices/disks/naa.<number>

Note: In this command, <number> is the NAA number displayed in the error message.
Press d.
Select partition 1.
Press w. You see the message:

The partition table has been altered!

Refresh the vmfs by running the following command in the SSH or ILO session:

vmkfstools –V

Refresh the VMware Infrastructure Client GUI.

VMWARE KB: 1017104

Category: Virtualization | Comments Off on VMWARE: Cannot delete a datastore from virtual center
December 6

VMWARE: Extending a logical volume in a virtual machine running Red Hat or Cent OS

Purpose

This article provides steps for extending the root partition residing in a logical volume created with Logical Volume Manager (LVM) in a virtual machine running Red Hat/Cent OS.

Resolution

To extend the logical volume:
Note: These steps only apply to EXT3 file systems.
Caution: VMware recommends having a complete backup of the virtual machine prior making these changes.

1. Power off the virtual machine.

2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047) (http://kb.vmware.com/kb/1004047) .

3. Power on the virtual machine.

4. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:
fdisk -l

5. Create a new primary partition:
a. Run the command:
fdisk /dev/sda (depending the results of the step 4)
b. Press p to print the partition table to identify the number of partitions.
By default there are 2: sda1 and sda2.
c. Press n to create a new primary partition.
d. Press p for primary.
e. Press 3 for the partition number, depending the output of the partition table print.
f. Press Enter two times.
g. Press w to write the changes to the partition table.

6. Restart the virtual machine.

7. Run this command to verify that the changes were saved to the partition table and that the new partition has an 83 type:
fdisk -l

8. Run this command to convert the new partition to a physical volume: pvcreate /dev/sda3

9. Run this command to extend the physical volume: vgextend VolGroup00 /dev/sda3

10. Run this command to verify how many physical extents are available to the Volume Group: vgdisplay VolGroup00 | grep “Free”

11. Run the following command to extend the Logical Volume: lvextend -L+#G /dev/VolGroup00/LogVol00 Where # is the number of Free space in GB available as per the previous command.
or
Run the following command to extend the Logical Volume: lvextend -l+#freeextents /dev/VolGroup00/LogVol00 Where # is the number of Free extents available as per the previous command.

12. Run the following command to expand the ext3 filesystem online, inside of the Logical Volume: ext2online /dev/VolGroup00/LogVol00
Note: Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.

13. Run the following command to verify that the / filesystem has the new space available: df -h /

By: VMWARE KB

Category: Virtualization | Comments Off on VMWARE: Extending a logical volume in a virtual machine running Red Hat or Cent OS