How to expand disk capacity for vmware linux virtual machine
First, make a clone of the vmware linux virtual machine. So even if you make serious mistake during the process, you still have all your data.
By default installation, linux virtual machine (Fedora, RHEL or CentOS) has two partitions, one for swapping, and the other one is a lv partition. The lvm partition mount as /, and cannot be resized by partition tools such as partition magic or gparted.
Before expansion, as shown below, we were almost run out of disk space:
The logical volume /dev/maper/VolGroup00 only has 16% free space.
Open virtual machine's settings, select hard disk and click "Utilities" button, and select "Expand":
Expand the disk size to 20GB:
Boot up, open a terminal and run
Type "n" and hit enter. Then press "p" to create a primary partition. It asks you for a partition number, enter "3". Now you are asked which cylinder the partition should start at, the beginning of the drive is the default, so just hit Enter. Then you are asked for the last cylinder, the end of the drive is default so you can just press Enter again. Here are the commands and results inside fdisk:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (1045-2610, default 1045): Using default value 1045 Last cylinder or +size or +sizeM or +sizeK (1045-2610, default 2610): Using default value 2610 Command (m for help): p 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 1044 8281507+ 8e Linux LVM /dev/sda3 1045 2610 12578895 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table.
After fdisk is done, reboot.
If system-config-lvm is not installed, use this command to install it first:
yum install system-config-lvm
Launch system-config-lvm, as in the following image, select "Partition 3" under the "Uninitialized Entities", then press "Initialize Entity" button to initialize it.
After this partition being initialized, it appears under the "Unallocated Volumes" node:
Press the "Add to existing Volume Group" to get it to join the "VolGroup00".
After it is done, select the logVol00 under VolGroup00, then press "Edit Properties" button:
Press the "Use remaining" button to make it use all the capacity, and then press the "Ok" button:
Now we have resized the disk capacity. Run df command to verify it:
Please feel free to contact email@example.com if you have any questions.
Tags: LVM, VMWARE, RESIZE, FDISK