Everyday Virtualization

Blog archive

Add a Disk with ESXi

For ESXi installations, command-line options are available for virtualization administrators. For licensed installations with vCenter, the VI Toolkit is a very powerful interface to manage the hosts. For unmanaged (or free ESXi), there are options to manage virtual machines, the hosts and other aspects of virtualization as well.

One common task is to add an additional disk file (VMDK) to a virtual machine. While this can be done in the vSphere client, things like this can be done via the command line as well. The command we will need to perform this task is the vim-cmd series of commands for ESXi. Let's go through a common scenario of adding an additional virtual disk that is thick-provisioned to a running virtual machine:

  • Get to a command line on ESXi. You can find how to do this by reading my May 2009 How-To post.
  • Determine the vmid of the virtual machine you want to add the disk to:

    vim-cmd vmsvc/getallvms

    The result is Fig. 1.
Adding a Disk
Figure 1. In my example, the virtual machine "BEATBOX-NUEVO" will be receiving the additional VMDK and is vmid #16. (Click image to view larger version.)

  • Enter the command to add a 10 GB disk:

    vim-cmd vmsvc/device.diskadd 16 10000 scsi0 2 datastore1

This adds to vmid 16 a 10000 KB disk on the SCSI0 controller, as the second disk (there is already a disk at the 1 position), to datastore1.

Once that command is passed, the VM now has the disk attached and did not require downtime to add the additional storage.

Posted by Rick Vanover on 12/03/2009 at 12:47 PM


Featured

Subscribe on YouTube