Today we will look at one of the useful tip to understand how to extend logical volume on RHEL/CentOS with a single command on production servers.
Lets see the process stepwise to understand it easily.
1. First check the partition or LV which we want to increase.
[root@ngelinux001 log]# df -h /var Filesystem Size Used Avail Use% Mounted on /dev/mapper/rootvg-varlv 15G 12G 2.2G 85% /var
2. Extend the Logical Volume
[root@ngelinux001 log]# lvextend -r -L +3G /dev/mapper/rootvg-varlv Size of logical volume rootvg/varlv changed from 15.00 GiB (480 extents) to 18.00 GiB (576 extents). Logical volume varlv successfully resized. resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/rootvg-varlv is mounted on /var; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/mapper/rootvg-varlv to 4718592 (4k) blocks. The filesystem on /dev/mapper/rootvg-varlv is now 4718592 blocks long.
3. Check the increased size now.
[root@ngelinux001 log]# df -h /var Filesystem Size Used Avail Use% Mounted on /dev/mapper/rootvg-varlv 18G 12G 5.0G 71% /var [root@ngelinux001 log]#
In the above command, we can see the,
a. “-r” option performs the resize2fs and,
b. “-L” mentions the exact size how much size we want to increase on this partition.