Difference between revisions of "ESX common commands"
Line 2: | Line 2: | ||
'''File Management''' | '''File Management''' | ||
+ | |||
COMMAND: vmkfstools | COMMAND: vmkfstools | ||
− | |||
Creating a virtual disk | Creating a virtual disk | ||
Line 11: | Line 11: | ||
COMMAND: vifs | COMMAND: vifs | ||
− | + | ||
Copying a file to another location | Copying a file to another location | ||
# vifs -c "[StorageName] VM/VM.vmx" "[StorageName] VM_backup/VM.vmx" | # vifs -c "[StorageName] VM/VM.vmx" "[StorageName] VM_backup/VM.vmx" | ||
Listing all the directories | Listing all the directories | ||
− | # vifs --server -D "[StorageName] | + | # vifs --server -D "[StorageName] vms" |
'''Host Management''' | '''Host Management''' | ||
+ | |||
COMMAND: vicfg-hostops | COMMAND: vicfg-hostops | ||
− | + | ||
Shutting down a single host | Shutting down a single host | ||
− | + | # vicfg-hostops --operation shutdown --force | |
Rebooting entire cluster | Rebooting entire cluster | ||
− | + | # vicfg-hostops --operation reboot --cluster | |
+ | |||
COMMAND: vicfg-cfgbackup | COMMAND: vicfg-cfgbackup | ||
− | + | ||
Backing up configuration data | Backing up configuration data | ||
− | + | # vicfg-cfgbackup -s /tmp/ESXi_181842_backup.txt | |
Restoring configuration data | Restoring configuration data | ||
− | + | # vicfg-cfgbackup -l /tmp/ESXi_181842_backup.tgz | |
+ | |||
COMMAND: vicfg-authconfig | COMMAND: vicfg-authconfig | ||
− | + | # vicfg-authconfig --server= | |
− | + | ||
− | + | ||
--username= | --username= | ||
--password= | --password= | ||
Line 41: | Line 42: | ||
'''Virtual Machine Management''' | '''Virtual Machine Management''' | ||
− | + | ||
COMMAND: svmotion | COMMAND: svmotion | ||
− | + | ||
Relocating a virtual machine's storage (including the disks) | Relocating a virtual machine's storage (including the disks) | ||
− | + | # svmotion - -url=https://myvc.mycorp.com/sdk - -datacenter=DC1 - -vm="[storage1] myvm/myvm.vmx:new_datastore" | |
Relocating a virtual machine's configuration file, but leaving the virtual disks | Relocating a virtual machine's configuration file, but leaving the virtual disks | ||
− | + | # svmotion - -datacenter='My DC' - -vm='[old_datastore] myvm/myvm.vmx:new_datastore' - -disks='[old_datastore] myvm/myvm_1.vmdk:old_datastore, [old_datastore] myvm/myvm_2.vmdk: old_datastore' | |
− | myvm/myvm.vmx:new_datastore' - -disks='[old_datastore] myvm/myvm_1.vmdk:old_datastore, [old_datastore] myvm/myvm_2.vmdk: old_datastore' | + | |
COMMAND: vmware-cmd | COMMAND: vmware-cmd | ||
− | + | ||
Listing all registered virtual machines | Listing all registered virtual machines | ||
− | + | # vmware-cmd -l | |
Registering a virtual machine | Registering a virtual machine | ||
− | + | # vmware-cmd -s register /vmfs/volumes/storage/VM/MyVM.vmx | |
Creating a snapshot | Creating a snapshot | ||
− | + | # vmware-cmd -U -P -H VCServerABC -h ESXHost | |
/vmfs/volumes/storage1/MyVM/MyVM.vmx createsnapshot | /vmfs/volumes/storage1/MyVM/MyVM.vmx createsnapshot | ||
'''User Management''' | '''User Management''' | ||
− | + | ||
COMMAND: vicfg-user | COMMAND: vicfg-user | ||
− | + | ||
Listing the existing users | Listing the existing users | ||
− | + | # vicfg-user -e user -o list | |
Adding a new user with specified login ID and password | Adding a new user with specified login ID and password | ||
− | + | # vicfg-user -e user -o add -l userx -p password1234 | |
Creating a group | Creating a group | ||
− | + | # vicfg-user -e group -o add -d test | |
'''Virtual Network Management''' | '''Virtual Network Management''' | ||
− | + | ||
COMMAND: esxcli network vswitch | COMMAND: esxcli network vswitch | ||
− | + | ||
Listing all virtual switches and associated port groups | Listing all virtual switches and associated port groups | ||
− | + | # esxcli network vswitch standard list | |
+ | |||
COMMAND: vicfg-vswitch | COMMAND: vicfg-vswitch | ||
− | + | ||
Listing all virtual switches and associated port groups | Listing all virtual switches and associated port groups | ||
− | + | # vicfg-vswitch -l | |
+ | |||
COMMAND: esxcfg-vswitch | COMMAND: esxcfg-vswitch | ||
− | + | ||
Creating a new virtual switch | Creating a new virtual switch | ||
− | + | # esxcfg-vswitch a TestvSwitch | |
Adding or removing network cards (known as vmnics) to or from a vNetwork Distributed Switch (vDS) | Adding or removing network cards (known as vmnics) to or from a vNetwork Distributed Switch (vDS) | ||
− | + | # esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch | |
+ | |||
COMMAND: esxcfg-nics | COMMAND: esxcfg-nics | ||
− | + | ||
Viewing the list of physical adapters and their link status | Viewing the list of physical adapters and their link status | ||
− | + | # esxcfg-nics l | |
'''Storage Management''' | '''Storage Management''' | ||
+ | |||
COMMAND: vicfg-scsidevs or esxcli storage core device list | COMMAND: vicfg-scsidevs or esxcli storage core device list | ||
− | + | ||
Listing all logical devices known on the system | Listing all logical devices known on the system | ||
− | + | # esxcli storage core device list | |
− | OR | + | OR |
− | + | # vicfg-scsidevs --list | |
+ | |||
COMMAND: vicfg-mpath or esxcli storage core path | COMMAND: vicfg-mpath or esxcli storage core path | ||
− | + | ||
Listing all devices, along with corresponding paths, state of the path, adapter type, and other information | Listing all devices, along with corresponding paths, state of the path, adapter type, and other information | ||
− | + | # esxcli storage core path list | |
− | OR | + | OR |
− | + | # vicfg-mpath --list-paths | |
Setting the state of a LUN path to "off" | Setting the state of a LUN path to "off" | ||
− | + | # esxcli storage core path set --state off --path vmhba32:C0:T1:L0 | |
− | OR | + | OR |
− | + | # vicfg-mpath --state off --path vmhba32:C0:T1:L0 | |
+ | |||
COMMAND: vicfg-rescan adapter rescan or esxcli storage core adapter rescan | COMMAND: vicfg-rescan adapter rescan or esxcli storage core adapter rescan | ||
− | + | ||
Rescanning a storage adapter | Rescanning a storage adapter | ||
− | + | # esxcli storage core adapter rescan --adapter=TestAdapter | |
− | OR | + | OR |
− | + | # vicfg-rescan TestAdapter | |
+ | |||
COMMAND: esxcfg-mpath | COMMAND: esxcfg-mpath | ||
− | + | ||
Enabling or disabling a path | Enabling or disabling a path | ||
− | + | # esxcfg-mpath -P path -s state | |
+ | |||
COMMAND: esxcfg-info | COMMAND: esxcfg-info | ||
− | + | ||
Checking the ESX/ESXi host for host hardware info | Checking the ESX/ESXi host for host hardware info | ||
− | + | # esxcfg-info | less i | |
Filtering out information about a specific system | Filtering out information about a specific system | ||
− | + | # esxcfg-info | grep 'system uuid' | |
+ | |||
+ | COMMAND: esxcli storage nmp | ||
+ | |||
+ | Listing paths to a single device | ||
+ | # esxcli storage nmp path list --device | ||
+ | Setting configuration parameters for third-party extensions | ||
+ | # esxcli storage nmp roundrobin setconfig | ||
'''iSCSI Storage Management''' | '''iSCSI Storage Management''' | ||
− | + | ||
COMMAND: esxcli iscsi | COMMAND: esxcli iscsi | ||
− | + | ||
Enabling software iSCSI | Enabling software iSCSI | ||
− | + | # esxcli iscsi software set --enabled=true | |
Adding a new adapter | Adding a new adapter | ||
− | esxcli iscsi networkportal add -n -A | + | # esxcli iscsi networkportal add -n -A |
+ | |||
COMMAND: vicfg-iscsi | COMMAND: vicfg-iscsi | ||
− | + | ||
Enabling software iSCSI | Enabling software iSCSI | ||
− | + | # vicfg-iscsi --swiscsi enable | |
Setting the iSCSI name and alias | Setting the iSCSI name and alias | ||
− | + | # vicfg-iscsi --iscsiname name | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 13:25, 15 September 2017
File Management
COMMAND: vmkfstools
Creating a virtual disk
# vmkfstools -c 2048m testvirtualdisk.vmdk
Creating a VMFS
# vmkfstools -C vmfs5 -b 1m -S my_test_vmfs /vmfs/devices/disks/test.ID:1
COMMAND: vifs
Copying a file to another location
# vifs -c "[StorageName] VM/VM.vmx" "[StorageName] VM_backup/VM.vmx"
Listing all the directories
# vifs --server -D "[StorageName] vms"
Host Management
COMMAND: vicfg-hostops
Shutting down a single host
# vicfg-hostops --operation shutdown --force
Rebooting entire cluster
# vicfg-hostops --operation reboot --cluster
COMMAND: vicfg-cfgbackup
Backing up configuration data
# vicfg-cfgbackup -s /tmp/ESXi_181842_backup.txt
Restoring configuration data
# vicfg-cfgbackup -l /tmp/ESXi_181842_backup.tgz
COMMAND: vicfg-authconfig
# vicfg-authconfig --server=
--username= --password= --authscheme AD --joindomain --adusername= --adpassword=
Virtual Machine Management
COMMAND: svmotion
Relocating a virtual machine's storage (including the disks)
# svmotion - -url=https://myvc.mycorp.com/sdk - -datacenter=DC1 - -vm="[storage1] myvm/myvm.vmx:new_datastore"
Relocating a virtual machine's configuration file, but leaving the virtual disks
# svmotion - -datacenter='My DC' - -vm='[old_datastore] myvm/myvm.vmx:new_datastore' - -disks='[old_datastore] myvm/myvm_1.vmdk:old_datastore, [old_datastore] myvm/myvm_2.vmdk: old_datastore'
COMMAND: vmware-cmd
Listing all registered virtual machines
# vmware-cmd -l
Registering a virtual machine
# vmware-cmd -s register /vmfs/volumes/storage/VM/MyVM.vmx
Creating a snapshot
# vmware-cmd -U -P -H VCServerABC -h ESXHost
/vmfs/volumes/storage1/MyVM/MyVM.vmx createsnapshot
User Management
COMMAND: vicfg-user
Listing the existing users
# vicfg-user -e user -o list
Adding a new user with specified login ID and password
# vicfg-user -e user -o add -l userx -p password1234
Creating a group
# vicfg-user -e group -o add -d test
Virtual Network Management
COMMAND: esxcli network vswitch
Listing all virtual switches and associated port groups
# esxcli network vswitch standard list
COMMAND: vicfg-vswitch
Listing all virtual switches and associated port groups
# vicfg-vswitch -l
COMMAND: esxcfg-vswitch
Creating a new virtual switch
# esxcfg-vswitch a TestvSwitch
Adding or removing network cards (known as vmnics) to or from a vNetwork Distributed Switch (vDS)
# esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch
COMMAND: esxcfg-nics
Viewing the list of physical adapters and their link status
# esxcfg-nics l
Storage Management
COMMAND: vicfg-scsidevs or esxcli storage core device list
Listing all logical devices known on the system
# esxcli storage core device list OR # vicfg-scsidevs --list
COMMAND: vicfg-mpath or esxcli storage core path
Listing all devices, along with corresponding paths, state of the path, adapter type, and other information
# esxcli storage core path list OR # vicfg-mpath --list-paths
Setting the state of a LUN path to "off"
# esxcli storage core path set --state off --path vmhba32:C0:T1:L0 OR # vicfg-mpath --state off --path vmhba32:C0:T1:L0
COMMAND: vicfg-rescan adapter rescan or esxcli storage core adapter rescan
Rescanning a storage adapter
# esxcli storage core adapter rescan --adapter=TestAdapter OR # vicfg-rescan TestAdapter
COMMAND: esxcfg-mpath
Enabling or disabling a path
# esxcfg-mpath -P path -s state
COMMAND: esxcfg-info
Checking the ESX/ESXi host for host hardware info
# esxcfg-info | less i
Filtering out information about a specific system
# esxcfg-info | grep 'system uuid'
COMMAND: esxcli storage nmp
Listing paths to a single device
# esxcli storage nmp path list --device
Setting configuration parameters for third-party extensions
# esxcli storage nmp roundrobin setconfig
iSCSI Storage Management
COMMAND: esxcli iscsi
Enabling software iSCSI
# esxcli iscsi software set --enabled=true
Adding a new adapter
# esxcli iscsi networkportal add -n -A
COMMAND: vicfg-iscsi
Enabling software iSCSI
# vicfg-iscsi --swiscsi enable
Setting the iSCSI name and alias
# vicfg-iscsi --iscsiname name