Managing Storage using the Command Line Interface (CLI) in vSphere 4.x
search cancel

Managing Storage using the Command Line Interface (CLI) in vSphere 4.x

book

Article ID: 308141

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This articles provides information about configuring NFS, iSCSI, and VMFS volumes using:
  • ESX Console Operating System (COS)
  • vSphere PowerCLI 4.x
  • VMware vSphere CLI 4.x


Environment

VMware ESXi 4.0.x Embedded
VMware ESXi 4.1.x Embedded
VMware ESX 4.0.x
VMware vSphere PowerCLI 4.1
VMware vSphere PowerCLI 4.0
VMware ESXi 4.0.x Installable
VMware ESX 4.1.x
VMware vSphere CLI 4.0
VMware vSphere CLI 4.1
VMware ESXi 4.1.x Installable

Resolution

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

For detailed information on creating the VMFS volume from the ESX/ESXi console, see Manually creating a VMFS volume using vmkfstools -C (1009829).


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:
  1. To enable the iSCSI Initiator, run the command:

    # esxcfg-swiscsi -e

  2. 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.

  3. To show details about the configured targets, run the command:

    # vmkiscsi-tool -l -T vmhba37

  4. To rescan the software iSCSI adapter, run the command:

    # esxcfg-swiscsi -s

    Scanning vmhba32...
    Scanning vmhba33...

  5. 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

For more information on creating a new datastore over iSCSI, see Work with Host Storages and iSCSI HBA Devices in the vSphere PowerCLI Administration Guide.


vSphere CLI

Use the vicfg-iscsi vCLI command to configure both hardware and software iSCSI storage for your ESX/ESXi system.

For detailed information on configuring iSCSI storage using the vSphere CLI, see iSCSI Storage Setup in the vSphere Command-Line Interface Installation and Scripting Guide.


Additional Information

For information about managing storage using the CLI in vSphere 5.x, see Command-Line Management in vSphere 5 for Service Console Users in the vSphere documentation. vSphere 4.x でコマンド ライン インターフェイス (CLI) を使用してストレージを管理する
在 vSphere 4.x 中使用命令行界面 (CLI) 管理存储