To resize a filesystem to use the new space in a logical volume in Linux, you need to perform the following steps. Please note that these instructions assume you are using the LVM (Logical Volume Manager) system.
Here are the 3 Simple steps to resize a filesystem in a logical volume.
1. Extend the Logical Volume
First, you need to extend the logical volume to use the newly added space. Let’s assume your logical volume is named “datalv” and you want to extend it. Replace “datavg” with your actual volume group name and replace “datalv” with your actual logical volume name.
# Check the available space in the volume group
Vgdisplay
# Extend the logical volume (assuming /dev/sdb1 is the new partition)
sudo lvextend -l +100%FREE /dev/datavg/datalv
or
sudo lvresize -L +2G /dev/my_volume_group/my_logical_volume
or
sudo lvextend -L +2G /dev/datavg/datalv
2. Resize the Filesystem
Next, you need to resize the filesystem on the logical volume. The command you use depends on the type of filesystem you are using. Below are commands for commonly used filesystems.
#For ext2/ext3/ext4 Filesystems.
# Resize the ext2/ext3/ext4 filesystem
resize2fs /dev/datavg/datalv
#For XFS Filesystems.
# Resize the XFS filesystem
xfs_growfs /dev/datavg/datalv
#For Btrfs Filesystems.
# Resize the Btrfs filesystem
btrfs filesystem resize max /mnt/datalv
Replace “/mnt/datlv” with the actual mount point of your Btrfs filesystem.
3. Verify the Changes
Now, you should verify that the logical volume and filesystem have been successfully resized using following commands.
# Check the logical volume status
lvdisplay /dev/datavg/datalv
# Check the filesystem size
df -h
These commands will display information about your logical volume and confirm that the filesystem has been resized to utilize the new space in the logical volume.
Remember to replace “datavg” with your actual volume group name and “datalv” with your actual logical volume name in the commands above.
Note : Make sure to back up your important data before performing any resizing operations to avoid data loss in case of unexpected issues.
Click Here!!! to know how to create a new logical volumes from a new disk in linux.
How do you feel about this post? Drop your comments below..