Mounting Network File System (NFS) Shares
COS
esxcfg-nas manages NAS mounts. Use this command to add, delete, list, and change the attributes of NAS devices. This example shows you how to add an NFS share:
# esxcfg-nas -a <datastore name> -o <nfs server hostname/ip> -s <mount point>
vSphere PowerCLI
Use the New-Datastore cmdlet to create a new datastore. Use -Nfs to create an NFS share and specify the NFS server and mount point using the -NfsHost and -Path parameters. For example:
[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> New-Datastore -VMHost 10.112.96.17 -Nfs -Name NFS-01 -NfsHost 10.112.101.9 -Path /NFS
Name FreeSpaceMB CapacityMB
---- ----------- ----------
NFS-01 135548 274944
vSphere CLI
Use the vicfg-nas.pl command to add an entry to the known NAS file system list and supplies the share name of the new NAS file system. You must supply the host name and the share name for the new NAS file system. For example:
vicfg-nas.pl --server 10.112.96.17 --add NFS-01 --nasserver 10.112.101.9 --share /NFS
Connecting to NAS volume: NFS
NFS created and connected.
Listing NAS/NFS Exports or Shares
COS
To list NAS/NFS Exports or Shares using the COS, run the command:
# esxcfg-nas –l
vSphere PowerCLI
To list NAS/NFS Exports or Shares using the vSphere PowerCLI, run the command:
[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-Datastore | where {$_.type -eq "NFS"}
vSphere CLI
To list NAS/NFS Exports or Shares using the vSphere CLI, run the command:
C:\Program Files\VMware\VMware vSphere CLI\bin>vicfg-nas.pl -server 10.112.96.17 --list
Creating a VMFS Volume
You can use vmkfstools to create and manage a virtual machine file system (VMFS) and physical storage devices on an ESX/ESXi host:
COS
vSphere PowerCLI
The New-Datastore cmdlet is used to create the VMFS datastore, specify the name of the datastore using the -Name parameter, and provide the NAA ID using the -Path parameter. For example:
[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> New-Datastore -Name vCloud-0 -Path naa.60060160582017005c0a006277b6df11 -Vmfs
Name: vCloud-0
Name FreeSpaceMB CapacityMB
---- ----------- ----------
vCloud-0 50425 50944
vSphere CLI
To create a VMFS volume using the vSphere CLI, run the command:
C:\Program Files\VMware\VMware vSphere CLI\bin>vmkfstools.pl --server 10.112.96.17 -C vmfs3 -b 1m -S vCloud-0 /vmfs/devices/disks/naa.60060160582017005c0a006277b6df11:1
Creating vmfs3 file system on naa.60060160582017005c0a006277b6df11:1 with blockSize 1048576 and volume label vCloud-0
Successfully created new volume:4cb43e93-555bbef5-0f61-0024817ebebb
Configuring iSCSI Storage
VMware ESX/ESXi systems include software iSCSI capabilities for accessing remote storage using an IP network. This can be configured in the VMware vSphere Client, Console OS, vSphere CLI and PowerCLI.
COS
To configure a VMware ESX software iSCSI initiator:
- To enable the iSCSI Initiator, run the command:
# esxcfg-swiscsi -e
- To add iSCSI targets, run the command:
# vmkiscsi-tool -D -a 10.112.101.9:3260 vmhba32
Notes:
- -D is used to set the mode of discovery and -a is used to add an iSCSI target.
- The device identifier may differ between ESX host systems. For example, the software iSCSI initiator may be populated as vmhba33 or vmhba34.
- To show details about the configured targets, run the command:
# vmkiscsi-tool -l -T vmhba37
- To rescan the software iSCSI adapter, run the command:
# esxcfg-swiscsi -s
Scanning vmhba32...
Scanning vmhba33...
- For configuring VMkernel ports for iSCSI, see Configuring a VMkernel port and enable VMotion via command line (1006989).
vSphere PowerCLI
To get a list of iSCSI HBAs, run the command:
[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMHost 10.112.96.17 | Get-VMHostHba -Type iScsi
vSphere CLI
Use the vicfg-iscsi vCLI command to configure both hardware and software iSCSI storage for your ESX/ESXi system.