FeedBurner

Enter your email address:


Visitors

Today:7
This month:1226
This year:2868
Total:23935

Online

We have 5 guests online
Creating and managing VMFS volumes on ESX hosts PDF Print E-mail
( 0 Votes )
Written by Cristian Ciobanu   
Tuesday, 29 March 2011 20:13

Vmware

Introduction



VMFS (Virtual Machine File System) is a proprietary high-performance cluster file system used on Vmware ESX servers to store virtual machines, ISO files and templates. VMFS comes in 3 versions. The last version VMFS-3 has introduced an important enhacement by adding directory structure in the filesystem. It has also some limitations regarding the file size which depends on the block size. So for a block size of 1MB you can have a maximum file size of 256GB. The maximum values for the block size and file size are 8MB respectively 2TB. ESX 3.x and higher allows up to 32 ESX hosts to be shared on a VMFS file system. Since VMFS is a journaling filesystem when a crash occurs, it does not run a full fsck on the volume, but merely checks the journal. A VMFS volume is used as a datastore to hold all of the files needed by virtual machines. In this article we will discuss only the command line management tools for VMFS although you can do this by using the vSphere client.

Creating a VMFS volume

Since we are using the command line method to create a VMFS volume you need to have physical access to the console or have SSH enabled on the ESX host. Before you start creating a new VMFS volume you must have some empty space (a disk or partition) preferably. For creating new partitions Vmware provides the fdisk utility which is available on most operating systems. First check the available disks by typing the following command:

#fdisk -l

Next we must create the partition where the VMFS file system will reside. For the purpose of this example we will use the /dev/sdb device. Enter into the command line mode of the fdisk utility:

#fdisk /dev/sdb

Type 'n' to specify that you want to create a new partition then choose 'p' to specify partition type (primary in this case). Next you must type the partition number '1' in my case because the disk is empty. Specify the partition start and end block. If you are using the entire disk you can press Enter for the defaults, otherwise type your desired values. Press 't' key to specify the partition type. Here type 'fb' which indicates a Vmware VMFS partition type.

If the new volume is not the first partition you must manually align the partition to improve throughput. If the start value is 63, which is the default, the partition is not aligned. To do this at the fdisk console type 'x' to enter expert mode then type '1' to select the partition and then type 128 to set the partition position using a 64K boundary.

 At last type 'w' to commit these changes to the disk and exit fdisk utility.

Now that our partition is created it's time to add the file system on it. For this Vmware provides the vmkfstools utility which allows you to create a VMFS filesystem on the partition. The syntax for this command is a little different depending on the ESX version. If you are using ESX 3.X run the following command:

#vmkfstools -C vmfs3 -b <Block_Size> -S <VMFS_Name> vmhba<C>:<T>:<L>:<P>

For ESX 4.x run the following command:

#vmkfstools -C vmfs3 -b <Block_Size> -S <VMFS_Name> vmhbaX:hba:scsi_target:scsi_lun:disk_partition

As an example let's create a VMFS volume on a ESX 4 host using a block size of 8MB:

#vmkfstools -C vmfs3 -b 8m -S DataStore2 /vmfs/devices/disks/mpx.vmhba0:C0:T1:L0:1

The parameters in the above example have the following meanings

  • -C - specifies which type of VMFS volume to create in our case VMFS version 3
  • -b - specifies the block size used for the VMFS volume
  • -S - specifies the label for your volume

The last option vmhba0:C0:T1:L0:1 specifies the target device in our case the first HBA (C0) connected to the second storage processor (T1) using the LUN 0 (L0), and the volume (or partition) is the first (1). You can display the HBA mappings in ESX 4.x using the following command:

#esxcfg-scsidevs -m

Remember that you cannot change the block size after you created the volume. If you need to do this you must backup your data and recreate the VMFS volume. Now that our VMFS volume is created you can log on to the ESX host using the vSphere client and see the newly available Datastore.

Displaying VMFS metadata

The VMFS metadata is stored in files with the .sf extension in the root of the VMFS volume. This metadata keeps all hosts with access to the datastore informed of the current status of any object on the datastore. Metadata contains certain filesystem descriptors such as:

  • Block Size
  • Number of Extents
  • Volume Capacity
  • VMFS Version
  • Volume Label
  • VMFS UUID

If you want to display all this information you can use the vmkfstools command with the below parameters.

#vmkfstools -P -h pathname

The -P option allows you to query the metadata information, while the -h option tells the vmkfstools command to display the information in human readable form using units like MB, KB, or GB instead of the default bytes. The pathname indicates the location of your VMFS filesystem. As a practical example let's display the metadata information of our newly created VMFS volume:

#vmkfstools -P -h /vmfs/devices/disks/mpx.vmhba0:C0:T1:L0:1
VMFS-3.46 file system spanning 1 partitions.
File system label (if any): Datastore2
Mode: public
Capacity 40G, 39.28G available, file block size 8.0M
UUID: 4d8d1124-6d89bc36-4448-000c2922088e
Partitions spanned (on "lvm"):
vmhba0:C0:T1:L0:1

Extending a VMFS Volume

Sometimes arises the need to increase the size of an existing VFMS volume for example to host more virtual machines. If you have some free space on a disk or even a spare disk you can extend the volume to comprise this free space. An extended VMFS volume can have at most 32 physical extents. An extent is either a primary partition, or a logical partition within an extended partition. The command syntax is as follows:

#vmkfstools -Z vmfs/devices/disks/vml.<vml2_ID>:1 vmfs/devices/disks/vml.<vml1_ID>:1

First you must specify the new volume to be added (vml.<vml2_ID:1>) and the second is the existing VMFS volume (vml.<vml1_ID:1>).

For the practical example I have added another disk /dev/sdd which was initialized as a VMFS partition. This new volume (vmhba0:C0:T2:L0:1) will be added to the existing VMFS volume (vmhba0:C0:T1:L0:1). Remember that you have to specify the full path for each volume like /vmfs/devices/disks/<volume_name> not only its name.

#vmkfstools -Z /vmfs/devices/disks/mpx.vmhba0:C0:T2:L0:1 /vmfs/devices/disks/mpx.vmhba0:C0:T1:L0:1

When running this command you will be asked to confirm that the data on the new volume will be destroyed before expanding. Press '0' to agree. After this if you access the ESX host using the vSphere client you will see the new size of the Datastore.

Renaming a VMFS Datastore

If you need to change the label assigned to a VMFS Datastore you must find the UUID assigned to the VMFS volume you wish to rename. For this use one of the following two commands:

#vmkfstools -P datastorename
#ls -al /vmfs/volumes

To rename the VMFS volume you need to use the ln command along with the found UUID

#ln -sf /vmfs/volumes/UUID /vmfs/volumes/new_volume_name

First we must specify the UUID of the volume and then the new name which will be assigned to it. The '-s' option creates a symbolic link and the '-f' option is used to overwrite the existing destination files. Once the operation is complete you need to restart the management services using the following command:

#service mgmt-vmware restart

Conclusion

VMFS provides the capabilities that allow virtual machines to scale beyond the limits of a single server without downtime. It also improves resource utilization and lowers the management overhead for storage administration in a virtual environment. The vmkfstools utility presented here is very powerful and also offers many options for managing virtual disks but this will be will discussed in a future article.

Share this post

Last Updated on Tuesday, 29 March 2011 20:19
 

Add comment


Security code
Refresh

Copyright © 2011 Ciobanu Cristian - www.cioby.ro