Increase size of VMWare virtual disk

Let us have a look at how to increase size of VMWare virtual disk.

Apparently there are several ways of increasing the disk size on a VMWare VMDK file, so below I will describe the way I have successfully done this in my virtual environment (vSphere 5.1).

(Note: This kind of operation can be harmful to your virtual machines and this information is provided without ANY warranty or responsibility for what happens when you do it! Make sure you have a proper backup before you engage in these activities)

 

First of all you need to have access to VMware ESXI Shell as described in my previous post.

After this we can start the work to expand our VMDK file.

Step 1 is to locate the VMDK file

  1. Log in to the VMware ESX/ESXi host as the root user.
  2. Run vim-cmd vmsvc/getallvms to list the location of the configuration files for the virtual machines registered on an ESXi host.
  3. Record the location of the .vmx file (configuration file) for the virtual machine that you are looking for. For example:/vmfs/volumes/46b2f3eb-ced4c7d8-c1d2-111122223333/vm1/vm1.vmx
  4. The results of step 4 list all virtual machine configuration files. Search the results for the name of a virtual machine file you are interested in locating. The results also list the path to the directory where these files are located.
  5. By viewing* the configuration file of a virtual machine, you can tell where all of its associated files, including .vmdk files, are located. If a file is not in the same directory as the configuration file the complete path is shown in the configuration file. For example, a second hard disk may have an entry such as the one shown below:scsi0:1.present = “true”
    scsi0:1.fileName = “/vmfs/volumes/46b2f3ea-980a1c90-3333-00112233bb44/diskStore/secondHardDisk.vmdk”

    • *Tip: Use the VI editor to view the content of the VMX file

    This information is based on this article from vmware : http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1003751

Step 2 will be actually expanding the file.

Virtual disks can be expanded using this ESXi/ESX command line command vmkfstools -X:

vmkfstools -X <new size> <virtual disk>.vmdk

Here is an example, use this command to grow the virtual disk to 25GB in size:
vmkfstools -X 25g /vmfs/volumes/xxxx/vmname/vmname.vmdk

  • Changes are made to the disk and are almost instant.
  • Partitions residing within the virtual disks will not resize and there will be unallocated space at the end of the disk.Third-party partitioning tools are required at this point to resize the primary partition to take advantage of the additional space.
  • VMware Converter allows you to specify a new disk size in its conversion wizard. It will also take care of partition resizing for you.

 

You can read more details on this if you need it here http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002019

 

 

Enabling ESXi Shell access using vSphere Client

So you need a deeper connection with your vSphere? Let us take a look at Enabling ESXi Shell access using vSphere Client.

Use the vSphere Client to enable local and remote access to the ESXi Shell:

  1. Log in to a vCenter Server system using the vSphere Client.
  2. Select the host in the Inventory panel.
  3. Click the Configuration tab and click Security Profile.
  4. In the Services section, click Properties.
  5. Select ESXi Shell from this list:

    ESXi Shell
    SSH
    Direct Console UI

  6. Click Options and select Start and stop manually.

    Note: When you select Start and stop manually, the service does not start when you reboot the host. If you want the service to start when you reboot the host, select Start and stop with host.

  7. Click Start to enable the service.
  8. Click OK.

Enabling ESXi Shell access using the Direct Console User Interface

Use the direct console user interface to enable the ESXi Shell:

  1. From the Direct Console User Interface, press F2 to access the System Customization menu.
  2. Select Troubleshooting Options and press Enter.
  3. From the Troubleshooting Mode Options menu, select Enable ESXi Shell.

    Enable ESXi Shell
    Enable SSH

  4. Press Enter to enable the service.

This information is taken from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2004746

Install VMware tools on Ubuntu via command line

This information is succesfully tested in several of my VM’s

  1. Go to Virtual Machine > Install VMware Tools (or VM > Install VMware Tools).Note: If you are running the light version of Fusion, or a version of Workstation without VMware Tools, or VMware Player, you are prompted to download the Tools before they can be installed. Click Download Now to begin the download.
  2. In the Ubuntu guest, run these commands:
    1. Run this command to create a directory to mount the CD-ROM:sudo mkdir /mnt/cdromWhen prompted for a password, enter your Ubuntu admin user password.

      Note: For security reasons, the typed password is not displayed. You do not need to enter your password again for the next five minutes.

    2. Run this command to mount the CD-ROM:sudo mount /dev/cdrom /mnt/cdrom or sudo mount /dev/sr0 /mnt/cdrom
    3. The file name of the VMware Tools bundle varies depending on your version of the VMware product. Run this command to find the exact name:ls /mnt/cdrom
    4. Run this command to extract the contents of the VMware Tools bundle:tar xzvf /mnt/cdrom/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/Note: x.x.x-xxxx is the version discovered in the previous step.
    5. Run this command to change directories into the VMware Tools distribution:cd /tmp/vmware-tools-distrib/
    6. Run this command to install VMware Tools:sudo ./vmware-install.pl -dNote: The -d switch assumes that you want to accept the defaults. If you do not use -d, press Return to accept each default or supply your own answers.
  3. Run this command to reboot the virtual machine after the installation completes:sudo reboot

 

This information is taken from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022525