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.

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

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 53 other followers