[root@rhce-ryanrudolf]# rm -rf / 2> /dev/null

things I break/fix for fun and learning

May 11, 2018 - 2 minute read - Comments

Additional Storage when / (root) Partition is Full

A question was raised in one of the facebook groups I frequent in that caught my attention. The question goes like this - “I have centos 7 vm and it looks like I’ve run out of space on my main partition (/dev/mapper/centos-root). Since it is a vmware vm, i can increase that drive but how would configure in linux to see the added storage?”

This has not happened to me before, and I am curious on how to solve this particular problem in case I have to deal with it. I tried to simulate this on my test VM. First thing I did is reconfigured the VM to use additional 1GB HDD. And then the rest is purely command line magic!

1 - Login to the VM. Once logged in, I issued df -h and it shows that the / partition which is /dev/mapper/centos-root has 9.8GB. After that I need to figure out which device the additonal HDD is located in. By using dmesg | grep sd , I can filter all storage devices that starts with sd. sda is the first HDD that CentOS is installed in, and sdb is the 2nd HDD that I added with 1GB of space.

2 - Next step is to create a LVM parition using fdisk /dev/sdb . Create a partition and change the partition type to 8e which stands for LVM. Write the changes and quit fdisk.

3 - Once an LVM partition is created, we need to create a physical volume from /dev/sdb1 and extend the volume group where the OS is installed. This can be achieved using pvcreate /dev/sdb1 then vgdisplay to show the volume group name, and using vgextend centos /dev/sdb1 .

4 - Once the volume group is extended, the next step is to extend the logical volume. We can use lvdipsplay to show the logical volumes. From here we need to extend /dev/centos/root . We can do it using the lvextend -L +1GB /dev/centos/root command.

5 - Finally its time to expand / grow the partition. We can do this using the xfs_growfs / command. And to verify, the output of df -h shows that the /dev/mapper/centos-root partition now has 11GB (compared to the 9.8GB size before).

And there you have it, problem solved!

Like this page? Share it!