lvresize: command not found

lvresize is a command in Linux used to resize a Logical Volume (LV) in a Linux Logical Volume Manager (LVM) system. The command can be used to increase or decrease the size of a LV. When increasing the size of a LV, the lvresize command can also be used to resize the filesystem that is mounted on the LV, so the new space can be immediately used by the system. The lvresize command requires specifying the LV to be resized and the new size of the LV. Additionally, options can be used to specify the type of resize operation to perform and to control the behavior of the resize operation. The lvresize command is a powerful tool for managing LVM storage, allowing you to dynamically allocate, manage, and reconfigure storage as needed.

If you are running out of space and you want to add more space to your LVM volume, you can use the lvresize command to do so. To do that, unmount the volume and use the lvresize command. (Actually, it is not required that you unmount the volume to grow it, but it is done as an extra precaution.) After that, you must also check the filesystem with e2fsck and run resize2fs to resize the ext4 filesystem on that volume:

1. Umount the mount point:

# umount /data

2. Perform the resize operation:

# lvresize --size 2G /dev/vg_name/lv_name

In the example just shown, the volume and the filesystem are both resized to 2GB.

3. Run the fsck:

# e2fsck -f /dev/vg_name/lv_name

4. Next, mount the volume again and check the disk space:

# mount -t ext4 /dev/vg_name/lv_name /data
# df -h /data

If you encounter the below error while running the command lvresize:

lvresize: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install lvm2
Ubuntu apt-get install lvm2
Alpine apk add lvm2
Arch Linux pacman -S lvm2
Kali Linux apt-get install lvm2
CentOS yum install lvm2
Fedora dnf install lvm2
Raspbian apt-get install lvm2

lvresize command examples

1. To resize a logical volume (in units of logical extents)

# lvresize -l [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}]
# lvresize --extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}]

2. To do not perform fsck before resizing filesystem when filesystem requires it:

# lvresize -n
# lvresize --nofsck

3. To disable udev synchronization:

# lvresize --noudevsync

4. To resize underlying filesystem together with the logical volume using fsadm:

# lvresize -r
# lvresize --resizefs

5. To change or set the logical volume size in units of megabytes:

# lvresize -L [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]
# lvresize --size [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]

6. To gives the number of stripes to use when extending a Logical Volume:

# lvresize -i stripes
# lvresize --stripes stripes

7. To gives the number of kilobytes for the granularity of the stripes

# lvresize -I StripeSize
# lvresize --stripesize StripeSize
Related Post