📜  lvm resize ext4 - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:32:46.316000             🧑  作者: Mango

LVM Resize Ext4

LVM (Logical Volume Manager) is a tool used to manage disk devices and volumes on a Linux system. It allows the creation of logical volumes that can span across multiple physical disks, providing flexibility in storage management.

Ext4 is a commonly used file system in Linux distributions, known for its performance and scalability.

LVM resize ext4 is the process of resizing an Ext4 file system that is managed by LVM.

Steps to resize an Ext4 file system with LVM
  1. Identify the logical volume and file system that needs to be resized using the lsblk command:

    $ sudo lsblk
    NAME            MAJ:MIN RM  SIZE  RO  TYPE  MOUNTPOINT 
    sda                   8:0   0    20G  0    disk
    └─sda1                8:1   0    20G  0    part  /
    sdb                   8:16  0    10G  0    disk
    └─sdb1                8:17  0    10G  0    part
      └─vg1-lv1          253:0  0    5G   0    lvm   /mnt/lv1
    

    In this example, we have a logical volume named vg1-lv1 that is mounted on /mnt/lv1.

  2. Resize the logical volume with the lvresize command:

    $ sudo lvresize -L +5G vg1/lv1
    

    This command will increase the size of the logical volume vg1-lv1 by 5GB.

  3. Resize the file system with the resize2fs command:

    $ sudo resize2fs /dev/vg1/lv1
    

    This command will resize the Ext4 file system on the logical volume to match the new size of the logical volume.

  4. Verify that the file system has been resized using the df command:

    $ df -h /mnt/lv1
    Filesystem        Size  Used Avail Use% Mounted on
    /dev/mapper/vg1-lv1  9G  3.9G  4.6G  46% /mnt/lv1
    

    The output should show the new size of the mounted file system.

Conclusion

LVM resize ext4 is a simple process that can be performed to increase the size of a logical volume and its Ext4 file system. It is important to make sure that there is enough disk space available before resizing a file system. Also, it is recommended to have a backup of any important data before performing such operations.