Decreasing/Shrinking the logical quantity is the very best threat of information corruption.

So attempt to keep away from this sort of state of affairs if potential, however go forward in case you have no different choices.

It’s at all times advisable to make a backup earlier than shrinking an LVM.

If you end up working out of disk area in LVM, you can also make some free area on the quantity group by decreasing the exsisting LVM that now not makes use of the complete measurement, as a substitute of including a brand new bodily disk.

Make an observation: Shrinking just isn’t supported on a GFS2 or XFS file system.

If you’re new to Logical Quantity Administration (LVM), I recommend you begin with our earlier article.

LVM (Logical Volume Resize) in Linux How to Reduce / Shrink

Decreasing the logical quantity includes the beneath steps.

  • Unmount the file system.
  • Verify the file system for any errors.
  • Shrink the file system measurement.
  • Cut back the logical quantity measurement.
  • Re-check the file system for errors (Optionally available).
  • Mount the file system
  • Verify the diminished file system measurement

As an example; You have got a 100GB LVM that now not makes use of the complete measurement, you need to scale back it to 80GB so 20GB can be utilized for different functions.

# df -h /lvmtest

Filesystem Dimension Used Avail Use% Mounted on
/dev/mapper/vg01-lv002 100G 15G 85G 12% /lvmtest

1) Unmount the file system

Use the umount command to unmount the file system.

# umount /lvmtest1

2) Verify the file system for any Errors

Verify the file system for any errors utilizing the e2fsck command.

# e2fsck -f /dev/mapper/vg01-lv002

e2fsck 1.42.9 (28-Dec-2013)
Move 1: Checking inodes, blocks, and sizes
Move 2: Checking listing construction
Move 3: Checking listing connectivity
Move 4: Checking reference counts
Move 5: Checking group abstract info
/dev/mapper/vg01-lv002: 13/6553600 information (0.0% non-contiguous), 12231854/26212352 blocks

3) Shrink the file system.

The beneath command will scale back the “lvmtest1” file system from 100GB to 80GB.

Frequent syntax for file system resize (resize2fs).

resize2fs [Existing Logical Volume Name] [New Size of File System]

The precise command is as follows.

# resize2fs /dev/mapper/vg01-lv002 80G

resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/vg01-lv002 to 28321400 (4k) blocks.
The filesystem on /dev/mapper/vg01-lv002 is now 28321400 blocks lengthy.

4) Cut back the Logical Quantity (LVM)

Now scale back the logical quantity (LVM) measurement utilizing the lvreduce command. The beneath command “/dev/mapper/vg01-lv002” will shrink the Logical quantity (LVM) from 100GB to 80GB.

Frequent syntax for LVM Cut back (lvreduce)

lvreduce [New Size of LVM] [Existing Logical Volume Name]

The precise command is as follows.

# lvreduce -L 80G /dev/mapper/vg01-lv002

WARNING: Decreasing energetic logical quantity to 80.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem and so forth.)
Do you actually need to scale back lv002? [y/n]: y
Decreasing logical quantity lv002 to 80.00 GiB
Logical quantity lv002 efficiently resized

5) Optionally available: Verify the file system for any Errors

Verify the file system once more if there are any errors after LVM has been diminished.

# e2fsck -f /dev/mapper/vg01-lv002

e2fsck 1.42.9 (28-Dec-2013)
Move 1: Checking inodes, blocks, and sizes
Move 2: Checking listing construction
Move 3: Checking listing connectivity
Move 4: Checking reference counts
Move 5: Checking group abstract info
/dev/mapper/vg01-lv002: 13/4853600 information (0.0% non-contiguous), 1023185/2021235 blocks

6) Mount the file system and examine the diminished measurement

Lastly mount the file system and examine the diminished file system measurement.

Use the mount command to mount the logical quantity.

# mount /testlvm

Verify the newly mounted quantity utilizing the df command.

# df -h /lvmtest1

Filesystem Dimension Used Avail Use% Mounted on
/dev/mapper/vg01-lv002 80G 15G 65G 18% /lvmtest1

lvreduce xfs,reduce logical volume rhel 7,reduce filesystem rhel 7,centos 6 lvreduce,lvextend size may not be negative,how to reduce root partition in linux lvm,pvresize,linux resize root partition,lvextend,how to reduce xfs filesystem in rhel 7,resize root lvm centos 7,linux resize partition without losing data,how to reduce ext4 filesystem in rhel 7,reduce size of xfs volume,xfs shrink home partition,convert xfs to ext4,xfsdump,lvm shrink var partition,resize lvm without unmounting,resize2fs: on-line shrinking not supported,lvm migrate physical volume,lvm split vg,vgsplit,pvmove free disk,pvmove pvremove,lvcreate raid0,resize2fs invalid new size,pvresize shrink,create filesystem in linux lvm,lvm extend in linux,shrink volume linux,lvreduce in rhel7,lvm extend physical volume,resize lvm partition gparted,ubuntu 18.04 extend lvm,resize xfs lvm,how to extend lvm partition in linux vmware,lvreduce,shrink lvm partition,how to reduce lvm size in linux step by step,how to reduce root partition in rhel 7

Share: