How to increase the size of a local datastore … on an ESXi4?


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:
esxcfg-scsidevs -l
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:

fdisk /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0

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).

Job done!

Advertisements

About PiroNet

Didier Pironet is an independent blogger and freelancer with +15 years of IT industry experience. Didier is also a former VMware inc. employee where he specialised in Datacenter and Cloud Infrastructure products as well as Infrastructure, Operations and IT Business Management products. Didier is passionate about technologies and he is found to be a creative and a visionary thinker, expressing with passion and excitement, hopefully inspiring and enrolling people to innovation and change.
This entry was posted in Uncategorized. Bookmark the permalink.

23 Responses to How to increase the size of a local datastore … on an ESXi4?

  1. Pingback: Tweets that mention How to increase the size of a local datastore … on an ESXi4? « DeinosCloud -- Topsy.com

  2. Vladan says:

    Great How-to Didier.

    Definetely bookmark worth. Is there another way doing it? Through the VMA I guess.

    I wonder if one could just save the configuration of ESXi with: /sbin/auto-backup.sh

    Then reinstall with larger drives and restore the conf…But never tried..-:).

    • deinoscloud says:

      Thx for your comment Vladan!
      I haven’t figured out yet how to manipulate disk partition tables through a vMA appliance :O
      Even VMware uses regular Linux tools like fdisk.
      If anyone has a idea, please post a comment I’m willing to know how to do that…

  3. Pingback: Speed Up Your Home Lab With a SD Card – How To? « DeinosCloud

  4. Evan says:

    Good post!

    esxcfg-scsidevs –compact-list will show you the Console Device.

    esxcfg-scsidevs –compact-list

    naa.60a980005033572f4b5a2f59386e7537 Direct-Access /dev/sdk 71687MB NMP NETAPP Fibre Channel Disk (naa.60a980005033572f4b5a2f59386e7537)

  5. borito says:

    Good post 🙂

    I have just one important question ;p

    With this commands, can i lose my vm?

    • deinoscloud says:

      There is a risk definitely!
      So I would not advice you to try this without a proper backup…
      Sorry 😦

  6. borito says:

    ok thanks, i have expand the datastore whith vsphere client. the lun was correctly detected.

    But on my own server 4.1 also i can’t do the same because the lun is not detected

    http://hpics.li/6c5b13f

    This is an another problem 🙂

    • deinoscloud says:

      If I’m not wrong extend and expand are two different things.
      If you expand, you combine several LUNs to form one big datastore.
      In your case, and again if I’m not wrong, you want to extend an existing LUN with more disk space and then extend the datastore to benefit from this disk space, am I correct?

  7. borito says:

    yes but, as i can’ see my disk (look my picture) , i can’t increase it.
    bug vmware?

  8. Steve says:

    Very good walk though. I did find one command not listed to give you the NAME used in growing the file system command. vmkfstools –growfs /vmfs/devices/disks/vml.0000000000766d686261313a303a30 This is found by using the (esxcfg-scsidevs -l) command, look for “Other Names:” Otherwise, dead on!

    Thanks

  9. Pingback: 实战给装了 VMWare ESXi 的 DELL PERC H700 添加硬盘 « 用科技创造明天

  10. Cor says:

    Cool, worked great for me on ESXi 4.1.
    The partition number of my partion was 3 instead of 2, but again, worked witout a problem.
    Thanks!

  11. Diego Saez says:

    Great job!!! It worked oh ESXi 4.1 for me too!!!
    I was looking in a lot of websites and blogs and everybody was telling me that I’ve to reinstall ESXi.

    Thanks for your help!

  12. Sean Yee says:

    Wow it’s very promising for my current project.
    Thank you “deinoscloud”

    Hi all,

    Here is what I am trying to do:
    I’ve added 3Hard Disks into existing RAID.
    As you can see the Disk Space is grown from 1798.6 GB to 3597.3 GB.
    But unfortunately I can not make use of the added spaces.
    My question is whether I can use newly added space into datastore1 or add new datastore2 using the new sapce WITHOUT reinstalling Esxi 4.1.
    So far, Dell tech support is saying that I have to backup and wipeout everything and reinstall Esxi 4.1 from the scratch in order to make use of the total available storage.

    Can anyone give advise?

    ———————————————–
    ~ # fdisk -lu (BEFORE adding 3 Hard Disks)
    ———————————————–
    Disk /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11: 1798.6 GB, 1798651772928 bytes
    64 heads, 32 sectors/track, 1715328 cylinders, total 3512991744 sectors
    Units = sectors of 1 * 512 = 512 bytes

    Device Boot Start End Blocks Id System
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p1 8192 1843199 917504 5 Extended
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p2 1843200 10229759 4193280 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p3 10229760 3512991743 1751380992 fb VMFS
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p4 * 32 8191 4080 4 FAT16 <32M
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p5 8224 520191 255984 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p6 520224 1032191 255984 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p7 1032224 1257471 112624 fc VMKcore
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p8 1257504 1843199 292848 6 FAT16

    ———————————————–
    ~ # fdisk -lu (AFTER adding 3 Hard Disks)
    ———————————————–

    Disk /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11: 3597.3 GB, 3597303545856 bytes
    64 heads, 32 sectors/track, 3430656 cylinders, total 7025983488 sectors
    Units = sectors of 1 * 512 = 512 bytes

    Device Boot Start End Blocks Id System
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p1 8192 1843199 917504 5 Extended
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p2 1843200 10229759 4193280 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p3 10229760 3512991743 1751380992 fb VMFS
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p4 * 32 8191 4080 4 FAT16 <32M
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p5 8224 520191 255984 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p6 520224 1032191 255984 6 FAT16
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p7 1032224 1257471 112624 fc VMKcore
    /dev/disks/naa.6782bcb049b62c0015e129ac5f8e3d11p8 1257504 1843199 292848 6 FAT16

    • deinoscloud says:

      Hi Sean and thx for your comment.

      You can add a new disk space as datastore2
      You can then eventually add the new space to datastore1 as an extend, but this needs confirmation.

      And finally you can use the technique in my post to increase the disk space of datastore1 up to 2TB-512 Bytes only (vSphere 4.1 maximums).
      N.B. If adding as an extend you can go up to 64TB for a single datastore.
      Now here is my statement to cover my ass. I do not recommend this for production systems, nor for any systems actually, unless you understand what your doing AND you have a proper backup. Use at your own risk!

      Personally I would go for the extend but not sure if it works for you.

      Keep us posted 😉

      • Sean Yee says:

        Hi Deinoscloud,

        So practically, I could not add 1.5TB to existing datastore1(1.6TB) due to 2TB limit.
        My question is then if I can create new datastore, i.e. datastore2, from linux?
        Currently the newly added space (1.5TB) doesn’t belong to datastore1 nor datastore2, and sits there doing nothing.

        If I can create datastore2, that means I don’t have to touch, remove,etc for datastore1, which is great.

        Can you guide me for proper commands in creating datastore2?

        Thanks
        Sean Yee

        • deinoscloud says:

          Hi Sean,

          Use fdisk on the device /dev/disks/naa.xxxx
          Create a new partition with type 0xfb.
          Format the new VMFS datastore using vmkfstools -C vmfs3 /dev/disks/naa.xxxxpx
          Attention, format the correct partition (px)

          And don’t forget to have a backup… Use at your own risk.

  13. Pingback: A Year Of Blogging In Summary And Season’s Greetings | DeinosCloud

  14. J-P says:

    vmkfstools -growfs gives me:
    Underlying device has no free space
    Error: No space left on device

  15. D.T. says:

    I just wanted to give a shout out to you for this article. You did a great job! Saved my client and made me look good at the same time! Thank you!

  16. Pingback: How to increase the size of a local datastore … on an ESXi4? | Quelques liens utiles … ;)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s