37

How To Resize/Grow VMware Linux Disks and Partitions


Posted by Artem Russakovskii on August 10th, 2007 in Linux
Share

Updated: January 18th, 2009

Update 01/16/2008: This method does not work for LVM partitions, as discovered in the comments.

In this article, I will show how to resize a VMware disk if you didn't make it large enough when it was created. Furthermore, I will show how to resize partitions following the disk augmentation using OpenSUSE 10.2 as an example. You will even be able to resize the Linux root partition (/) that is mounted and is normally unmountable.

The story: this is simple – you made a VMware disk without thinking ahead and now it ran out of space. Here you have a few options, the most notable ones being create another disk and mount it or grow the existing disk and resize the existing partitions. The first option is trivial, so let's explore the 2nd one.

1. Backup the existing VMware disk file by copying it somewhere safe.

2. Grow the VMware disk file (note that I'm using Windows in this step because my host system is Windows XP). In order to do this, use the 'vmware-vdiskmanager.exe' utility that comes bundled with VMware and most likely sits in C:\Program Files\VMware\VMware Workstation. If the target size of the new disk is 10GB, issue the following command:

vmware-vdiskmanager.exe -x 10Gb "YOUR_DISK.vmdk"

The disk will crunch for a bit and hopefully happiy finish with Grow: 100% done. Now the maximum disk space has been increased to 10GB. At this point, all partitions remain the same size, with a bunch of unpartitioned free space added at the end of the disk.

3. Now you can boot the guest OS (OpenSUSE 10.2 in my example) and use some magical utility to resize your partitions. In YaST, for instance, you would go to System->Partitioner. You can resize pretty much any partition that can be unmounted (unmount it beforehand and never try to repartition a mounted one). That represents a problem if you, like me, want to grow the root partition /. Still with me? Then let's go to the next step.

4.

a) In order to repartition or resize a root partition, I will use a LiveCD of another OS. Or even better, a LiveCD that lives and breathes resizing things left and right. I'm talking about the GParted Live CD from http://gparted.sourceforge.net/livecd.php. Since a LiveCD is an operating system on its own loaded into RAM, it won't need to mount any of your existing partitions. There's a bug with the latest version 0.3.4-8, which prevents GParted from seeing any partitions in VMware systems at all, but 0.3.4-5 works like a charm. Download the ISO image, right click on the CD/DVD icon in the lower right part of the VMware window and click Edit. Then change the Connection to "Use ISO image" and browse to the freshly downloaded GParted ISO. This will effectively mount the image without having to burn it onto a CD.

b) Reboot the guest OS. Quickly press F2 on the VMware preboot load screen to enter the virtual VMware BIOS. Go to the Boot tab and bring the CD-ROM drive to the top by scrolling to it and clicking + repeatedly. Now save and exit. The next time the OS tries to boot, it will first try to load the LiveCD, which is exactly what we want.

c) GParted should load after a few minutes where everything should be very straightforward. The screenshots here may help understand what I'm talking about. Fiddle with the settings, increase the root partition size, click Apply, and go have a few beers because this may take a while to finish. When it does, so are we, as we now have successfully grown the root partition.

d) Optionally revert the steps in part 4a and 4b.

5. Reboot into the guest OS again. Enjoy all the new extra space.

This concludes the article. Feel free to leave any questions or comments.

● ● ●

Artem Russakovskii is a San Francisco programmer, blogger, and future millionaire (that last part is in the works). Follow Artem on Twitter (@ArtemR) or subscribe to the RSS feed.

In the meantime, if you found this article useful, feel free to buy me a cup of coffee below.


  • Share/Bookmark

