Managing ESXi Without the VI Client – Part 6

So far in this series of articles I’ve covered the following items.
Part 1 – initial setup and creating a VM
Part 2 – add a license key, enable VM automatic startup and shutdown and unregister a VM
Part 3 – create a virtual switch and configure a firewall VM
Part 4 – install an update for ESXi
Part 5 – Creating a datastore and migrating VMs

This article started with a need to add a VMDK to a VM for some performance testing. Part of the process was to hot add the disk to a VM and when I found that I couldn’t I choose to reset the license for the host back to evaluation mode to accomplish this.

1) I created a folder for disk file and then ran the below command to create the VMDK.

vmkfstools -c 255G -d eagerzeroedthick -a lsilogic IOMETER.vmdk

2) If the VM had been powered down, I could have added the below to the VMX file for the VM and then powered it on.

scsi0:1.fileName = "/vmfs/volumes/4a68046d-2159a120-ebac-001a9253e68f/IOMETER/IOMETER.vmdk"
scsi0:1.mode = "persistent"
scsi0:1.ctkEnabled = "FALSE"
scsi0:1.deviceType = "scsi-hardDisk"
scsi0:1.present = "TRUE"
scsi0:1.redo = ""

3) Instead I wanted to hot-add the disk so I ran the below commands. The first run shows the syntax of the command and with the second command I added the VMDK to the VM as device 1 on SCSI controller 0. If I had wanted to remove the virtual disk from the VM I would have used the device.diskremove option as shown below.

vim-cmd vmsvc/device.diskaddexisting
   Insufficient arguments.
   Usage: device.diskaddexisting vmid 'disk file' 'controller number' 'unit number'
   Add an existing disk to this virtual machine.
vim-cmd vmsvc/device.diskaddexisting 272 /vmfs/volumes/datastore1/IOMETER/IOMETER.vmdk 0 1
vim-cmd vmsvc/device.diskremove
   Insufficient arguments.
   Usage: device.diskremove vmid 'controller number' 'unit number' 'delete file'
Remove a disk from this virtual machine.
vim-cmd vmsvc/device.diskremove 272 0 1 n

To get information about the controller and device ID for disks, you can execute the command vim-cmd vmsvc/device.getdevices <vm ID> and you’ll get an output as shown below.

(vim.vm.device.VirtualDisk) {
 dynamicType = <unset>,
 key = 2001,
 deviceInfo = (vim.Description) {
 dynamicType = <unset>,
 label = "Hard disk 2",
 summary = "267386880 KB",
 backing = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) {
 dynamicType = <unset>,
 fileName = "[datastore1] IOMETER/IOMETER.vmdk",
 datastore = 'vim.Datastore:4a68046d-2159a120-ebac-001a9253e68f',
 diskMode = "persistent",
 split = false,
 writeThrough = false,
 thinProvisioned = false,
 eagerlyScrub = <unset>,
 uuid = "6000C292-7b91-a7ed-5386-161b52701478",
 contentId = "1c86e62103b24c83b27711726578c835",
 changeId = <unset>,
 parent = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) null,
 connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null,
 controllerKey = 1000,
 unitNumber = 1,
 capacityInKB = 267386880,
 shares = (vim.SharesInfo) {
 dynamicType = <unset>,
 shares = 1000,
 level = "normal",

4) Now when I checked the VM, the new virtual disk was not present so I checked /var/log/messages and found the below error.

Nov 13 07:54:42 Hostd: [2009-11-13 07:54:42.538 77381B90 info 'vm:/vmfs/volumes/4aea17ed-5267d790-647d-001a9253e63a/DC05/DC05.vmx'] No hot-plug license available.
Nov 13 07:54:42 Hostd: [2009-11-13 07:54:42.538 77381B90 info 'TaskManager'] Task Completed : haTask-272-vim.VirtualMachine.reconfigure-1852796427 Status error
Nov 13 07:54:42 Hostd: [2009-11-13 07:54:42.538 77381B90 warning 'vm:/vmfs/volumes/4aea17ed-5267d790-647d-001a9253e63a/DC05/DC05.vmx'] Reconfigure worker failed to validate device spec

5) As shown above I was not able to add the disk as my license was not configured for hot add, so I decided to change the ESXi temporarily back to evaluation mode. Using what I had done in Part 2, I did the following:

a) Edited /etc/vmware/vmware.lic and deleted the license key.

b) Deleted the file /etc/vmware/license.cfg

c) Ran the command restart

d) I then queried the license information to check the status. The file /etc/vmware/license.cfg was automatically recreated. You’ll note that for the 1st attempt of the command I got the “514 Error connecting” error. This was due to the services restart sequence completing, but the hostd service not yet being fully up yet.

Leave a Comment

Your email address will not be published. Required fields are marked *