Hardcore Linux

Anything about Ubuntu, Centos, openSuSe and Fedora

How to resize a VMWARE virtual disk

More often the initial disk space for your vmware devices is not enough in the long run and you wish extend its current capacity. I’ve  tried few tutorials I googled, but most of them are either not working for me or too complex to follow, and some commands are really not necessary.

So here’s my version of increasing your vmware virtual disk from linux for a vmware linux guest OS.

  1. First, check the current capacity of your vmware disk/drive. Start your guest OS and on console perform the following:

fdisk -l /dev/sda1 # or the device address of your vmware vdisk  on your guest OS.

it will response to something like this:

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14          77      514080   82  Linux swap / Solaris
/dev/sda3              78        1044     7767427+  8e  Linux LVM

2.  Keep this in mind for future reference, now shutdown the guest OS.

shutdown -r now

3.  On your host OS (the one the serves your virtual devices), perform the following as root:

vmware-vdiskmanager -d myvirtual/myvirtual.vmdk # this will defrag the virtual disk.

and then followed by

vmware-vdiskmanager -x 30GB myvirtual/myvirtual.vmdk #resize the virtual device’s virtual disk.

4.  Now, test your  guest OS if it can still normally boots and on the console enter:

fdisk -l /dev/sda

5.   Compare the old value  to the new one, confirm if it successfully resize the partition.

6.  In my case, an LVM drive, you can perform the following to check the current status of your volumes:

pvdisplay  #To check the physical volume partition

lvdisplay #to check the  status of your volumes

vgdisplay #to display the status of your logical volume

7.  When creating server’s on vmware, doing it on LVM is a good way to safely increase or decrease the storage capacity of your guest OS.

8. Add an lvm physical partition, in my case it will be /dev/sda4 and add it in the current LVM volume group.

9. Now you can perform lvextend to resize your current logical volume capacity.


lvextend -L+10G /dev/base/system

10. Restart your guest OS and its done.


7 responses to “How to resize a VMWARE virtual disk

  1. hardc0l2e May 20, 2009 at 6:35 am

    sadly no comments

  2. Pingback: Resizing an LVM in a CENTOS VMWare Guest « creechy iv: a new hope

  3. ccv December 28, 2011 at 10:04 am

    thanks for nice tip. also, how to extend if we dont hv LVM and need to extend FS on disk directly.

  4. rdd972 January 14, 2013 at 10:33 pm

    still looking for a solution to update disk changes without rebooting the OS, like Windows 2003 and AIX 5L can do…

  5. charlie February 2, 2013 at 7:21 am

    When I try to extend, I got the following error in my VM Guest (Centos)
    lvdisplay — No volume groups found

    So I cannot perform the lvextend command…

    pvdisplay displays:

    “/dev/sda4” is a new physical volume of “10.00 GiB”
    — NEW Physical volume —
    PV Name /dev/sda4
    VG Name
    PV Size 10.00 GiB
    Allocatable NO
    PE Size 0
    Total PE 0
    Free PE 0
    Allocated PE 0
    PV UUID qBoJjc-xmAS-9NZZ-Ta9h-FfIP-PjgX-omrh4G

    why I cannot see the volume information?


  6. Jostein Toftebakk (@JosToftebakk) February 22, 2013 at 11:45 pm

    Thanks a lot! I couldn’t figure out how to extend the volume group using the free space. Point 8 made me realize how to do it.

  7. ben@geekswing.com April 27, 2013 at 1:48 am

    Without LVM you cannot extend live (per the first comment). You will need to shutdown, extend disk, and use a tool like gparted (bootable utility) to extend the disk.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: