How to Extend Logical Volume (LVM) in Linux Easily

How to Extend Logical Volume (LVM) in Linux

If you are looking for How to extend or how to increase logical volume in linux on lvm. Here we have described the commands to extend a logical volumes on Linux.


Prerequisites:

Ensure that we have enough free space on Volume group (Example : vg01) to extend Logical Volume using the command.

vgdisplay vg01

or

vgs

How to extend Logical Volume? or How to increase logical volume?

Assume that We have filesystem "/dev/vg01/lvol1" with size 40Gb and we need to increase the size by 10Gb.

There are two ways to extend LV.
1. Extend to exact size 50Gb
2. Extend by the size 10Gb

Use "lvextend" command to extend / increase a logical volumes on LVM.

1. Extend to exact size

# lvextend -L50G /dev/vg01/lvol1
lvextend -- extending logical volume "/dev/vg01/lvol1" to 50 GB
lvextend -- doing automatic backup of volume group "vg01"
lvextend -- logical volume "/dev/vg01/lvol1" successfully extended

Above command will extend the logical volume "/dev/vg01/lvol1" to total 50Gb.

2. Extend by the size.

If you want to increase the logical volume by 10Gb additional to existing 40Gb.

# lvextend -L+10G /dev/vg01/lvol1
lvextend -- extending logical volume "/dev/vg01/lvol1" to 50 GB
lvextend -- doing automatic backup of volume group "vg01"
lvextend -- logical volume "/dev/vg01/lvol1" successfully extended

Above command will increase the logical volume "/dev/vg01/lvol1" to total 50Gb.

After extending the logical volume, its mandatory to increase the filesystem in partition table to match. Because now it will show the logical volume size as 50Gb, But when you do "df -h', it wont show you the extended size.

Use resizing tools to increase the filesystem size to match the extended size. For each filesystem, we have different tools.

For ext2/ext3/ext4, use resize2fs command.

resize2fs /dev/vg01/lvol1

For reiserfs, use resize_reiserfs command.

Reiserfs file systems can be resized online.

resize_reiserfs -f /dev/vg01/lvol1

For xfs, use zfs_growfs command.

XFS file systems can be resized online.

xfs_growfs /dev/vg01/lvol1

That all about how to extend or increase logical volume on LVM.

Related Content on Linux might be useful to you to improve your Linux Skills.


Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.

إرسال تعليق

0 تعليقات