How reduce or shrink Logical Volume on Linux

How reduce or shrink Logical Volume on Linux

You can reduce the size of a logical volume on Linux using the lvresize command. Before you can reduce the size of a logical volume, you need to make sure that the filesystem inside the logical volume is shrunk to a size smaller than the desired size of the logical volume.

Here are the steps to reduce the size of a logical volume:

  1. Identify the logical volume you want to shrink. You can use the lvdisplay command to list all logical volumes and their sizes. For example:
r‮fe‬er to:lautturi.com
lvdisplay
  1. Shrink the filesystem inside the logical volume. The exact steps for shrinking the filesystem depend on the filesystem type. For example, to shrink an ext4 filesystem, you can use the resize2fs command. Consult the documentation and online resources available for more information on how to shrink the filesystem.

  2. Use the lvresize command to reduce the size of the logical volume. The -L option is used to specify the new size. For example:

lvresize -L 10G /dev/vg/lv_name

Replace /dev/vg/lv_name with the actual path to the logical volume you want to shrink. Replace 10G with the desired size of the logical volume. The size can be specified in bytes, kilobytes, megabytes, gigabytes, or terabytes, with a b, k, m, g, or t suffix, respectively.

  1. Check the size of the logical volume to make sure it was reduced correctly. You can use the lvdisplay command again to check the size.

Note: Use these commands with caution, as reducing the size of a logical volume can result in data loss if the filesystem inside the logical volume is not shrunk first. Make sure to take a backup of your data before attempting to resize a logical volume. Consult the documentation and online resources available for more information on the various options and features available for managing logical volumes.

Created Time:2017-10-28 21:38:57  Author:lautturi