To extend the size of a logical volume (LV) in Linux, you can follow these steps. This assumes you have free space available in the volume group that the logical volume is part of.
1. Check Free Space:
First, check the available free space in the volume group. You can use the following command to view the available space in the filesystem and volume group:
df -h /opt/software
vgdisplay <vgname>
This command will show you information about your volume groups, including the free space available.
2. Resize the File System:
If the logical volume contains a file system (such as ext4 or xfs), you’ll need to resize the file system before extending the LV. Use the appropriate command for your file system:
For ext4 file system:
resize2fs /dev/mapper/vg_name-lv_name
resize2fs /dev/mapper/datavg-datalv
For xfs file system:
xfs_growfs /mount_point
Replace “/dev/mapper/vg_name-lv_name” with the actual path to your logical volume or “/mount_point” with the mount point of the file system.
3. Extend the Logical Volume:
To extend the logical volume, use the “lvextend” command. For example, to extend the logical volume named “lv_name” in the volume group “vg_name” by 500Mb, you can use the following command:
lvextend -L +500M /dev/mapper/vg_name-lv_name
This command increases the size of the logical volume by 10GB. Adjust the size according to your requirements.
4. Verify the Logical Volume:
You can verify that the logical volume has been extended using the following command:
lvdisplay /dev/mapper/vg_name-lv_name
This command will display detailed information about the logical volume, including its size.
5. Resize the File System (Again, if applicable):
If you resized the file system in step 2, you don’t need to repeat this step. However, if you skipped step 2, resize the file system now to fill the available space in the logical volume.
For ext4 file system:
resize2fs /dev/mapper/vg_name-lv_name
For xfs file system:
xfs_growfs /mount_point
Make sure to replace “/dev/mapper/vg_name-lv_name” with the correct path or “/mount_point” with the appropriate mount point.
Now your logical volume has been successfully extended to the specified size. Remember, always have a backup before making any changes to your disk partitions or file systems.
Click Here!! to know how to create logical volumes in linux.
How do you feel about this post? Drop your comments below..