Adding NFS storage using the command line interface (CLI) with esxcfg and PowerCLI

In this example I will look at creating an NFS datastore using both esxcfg command line interface and PowerCLI to which I will use the following parameters.

  • Datastore Name: openfiler-nfs2
  • NFS Host:
  • NFS mount point: /mnt/nfs/nfs2/vmfs/

By connecting to an ESXi hosts console session we can invoke the esxcfg command line interface to create the new NFS datastore by invoking the esxcfg-nas switch.

esxcfg-nas -a openfiler-nfs2 -o -s /mnt/nfs/nfs2/vmfs/

Once created, you should receive confirmation the NAS datastore has been created and connected as below:

Connecting to NAS volume: openfiler-nfs2
openfiler-nfs2 created and connected
openfiler-nfs2 is /mnt/nfs/nfs2/vmfs/ from mounted available

We can remove the NFS datastore by invoking the ‘esxcfg-nas -d’  and specifying the datastore name.

esxcfg-nas -d openfiler-nfs2

To which on deletion you will receive confirmation as below.

NAS volume openfiler-nfs2 deleted.

Alternatively using PowerCLI we  can invoke the New-Datastore cmdlet to create a new NFS datastore  on the ESXi Host ‘deanesxi1.dean.local’.

New-Datastore -VMHost deanesxi1.dean.local -Nfs -Name openfiler-nfs2 -NfsHost -Path /mnt/nfs/nfs2/vmfs/

To confirm the NFS datastore has been create we can invoke the Get-Datastore cmdlet to retrieve a collection of datastore where the type is ‘NFS’.

Get-Datastore | where {$_.type -eq "NFS"}

As below, we can confirm the new NFS datastore has been created.

Name            FreeSpaceGB CapacityGB
----            ----------- ----------
openfiler-nfs2  21.271     21.302

In order to remove a NFS datastore we can invoke the Remove-Datastore cmdlet to specify the datastore to remove on the ESXi host, where I am invoking the command without requiring user confirmation.

Remove-Datastore -Datastore openfiler-nfs2 -VMHost deanesxi1.dean.local -Confirm:$False

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s