37 Responses to “How To Resize/Grow VMware Linux Disks and Partitions”

    37 Comments:
  1. pY says:

    Thanks a lot. Very clear and concise indications on how to procede. Exactly what i was looking for.

  2. Tomslin says:

    Thanks for the howto.I'll like to know how I can do this with my host being linux,as i see no tool like vdiskmanager on my linux vmware install.

  3. Tomslin, I just installed VMWare Workstation v6.0.3 on my Linux server and the following commands became available:

    vmware vmware-authd vmware-loop vmware-ping vmware-uninstall-vix.pl vmware-vdiskmanager vmware-acetool vmware-config.pl vmware-mount.pl vmware-tray vmware-uninstall.pl

    I needed to install the kernel-source package in order to complete the installation.

    Perhaps you're using the VMWare Player, which may or may not include vmware-vdiskmanager.

  4. Steven White says:

    Hello,

    I attempted what you've described but ran into a problem. When I boot up the LiveCD of gparted, after it boots into where my guest OS should be, gparted doesn't see any available devices.

    Is there a way to force gparted to look to the 'hard disk' that should contain my VM?

    system info…
    host OS: CentOS running VMWare server
    guest OS: Ubuntu 6.06

    My guest OS does boot properly and all apps will run across the network. Of course I didn't set aside a larger enough file system for my mail service. Which is why I'm here now.

    And I've already successfully enlarged the VM from 20GB to 40GB.

    I hope you can help.

    Cheers,
    Steven

  5. Steven, what gparted version are you using?

  6. Steven White says:

    I'm using 0.3.6-7. Any known problems w/this version?

  7. Steven, re-read #4A again, very carefully :P

  8. Roman says:

    Thanks a lot Artem,

    Your solution is brilliant. Worked fine for us and saved us a lot of time.

    Cheers,
    Roman

  9. Glad to be of service, Roman.

  10. Douglas Held says:

    On Mac OS X with VMWare Fusion 1.1.3, the utility is /Applications/VMWare\ Fusion.app/Contents/MacOS/diskTool , and the grow argument is big X, not little x.

    Thanks for the help, Artem.

  11. Carpii says:

    Hi, Im struggling a bit.

    GParted shows I have an ext3 partition (label /boot) of 100 meg, followed an unknown partition.

    The unknown partition should be appearing as etx3 too, its the root partition. But gparted wont recognise it, so I cant resize it :(

    Any ideas please? Im using gparted 0.3.4-5 as instructed

    Thanks

  12. Carpii, I'm afraid this is not something I personally can help you with and the question is better directed at the developers in their forum: http://gparted.sourceforge.net/forum.php.

    Good luck.

  13. Amski says:

    With VMWare Fusion (Mac), you can grow your disk size using the GUI. Select your VM machine, enter properties, select disk and resize. Of course VM machine must be shut down first (and you cannot have a snapshot attached to it).

    Also, for those of us who cannot press the F2 key fast enough during the VM machine's boot sequence to actually get BIOS instead of GRUB screen, you can edit the ".vfx" file and set "bios.bootDelay" property to some larger value. This makes VM machine wait longer at the initial boot screen, giving one more time in which to press F2.

    Artem, thanks for this write up. It was of great help :-)

  14. @Amski
    Thanks for the extra info for you fancy Mac people.

  15. M Hahn says:

    Hi,

    with VMWare 2 does not bring the BIOS (at least not for me). Rather you need to select: show BIOS at boot directly from VMServer

    Cheers,
    Matthias

  16. Vim Toutenhoofd says:

    I run Ubuntu 8.04 in a VMware Workstation virtual machine hosted by Windows XP on a ThinkPad G41. I had no luck with gparted-live-0.3.9-4.iso, which is an image of the current version of that utility. It made me wonder if that bug you referred to has not yet been fixed. I then tried the version which worked for you (gparted-livecd-0.3.4-5.iso), which indeed allowed me to enlarge the partitions on my virtual hard disk. Thanks for your article!

  17. Ed says:

    FFS.. I have followed the instructions.. and tried it with

    gparted-live-0.3.9-4.iso
    and
    gparted-live-0.3.4-5.iso
    and a couple others…

    and neither worked. I always get unrecognized FileSystem X\

    I'm trying to run a CentOS 5.2 VM on a Mac X\

  18. Michael says:

    Thanks for the information. Turns out that the latest version of gparted does not see VM partitions. Use the version you suggested and it works great. Once again, thank you.

  19. Keith says:

    Thanks, great article which helped me fix my problem!!!

  20. @Carpii, Ed, and others having a problem with GParted not seeing the partition (shows unknown)

    I just tried a default CentOS installation and realized I didn't give it enough space. Booting into any version of GParted showed the / partition as "unknown".

    Well, the problem is due to CentOS making it LVM by default. According to GParted, LVM is not supported. I've yet to find a solution. :(

  21. Tilman Schmidt says:

    You don't even need GParted with LVM. Instead, in step 3 you just use fdisk to create a new partition from the added space, pvcreate to make a PV from it, and vgextend to add it to your VG.

  22. luis benitez says:

    Sweet!!! Works like a charm.. thanks for the tip!

  23. Simon Shaw says:

    Tilman,
    I did what you said with LVM and I can see that the volume has increased in size from 7.5GB to 11.28GB as shown below, however when I run df -h the partition that I was originally trying to remains 7.2GB. Any ideas?

    lvdisplay
    — Logical volume —
    LV Name /dev/VolGroup00/LogVol00
    VG Name VolGroup00
    LV UUID qti2mM-XkDw-LPC1-ARJv-nLAs-YcTL-4zrCuP
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 11.28 GB
    Current LE 361
    Segments 2
    Allocation inherit
    Read ahead sectors auto
    – currently set to 256
    Block device 253:0

    df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
    7.2G 6.3G 536M 93% /
    /dev/sda1 99M 18M 77M 19% /boot
    tmpfs 744M 0 744M 0% /dev/shm
    /dev/hdc 278M 278M 0 100% /media/New

  24. Taheireem says:

    hi,
    I followed the steps downloaded the same version of gparted LiveCD,after booting i can see inside the gparted window:
    Partition:Filesystem:Label:Size:Used;
    /dev/sda1:ext3:/boot:101MB:12MB;
    /dev/sda2:ext2:/:3.4GB:3.2GB;
    /dev/sda3:Linux-Swap: :500MB:120MB;
    unallocated:unallocated: : :–:–;

    but i cant resize the "/" partions,even this partition is unmounted.

  25. Taheireem says:

    i think i made it ,it was LINUXSWAP partitions in the middle of /dev/sda2 and unallocated space,anyway thanks for the above procedure.

  26. Vzzuv says:

    Thanks a lot! Great article, very helpful.

  27. cmg says:

    @Simon Shaw (or in fact anyone who is having similar LVM difficulties): I encountered the same problems. I managed to solve the problem eventually as follows (WARNING, there may be errors here. I can't retrace my steps precisely having done everything via liveCD. You should investigate all steps, command usage, etc. yourself. I also recommend backing up your virtual disk before proceeding, it saved me a lot of tears :-) Also, some parameters [e.g. /dev/sda/, VolGroup00] may differ for you):
    1) Change size of VMWare virtual disk through the VMWare interface
    2) Start your VM from a live CD. (Press esc on boot with centOS).
    3) Use fdisk to add a new LVM partition. ('n' to create a new partition, select 'p' for primary, 3 [or whatever] for 3rd primary partition, 't' to modify partition's system id to 8e [LVM]). Not sure if the modification of the partition's system id was necessary… did it anyway just to be safe.
    4) Use pvcreate to intialise this partition for use by LVM
    $ pvcreate /dev/sda3
    5) Use vgextend to add it to your volume group
    $ vgextend VolGroup00 /dev/sda3
    # Thanks is obviously due to Tilman Schmidt for the
    # above few steps
    6) Use lvextend to extend the LV:
    $ lvextend -L20G /dev/mapper/VolGroup00-LogVol00
    # extend to 20GB
    7) Unmount and resize fsg
    $ umount /dev/mapper/VolGroup00-LogVol00
    $ resize2fs /dev/mapper/VolGroup00-LogVol00
    # after trying resize2fs I was prompted to do a filesystem check before proceeding. If this happens, do this, and try again.

    # http://tldp.org/HOWTO/LVM-HOWTO/extendlv.html for last 2 steps

  28. Robson says:

    Hi

    I need to resize a Linux "/" filesystem but to reduce and recover disk space not to increase.
    The recovered disk space is to be used to create othe VMware machines on the same VMware host.
    The guest OS is Red Hat Enterprise Linux AS (v. 4 for 64-bit AMD64/Intel EM64T) the VMWare host is also Linux.
    I have read your article but dont know how to use it to reduce and use freed disk space.
    Thanks for any help

  29. Muhammad Ali says:

    My host operating system is Windows 7, I made a VM ware image of linux os(guest os) which resides in my c drive.

    The size of the vm ware image is about 200 GB I would like to extend it to 220 Gb.

    Shall I need live cd or can I do it through vmware-vdiskmanager.exe utility.

  30. Muhammad Ali says:

    I tried to resize the vmdk file after 24% completion received the following error.

    C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager -x 220Gb "c
    :\apps12vm\Red Hat Enterprise Linux 5.vmdk"
    Grow: 24% done.Failed to expand the disk 'c:\apps12vm\Red Hat Enterprise Linux
    5.vmdk': Unknown error (0x45d000900000001).

  31. Jacques says:

    Hello, all seems clear enough but when i try to resize my partition Gparted stops after 1 second saying he is unable to resize (forbidden sign)
    I'm using gparted 0.5.2-9 iso and trying to resize a WS2003 ntfs partition (system). Did i something wrong ?

  32. Dan says:

    Thank you for a good guide.
    Instead of issuing the "vmware-vdiskmanager.exe -x 10Gb "YOUR_DISK.vmdk" command its now possible to change that setting inside wmware.

  33. Av8r says:

    Hi,

    Everything for me went fine, except the last step. After I reboot my Windows VM, in Disk Management it shows the new size for C:\ has grown from 4G to 8GB, but the hard disk C:\ in windows explorer still says 4GB.

    Am I missing something?

    Thanks

    • Well, the procedure here describes a Linux partition resizing – I'm not familiar with resizing a Windows drive, but my guess would be you need to resize it in Windows as well – open up Administrative Tools in Control Panel and go to Computer Management > Disk Management.

      • Av8r says:

        Administrative Tools in Control Panel and go to Computer Management > Disk Management shows 8GB, on the disk image but when you right-click on the disk and go to properties, it only sees 4GB.

        The text area which lists Volume, Layout, Type, …. , Overhead is showing 4GB. Wierd??

Leave a Reply