Linux: Increasing the size of a file system on Linux

Increasing the size of a file system on Linux that is managed by Logical Volume Manager (LVM) involves several steps. Here’s a general guide assuming you’re working with an LVM-managed file system:

Steps to Increase File System Size Using LVM:

1. Check Current Disk Space:

df -h

2. Check LVM Configuration:

sudo vgdisplay # List volume groups sudo lvdisplay # List logical volumes

3. Extend the Logical Volume:

  • Identify the logical volume (LV) associated with the file system you want to extend.

sudo lvextend -l +100%FREE /dev/vg_name/lv_name

Replace vg_name with your volume group name and lv_name with your logical volume name.

4. Resize the File System:

  • Resize the file system to use the new space.
    • For ext4:bashCopy codesudo resize2fs /dev/vg_name/lv_name
    • For XFS:bashCopy codesudo xfs_growfs /mount_point

Replace /mount_point with the actual mount point of your file system.

5. Verify the Changes:

df -h

That’s it! You’ve successfully increased the size of your file system using LVM. Make sure to replace vg_name and lv_name with your specific volume group and logical volume names.

Example:

Let’s assume you have a volume group named vg_data and a logical volume named lv_data that you want to extend.

# Check current disk space df -h # Check LVM configuration sudo vgdisplay sudo lvdisplay # Extend the logical volume sudo lvextend -l +100%FREE /dev/vg_data/lv_data # Resize the ext4 file system sudo resize2fs /dev/vg_data/lv_data # Verify the changes df -h

Make sure to adapt the commands based on your specific volume group and logical volume names, as well as the file system type you are using. Always perform these operations with caution and have backups available, especially when dealing with critical data.

Leave a comment