Wednesday, May 2, 2012

How to Rename a Virtual Machine with the CLI in esxi 5.0

With the release of esxi/vsphere 5, storage vmotion no longer renames the files of a vm if the vm was previously renamed. It only updates the folder to reflect the new name. If a person wants to rename a virtual machine and make sure that the virtual machine reflects the new name in the folder and files, follow these steps.

Warning: Try this on a non-production environment. We are not talking about what is supported, just what works. Also, be aware that you may have more files involved, such as an rdm, snapshot and so forth. Proceed at your own risk.

Step # 1:

Access the directory that contains the folder with the files. In this case, the vm is called machinex and it is located in datastore1. The vm needs to be powered off.

# cd /vmfs/volumes/datastore1

Step # 2:

Rename the folder

# mv machinex machiney

Step # 3:

Access the new directory

# cd machiney

Step # 4:

Rename all the files manually

# mv machinex.vmx machiney.vmx
# mv machinex.vmsd machiney.vmsd
# mv machinex.nvram machiney.nvram
# mv machinex.vmdk machiney.vmdk
# mv machinex-flat.vmdk machiney-flat.vmdk
# mv machinex.vmxf machiney.vmxf

Note: In this case, there were no snapshots so the .vmsd file was empty.

Step # 5:

Edit the contents of the .vmx file using vi. Use a global search and replace.

# vi machiney.vmx

Step # 6:

Edit the contents of the .vmdk file

# vi machiney.vmdk

Step # 7:

Get the vmid of the original vm and unregister the vm
# vim-cmd vmsvc/getallvms
# vim-cmd vmsvc/unregister 5

Step # 8:

Register the new virtual machine

# vim-cmd solo/registervm /vmfs/volumes/datastore1/machiney/machiney.vmx

Note: This was eventually taken care off in 5.0 u2 and 5.1 u1:

If using those versions, this can be taken care of via the vsphere client.
There is a parameter called provisioning.relocate.enableRename which is set to false. Just change it to true and restart the vcenter service.

Here are the steps:
  1. Log into the vSphere Client as an Administrator.
  2. Click Administration > vCenter Server Settings.
  3. Click Advanced Settings.
  4. Add this advanced parameter Key:


Wednesday, March 28, 2012

The power of the esxcli command in Esxi 5

The esxcli continues go grow as new versions of esxi and vsphere are introduced.
This command can be executed inside the esxi host (via ssh or the esxi shell) or remotely
using the vcli by adding the --server flag.

Here are some examples of the power of this command:

1. List how many nfs mounts exist.

# esxcli storage nfs list

2. Get information about fcoe adapters and cards

# esxcli fcoe nic list
# esxcli fcoe adapter list

3. Get information about installed packages

# esxcli software vib list

4. Find out how much memory exist on your esxi server

# esxcli hardware memory get

5. Find out how many cpus exist on your esxi server

# esxcli hardware cpu list

6. Find out the name of your iscsi adapter

# esxli iscsi adapter list

7. Find out how many physical nics exist

# esxcli network nic list

8. Find out the state of your firewall

# esxcli network firewall get
# esxcli network firewall ruleset list

9. Find out information about your vmfs file systems

# esxcli storage vmfs extent list

10. Find out the version of esxi

# esxcli system version list

How to query a virtual machine from the command line

To quickly get information, an administrator can use the vim-cmd vmsvc/get.summary command:

Here are some examples:

Step # 1: Get information about all the existing vms and select the identifier of one of them

# vim-cmd vmsvc/getallvms

Step # 2: Find out how many cpus a virtual machine has

# vim-cmd vmsvc/get.summary 1 | grep numCpu

Step # 3: Find out how much memory was allocated to a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep memorySize

Step # 4: Find out if vmware tools is installed

# vim-cmd vmsvc/get.summary 1 | grep toolsStatus

Step # 5: Find out how many network cards were allocated to a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep numEthernetCards

Step # 6: Find out how many virtual disks a virtual machine has

# vim-cmd vmsvc/get.summary 1 | grep numVirtualDisks

Step # 7: Find out if a virtual machine has a cpu reservation

# vim-cmd vmsvc/get.summary 1 | grep cpuReservation

Step # 8: Find out if a virtual machine has a memory reservation

# vim-cmd vmsvc/get.summary 1 | grep memoryReservation

Step # 9: Find out the name of a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep name

Step # 10: Find out if the virtual machine has been configured for fault tolerance

# vim-cmd vmsvc/get.summary 1 | grep faultTolerance

Wednesday, March 14, 2012

How to prepare a Linux iscsi server for Esxi testing

To prepare an iscsi server for esxi testing, one can use linux very easily.

Here are the steps. In this example, the boot drive is partitioned during the install and the
partition to make available for esxi testing is slice/partition 6 on the boot drive (/dev/sda).
In this example, Chap (authentication) is not used.


1. Install the iscsi packages into your ubuntu desktop.

$ sudo apt-get update
$ sudo apt-get install iscsitarget open-iscsi

2. Edit the /etc/default/iscsitarget and enable the iscsi functionality

$ sudo echo ISCSITARGET_ENABLE=true > /etc/default/iscsitarget

3. Edit the /etc/ietd.conf file (ietd=iscsi enterprise target daemon) and specify what to share.

$ sudo vi /etc/ietd.conf
Lun 0 Path=/dev/sda6,Type=fileio

4. Reboot the desktop to start the iscsi functionality

$ sudo reboot

5 Verify that iscsi is running and the partition is shared

$ sudo iscsiadm -m discovery -t st -p your_ip_here

That is all is needed.

How to prepare an nfs server in Linux for Esxi

If one needs to create an nfs server to test esxi, all one needs is a linux nfs server.
Some people prefer freenas or openfiler, others simply use solaris, hpux and so forth.

Here, I prepared an nfs server using ubuntu linux. Plain ubuntu linux, desktop edition.


1. Install the nfs server packages to turn your desktop into an nfs server.

$ sudo apt-get update
$ sudo apt-get install nfs-kernel-server

2. Prepare a directory to be shared. For testing, allow anybody to mount it and write into it.

$ sudo mkdir /share1
$ sudo chmod 777 /share1

3. Edit the /etc/exports file to share the directory share1 with everybody

$ sudo echo /share1 * >> /etc/exports
$ cat /etc/fstab

4. Start the nfs daemons and verify that nfs is working

$ sudo /etc/init.d/nfs-kernel-server start
$ sudo showmount -e

That is it; this is all it takes.

Wednesday, January 4, 2012

VAAI -- VMware vSphere vStorage APIs

Manipulating the Hardware Acceleration VAAI primitives

There are two new vaai primitives available in vsphere 5.0. These provide hardware 
acceleration for NAS and Thin Provisioning. Using these primitives offload certain 
operations to the array, hence reducing cpu overhead on the host and improving cold 
migrations and cloning duration.

From the VMA:
List all plugins installed:
# esxcli --server software vib list

Install a vaai vib:
# esxcli --server software vib install -v | --viburl=url_here

Uninstall a vaai vib:
# esxcli --server = software vib remove -v| --vibname=name

Additional local commands:
# esxcfg-scsidevs -l | egrep "Display Name:VAAI Status"

# esxcli storage core dvice vaai status get