VMFS Datastores – Expand and Extend

We all know, and love, PowerCLI‘s New-Datastore and Set-Datastore cmdlets to create and manipulate VMFS datastores. But when we look at the functionality available through the Web Client, there is one interesting feature for manipulating VMFS datastores that is missing from the PowerCLI cmdlets. The Increase button, which allows us to Expand or Extend an existing VMFS datastore*.

Recently there were a couple of threads on this subject in the VMTN PowerCLI Community, so I decided to streamline my quick-and-dirty scripts into something more presentable, and create a PowerShell module to bundle the functions. I present the VMFSIncrease module!
The VMFSIncrease module will also be my first contribution to the PowerCLI Community Repository! More on that further on in this post.

* The expand and extend functions for a VMFS datastore depend on the availability of free space on the VMFS datastore extents and/or the availability of free LUNs

The Increase button

The Increase button in fact offers two different methods to increase the size of a datastore. The definitions of two methods according to the

Expand: increases the capacity of an existing VMFS datastore by expanding (increasing the size of) an existing extent of the datastore

Extend: Increases the capacity of an existing VMFS datastore by adding new extents to the datastore

Perhaps the following schematic makes it a bit more clear.

The schematic shows a VMFS datastore with one extent, on LUN A. If we want to increase the Used capacity, we can do an Expand, on the same extent (LUN A). Or we can do an Extend on a new LUN, in this case LUN B.In the case of the Extend, the VMFS datastore will now have two extents, LUN A and LUN B.

Note that for the Expand and the Extent you do not need to use all of the free space. The following is perfectly possible.

The Increase button presents the user with a series of candidate LUNs. The Expand and Extend candidate LUNs are intermixed in that list. The underlying API method makes sure that the LUNs are not already used by another datastore or by a RDM disk.

The Module

Sample runs

Reporting

The Get-VmfsDatastoreInfo displays basic information about the extents and the partitions that make up the datastore.

PowerShell

1

Get-VmfsDatastoreInfo-DatastoreTestDS

This produces something like this

The Datastore lives on one extent, and on that extent there are three partitions. The partition marked with (2) is the part where the VMFS Datastore lives. Part (3) is the free space, and part (1) is for alignment.

To check how we can increase the capacity of the Datastore, we can run

PowerShell

1

Get-VmfsDatastoreIncrease-DatastoreTestDS

This returns something like this

The returned information shows that there are two options to increase the capacity of the Datastore. In (1) we see that we can Expand the extent by 80GB. In (2) we see that we can Extend the capacity by 100GB by adding a new extent to the Datastore.

Expand

The Help page for the New-VmfsDatastoreIncrease function already contains several examples on how to use the function. But to give you an idea what is possible, just a few examples.

We have the possibility to add up to 80GB. If we don’t specify a size, all the free space on the extent is used.

PowerShell

1

New-VmfsDatastoreIncrease-Datastore'TestDS'-Expand

If we do specify how much we want to increase the capacity, only that specific amount of space from the free space will be taken.

PowerShell

1

New-VmfsDatastoreIncrease-Datastore'TestDS'-Expand-IncreaseSizeGB25

If we have a Datastore that spans more than one extent, we can, through the Canonicalname parameter, indicate on which extent the increase shall be taken.

Interesting to note, if you don’t specify a LUN, through the Canonicalname parameter, the function will order the available LUNs alphanumerically on their Canonicalname, and take the first one. So the following is perfectly possible, provided of course there are free LUNs available.

PowerShell

1

New-VmfsDatastoreIncrease-Datastore'TestDS'-Extend

And, as with the Expand option, you do not need to use all of the available space with the Extend option. You can control how much space is taken through the IncreaseSizeGB parameter.

The option is also available without specifying a LUN. The function uses the same logic as was mentioned before, it will order the available LUNs alphanumerically on their Canonicalname, and take the first one.