The Sysadmin Wiki

VMware is a virtual machine. There are both freeware and paid versions available.



Disk tools[]

Create disk[]

You can either download a 21 KB zip file with all sorts of ready VMware images or if you want custom sizes, you can create your own with the following command:

qemu-img create -f vmdk harddisk.vmdk 30G

This command results in a 3.9 MB file, which can be expanded to up to 30 GB.

Convert disk[]

VMware VMDK disks can be converted between the various formats with vmware-vdiskmanager, e.g. to a single growable type VMDK:

vmware-vdiskmanager -r from.vmdk -t 0 to.vmdk

Shrink disk[]

VMware growable harddrives can end up being bigger than what's on them, especially if it's just converted from a fixed size VMDK, which is why vmware-vdiskmanager can shrink disks:

vmware-vdiskmanager -k disk.vmdk

NB: Doesn't seem to be available on the Linux version.

Expand disk[]

VMware server 2[]

  • Log on to the web management interface
  • Choose the VM on the left hand side
  • Make sure the VM is shut down
  • Click on the disk you want to expand and choose edit
  • Click on increase capacity and choose the size you want
  • Remember to expand the partition on the client, this can e.g. be done on an Ubuntu LiveCD or in Vista it can be done directly in the Disk Management tool

User identification issue[]

VMware server 2 seems to request user identification repeatedly on some setups. There is a thread on this issue on the VMware forum.

VMware ESXi on a USB disk[]

You can install VMware ESXi as a USB boot disk and therefore be able to start up an emergency VMware server on any compatible machine without formatting its harddisk. This makes any panic situation alot easier and takes very little effort.

You need to open the ISO file for the VMware installation with something like file-roller (archive manager) for Ubuntu or 7-zip for Windows, then open up install.tgz and in there open /usr/lib/vmware/installer/VMware-VMvisor-big-3.5.0_Update_3-123629.i386.dd.bz2 and extract the .dd file inside it.

You need to image this .dd file onto a USB disk with e.g. dd on Linux by using the command dd if=/home/sysadmin/vmware.dd of=/dev/sdc (if /dev/sdc is your USB disk).

You can then partition the rest of the available space on the USB disk for extra storage. The VMware ESXi server itself requires about 700MB on the USB disk.

Managing ESXi server from Linux[]

Enable SSH under "Troubleshooting Options" in the dcui or under configuration -> security profile -> 'properties' on both services and firewall and then you can run CLI commands directly on the ESXi server over the network.

ESXi license[]

See current license info:

vim-cmd vimsvc/license --show

Set license (e.g. the free ESXi license):

vim-cmd vimsvc/license --set "$LICENSE_KEY"

Common host settings[]

Hostname (2nd command makes sure to register hostname to DNS):

esxcli system hostname set --host=$HOSTNAME
esxcli system settings advanced set -o /Misc/PreferredHostName -s $HOSTNAME

IP address[]

To see the current NIC settings on the host:

esxcfg-vmknic -l

To set a static IP address for the "Management Network" interface on the host (will immediately switch over, so you need to re-connect on the new IP address afterwards):

esxcfg-vmknic -i -n "Management Network"

Mount NFS share[]

vim-cmd hostsvc/datastore/nas_create $localname $hostname $remotepath $rwsetting


localname: Local (ESXi server) mounted name for share
hostname: Hostname or IP of NFS server
remotepath: Path on NFS server to mount (e.g. /fish)
rwsetting: 0 for RW or 1 for readonly

Creating a VM[]

  • Create folder (e.g. in datastore1 with folder name newvm)
mkdir /vmfs/volumes/datastore1/newvm
  • Create disk (e.g. 40GB)
vmkfstools -c 40G -a lsilogic /vmfs/volumes/datastore1/newvm/disk0.vmdk
vi /vmfs/volumes/datastore1/newvm/vm.vmx
  • Register the VM
vim-cmd solo/registervm /vmfs/volumes/datastore1/newvm/vm.vmx
  • Verify that it's added
vim-cmd vmsvc/getallvms

Note: Check power state:

vim-cmd vmsvc/power.getstate $vmid
  • Power it on
vim-cmd vmsvc/power.on $vmid

If you've set it up in the .vmx file, you can now connect to it with VNC. Example conf:

RemoteDisplay.vnc.enabled = "True"
RemoteDisplay.vnc.port = "5901"
RemoteDisplay.vnc.password = "Super_secret.passw0rd!,,/"

Keep in mind that VNC is not opened in the vmware proxy by default, so you should either open it or preferrably ssh proxy your way in.

Or you can find the guests IP address, in order to connect directly to the guest, with this command:

vim-cmd vmsvc/get.guest $vmid | grep ipAddress | head -n1

Insert VMware tools[]

vim-cmd vmsvc/tools.install $vmid

Set NTP settings[]

To enable NTP, set /etc/ntp.conf with the following contents:

restrict default kod nomodify notrap nopeer
driftfile /etc/ntp.drift


On ESXi 5.1+ you need to enable the NTP client in the firewall:

esxcli network firewall ruleset list | grep '^ntpClient  *false$' && esxcli network firewall ruleset set -r ntpClient -e true

Then restart the ntp service for it to take effect:

/etc/init.d/ntpd restart

See also[]

External links[]