Logical Volumes give the system administrator virtually infinite possibilities to play with the storage sizes. They can be shrunk, extended ,and arranged to fit any need- given there is enough space on the physical disks.
We have discussed the partitions and logical volumes in our previous article (I suggest you read our “An Introduction to Partitions and Logical Volumes” article if you do not feel comfortable with these terms). Now we will build top of that and will see how we can change the logical volume sizes.
If you are setting up logical volumes when installing a Linux distribution from scratch, make sure that the /boot directory is on a separate partition. If you place /boot in a logical volume, you will end up with an unbootable system because the Linux bootloader cannot read /boot from a logical volume.
As far as the logical volumes are concerned, note that a logical volume can contain more than one physical volume, but a physical volume cannot be contained by more than one logical volume.
Given that we have touched the logical volume configuration basics, we can now go on with changing their sizes.
When you will increase the logical volume size, you will either set the size of the logical volume or extend it with the size you want. In any case, we will use the command lvextend for systems other than Red Hat.
Before using lvextend with an example, let's see our notation:
- The volume group is named logvol01 and is mounted under /dev and in volgrp01 (the mountpoint is /dev/volgrp01/logvol01)
- We will increase the logical volume to the space available in /dev/sdb1, assuming we have installed another disk on the system
- The present size of the logvol01 is 200 Gigabytes and we want to extend it to 500 Gigabytes by adding the 300 Gigabytes on /dev/sdb1
- Of course, /dev/sdb1 must have at least 300 Gigabytes of free space, and
- We have already made /dev/sdb1 a member of volgrp01.
When we have completed all above, we can use the lvextend command as follows to:
- Set size to 500 GB: lvextend -L500G /dev/volgrp01/logvol01 /dev/sdb1
- Increase size by 300 GB: lvextend -L+300G /dev/volgrp01/logvol01 /dev/sdb1
- To use all available space in /dev/sdb1: lvextend /dev/volgrp01/logvol01 /dev/sdb1 (note that there is no option set for the lvextend command)
To make the command run in verbose mode, you can use the additional -v option.
For the users running Red Hat systems, it will be better to utilize Red Hat's Disk Druid tool, which is a graphical tool to group and ungroup logical volumes and change their sizes.
Read on for increasing the filesystem size and deploying the new logical volume size.