Friday, March 28, 2014

Format a ESX & ESXi VMFS file system manually

Here you can find a excellent post from GK_RAJ that explains how to reformat a VMFS filesystem from console.

And this is his post:

Recently I came across a query in the VMware communities, the query was “How to reformat a VMFS file system or Datastore manuallly”

The preferred method of reformat the VMFS file system is from a console or SSH session as you can simply recreate the file system without having to make any changes to the disk partition.

Note: All data on a VMFS volume is lost when the datastore is recreated. Migrate or move all virtual machines and other data to another datastore. Back up all data before proceeding.
Note: This procedure should not be performed on a local datastore on an ESX host where the Operating System is located as it may remove the Service Console privileged virtual machine which is located there.

From the ESX/ESXi console:

Use the vmkfstools command to format the VMFS-5 or VMFS-3 datastore (Partition), specifying a Block Size of 1 to 8MB, a friendly name for the datastore, and the chosen disk device and the created partition.

vmkfstools -C vmfs3 -b BlockSize -S DatastoreVolumeName /vmfs/devices/disks/ DeviceName:Partition

vmkfstools -C vmfs5 -b BlockSize -S DatastoreVolumeName /vmfs/devices/disks/ DeviceName:Partition

STEPS:

1, Storage vMotion, or move the virtual machines located on the datastore you would like to re format.

2, Log in to the Local Tech Support Mode console of the ESX/ESXi host. For more information, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807), Tech Support Mode for Emergency Support (1003677), or Using Tech Support Mode in ESXi 4.1 and ESXi 5.0 (1017910).

3, Use the esxcfg-scsidevs command to obtain the disk identifier (mpx or naa) for the datastore you want to re format.
# esxcfg-scsidevs –m

clip_image002[6]

4, Use vmkfstools to create a new VMFS datastore file system with the corresponding block size.

Note: vSphere 5.0 and later releases have a block size of 1MB only. For ESX/ESXi in Vsphere 4 it is from 1MB to 8MB

# vmkfstools -C VMFS-type -b Block-Size -S Datastore-Name /vmfs/devices/disks/Disk-Identifier:Partition-Number

For Vsphere 5x
vmkfstools -C vmfs5 –b 1m -S Storage1 /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0:3

For Vsphere 4x
vmkfstools -C vmfs3 –b 8m -S Storage1 /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0:3

clip_image004[4]

5, Performing a rescan of the storage on an ESX/ESXi host

Using the ESXi 5.x

To rescan all HBAs:
esxcli storage core adapter rescan –all

To rescan a specific HBA:
esxcli storage core adapter rescan –adapter <vmkernel SCSI adapter name>

Where <vmkernel SCSI adapter name> is the vmhba# to be rescanned. To get a list of all adapters, run the esxcli storage core adapter list command.

OR

esxcfg-rescan <vmkernel SCSI adapter name>

esxcfg-rescan –all

Where <vmkernel SCSI adapter name> is the vmhba# to be rescanned.

In Vsphere 4x

esxcfg-rescan <vmkernel SCSI adapter name>

esxcfg-rescan –all

Where <vmkernel SCSI adapter name> is the vmhba# to be rescanned.

Or simply in Vsphere 4x and 5x

To search for new VMFS datastores, run this command:
vmkfstools –V

Note: This command does not generate any output.

No comments:

Post a Comment