FreeKB - Linux Commands Resize an LVM logical volume using the LVRESIZE command
Linux Commands - Resize an LVM logical volume using the LVRESIZE command

Before resizing a logical volume, you'll need to ensure the physical volume has available space.

The lvresize command can be used to add or remove space from an LVM logical volume. For example, let's say /dev/myVG/myLV is 1 GB.

~]# lvdisplay
. . .
LV Size    1.0 GiB

 

Increase size

When increasing the size of a logical volume, there is no need to unmount the volume. The --resizefs flag and the --extents option can be used to add extents to the logical volume. In this example, the logical volume will use all of the available extents.

~]# lvresize --resizefs --extents +100%FREE /dev/myVG/myLV

 

The --resizefs flag and the --size option can be used to increase the size of the logical volume. In this example, the logical volume is increased to 2 GB.

~]# lvresize --resizefs --size 2G /dev/myVG/myLV

 

If the increase was successful, something like this should be displayed.

Size of logical volume myVG/myLV changed from 1.00 GiB (32 extents) to 2.00 GiB (64 extents).
  Logical volume myLV successfully resized.
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/myVG-myLV is mounted on /var/lib/mysql; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/mapper/myVG-myLV to 6553600 (4k) blocks.
The filesystem on /dev/mapper/myVG-myLV is now 6553600 blocks long.

 


Decrease size

To decrease myLV, you will first need to use the umount command to unmount the volume. For example, lets say /dev/myVG/myLV is mounted on /var.

~]# umount /var

 

You can now reduce the size of the volume. In this example, myLV is reduced to 900 MB. Prior to reducing the size of the volume, ensure no data is using the end of the sectors that will be eliminated.

~]# lvresize --resizefs --size 900M /dev/myVG/myLV

 

Use the mount command to remount the volume.

~]# mount -t ext4 /dev/myVG/myLV /var

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 9145e in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |