I am working on my PowerShell module for Pure/VMware operations and one of the cmdlets I am writing is for growing a VMFS. When perusing the internet, I could not find a lot of direct information on how to actually do this. There is not a default cmdlet for doing this. Read on to learn more about VMFS datastore.

The illustrious Luc Dekens talks about this problem here and even provides a great module for doing this:

If you just need want to run a quick script you can use that. If you want to write it yourself here is a quick overview of what you need to do. I am talking about a specific use case of:

  • I have a datastore on one extent and that extent exists on a LUN (or device or volume or whatever you want to call it) on an array. That LUN has been grown on the array.
  • I want to grow the VMFS  to use the new capacity and not create a new extent, just grow it.

This is generally the most common use case and is what I recommend customers to do. Luc’s script covers a lot more use cases so there is a lot more code in there that you won’t need for this situation. So let me boil down the PowerCLI to the basics.

I have a datastore called CodyVMFS and it is 4 TB in size:

The underlying device is 4 TB too:

Now I resize the volume on the array itself, you can of course use PowerShell to do this, but I will use the GUI for clarity:

After a rescan, by looking in VMware you can see the underlying device is now 8 TB:

VMFS datastore

So now we have a 4 TB VMFS that sits on a 8 TB volume. So let’s use PowerCLI to expand the datastore to use the full 8 TB.

After connecting to vCenter, use get-datastore to get the datastore object.

Then you need to access the host datastore system. Since there is not direct cmdlet for this, we need to access the extension data of the host to run the methods directly. So, I grab a host object that has access to that datastore:

Then I need to grab the datastore system from that host:

The next step is to query the datastore for the specification that is needed to expand it to the new space. There is a simply method you can run to have ESXi build this for you automatically. Run it from $datastoreSystem and pass in the MoRef of the datastore like so:

Now pass the “spec” parameter and the datastore MoRef to another method to expand it:

This will expand the VMFS!

Pretty simple.

The whole script process is below:

The last line returns the expanded datastore object: