Add diskspace on CentOS 6.x

This procedure will only work if your configuration is using LVM. LVM is the default used during install, so this should be ok.

Start analyzing the usage of the disks.

fdisk -l

Shows that the volumes are on e.g. /dev/sda and that you are using an LVM system.

fdisk /dev/sda

In fdisk, create a new volume by pressing ‘n’. Create new primary partition (extended partition is not tested but should work). Change partition type by pressing ‘t’. Select partition type ‘8e’, this is Linux LVM.
Write down the results by pressing ‘w’ key. In case of doublt, press ‘m’ key to get help.

Now we need to re-read the partition table. Ether we restart the services or do a reboot.

shutdown -r now

After restarting the services, we check if all is ok and then proceed by creating the ‘Physical Volume Group’. The pvs command will show if it was created correctly. The example below assumes that your new partition is called /dev/sda4.

fdisk -l
pvcreate /dev/sda4
pvs

Now extend the volume group. Example assumes that name is VolGroup00, but fdisk will show you the exact name to be used. In case of doubt and you only have one volume group, the command vgs will show its name.

vgextend VolGroup00 /dev/sda4

Now extend its space, type the command vgdisplay to get the number of blocks to be extended. It should be displayed next to the label Free PE / Size. The example below assumes it shows Free PE / Size 3190 / xxxx.

vgdisplay
lvextend -l +3190 /dev/mapper/VolGroup00-LogVol00

After doing this, resize the file system. The command resize2fs assumes you are using ext4 which is the default.

resize2fs /dev/mapper/VolGroup00-LogVol00

Now check available disk space. It should be increased.

df

After finishing, do not forget to restart services or reboot.

shutdown -r now

Done !

Leave a Reply