Here is the situation: I have three ESXi4.0 running under VMware Workstation 7 in my home lab. I have extended the disk of one of the ESXi4.0 from 1500MB to 2048MB. Although that was easy with VMware Workstation, the new disk space is not visible yet to my ESXi4.0 local VMFS datastore. How do you do to increase the size of the local datastore of an ESXi4.0?
This procedure comes largely from this VMware KB which is originally written for ESX4.0 with a COS (Service Console). Because an ESXi4.0 doesn’t have a COS I have to access the Tech Support Mode which allows low-level access to the system so that advanced diagnostic and configuration commands can be issued. Only VMware Support can ask you to log in to the TSM. Use this procedure “as-is” and in a test environment only.
Now log on to the TSM mode (see how to logon to TSM), and run the following command:
The command confirms that the local storage is 2048MB (2GB)
In order to make use of the full size of the disk, the local VMFS datastore must be removed and recreated using the full size of the disk. On an ESX4.0 host you could use three tools: sfdisk, partedUtil and fdisk but on an ESXi4.0 host, only fdisk is available. Also I don’t have a standard naming convention for the disk in the Console Device like /dev/sda, or /dev/sdb. Instead I have /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0. To learn more about how to identify disks when working with VMware ESX, you should read this VMware KB. Now let’s connect to the disk with fdisk:
As you can see on the picture, the local VMFS datastore is only 651MB. Also if you add up all the partitions you end up with a bit more than 1500MB. I’m definitely +500MB short.
Press d then Enter 2 to delete /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0p2
Press n and Enter to start creating a new partition.
Press p and Enter to identify that you are creating a primary partition.
Press 2 and Enter to identify that you are creating a second partition. A primary partition already exists.
Press Enter to accept the default ending value.
Press t and Enter to identify that you want to change the type of a partition. We want to change partition# 2.
Type fb and press Enter. This sets the volume to type VMFS.
Press w and press Enter to save the changes and exit fdisk.
Now that we have set properly the partition table, we need to grow the file system on it. The :2 in the command identifies that this operation is performed on the second partition. Run the following command:
vmkfstools –growfs /vmfs/devices/disks/vml.0000000000766d686261313a303a30:2 /vmfs/devices/disks/vml.0000000000766d686261313a303a30:2
Now in the Configuration tab of my ESXi4.0 host, I go to Storage, select the local datastore (datastore1), right click and select Refresh. Now the local VMFS datastore is 1120MB (1.12GB) and uses all remaining disk space.
[UPDATE] In certain occasion, you cannot grow the VMFS disk because it doesn’t exist anymore. In that case you will have to create a VMFS datastore. By default it will take all space available. The command is: vmkfstools -C vmfs3 /vmfs/devices/disks/vml.0000000000766d686261313a303a30:2
Note that you will have to add that new VMFS datastore to your host using the vCenter Client. You will be able to give it a name, for instance ‘datastore1’, and the set the block size (1MB by default).