Terry : Extending and Reducing a Logical Volume

Use Case

Example: add 10GB of space for the backups:

lvresize -L +10G /dev/ubuntu/backup
resize2fs /dev/ubuntu/backup

The command to resize a Logical-Volume is lvresize. You can either give it a relative size (+10 GB to grow it by 10GB) or an absolute size (45GB). When no size is given to resize2fs (the tool that resizes ext2/ext3/ext4 filesystems), it automatically grows to the size of the underlying volume which is what we want.

Be careful if you shrink a volume. You have to unmount the filesystem first since linux filesystems do not support online shrinking with the exception of btrfs. Also you have to shrink the filesystem first (using resize2fs, resize_reiserfs, ...) and then you can resize the volume. A filesystem cannot be bigger than the volume where it lives. For this reason, it's good practice not to allocate all the space of your Volume-Groups immediately. It's recommended to create small Logical-Volumes first so as to leave some free space on your Volume-Group. You can always grow the volumes later when you need more space. This way you avoid having to unmount a filesystem to shrink it in order to free some space for other Logical-Volumes. This would require some down time which is not always possible on production machines.

shrink / logical volume

grow /home logical volume





Extending a logical volume

Reducing a logical volume