Reduce Logical Volume Size on Debian

Reduce Logical Volume Size on Debian/CentOS/RedHat

Reduce the logical volume size is not a good practice in terms of data therefore if you want to reduce the logical volume size must take the backup of data. Here we are reducing the size of logical volume "home" in Debian 9.8, you can also use this process on CentOS and RedHat.

To Check the complete details of Debian version, type the below mention command.

cat /etc/os-release

how to reduce logical volume size on debian

To check how many users available in home directory first use command "cd" to enter in the directory "home" then use command "ls" to list the available users in directory "home".

cd /home
ls

how to reduce logical volume size on debian

In the above image you can see that only user "debian9" is available in directory "home".

For switch from user "root" to user "debian9", type the below mention command.

su debian9

how to reduce logical volume size on debian

Create a text file from user "debian9" by use of command "touch", this is because check the data will available after the reduce size of logical volume "home".

Note: Default directory of every Linux users is "home".

touch book

reduce logical volume size on debian

To check the size of logical volume "home", other logical volumes and fixed volumes. Type the below mention command.

df -hT

reduce logical volume size on debian

Note: In the above image you can see that Here volume group is "NEWLVMGROUP".

To check the size of logical volumes only, type the below mention command.

lvs

reduce logical volume size on debian

Here we are reducing the size of logical volume "home". To reduce the size of logical volume "home" first unmount it. For unmount the logical volume "home", type the below mention command.

umount -v /home

reduce logical volume size on debian

In the above image you can see logical volume "home" has unmount. Type the below mention command to verify.

df -hT

reduce logical volume size on debian

To check the file system error of logical volume "home", type the below mention command. After unmount it is necessary to check file system error of logical volume "home".

e2fsck -ff /dev/NEWLVMGROUP/home

how to reduce logical volume size on linux

In the above image you can see that logical volume "home" file system have no error after unmount.

Here we are reducing size of logical volume "home" from 4.6GB to 3GB.

First resize logical volume "home", type the below mention command. 

resize2fs /dev/NEWLVMGROUP/home 3G

how to reduce logical volume size on linux

Second reduce the size of Logical volume "home" 1.66GB because as per calculation 4.6GB-3GB=1.66GB, type the below mention command for reducing the size of logical volume "home".

lvreduce -L -1.66G /dev/NEWLVMGROUP/home

how to reduce size of logical volume on linux

After reduce the size of logical volume "home", resize logical volume "home". The purpose of use this command to check the file system error in logical volume "home", If error occur it means some mistakes has perform during the process.

resize2fs /dev/NEWLVMGROUP/home

how to reduce size of logical volume on debian

After complete the process mount the logical volume "home".

mount /dev/NEWLVMGROUP/home /home

reduce logical volume size on linux

To check logical volume "home" has successfully mounted, type the below mention command.

df -hT

reduce logical volume size on linux

To check the size of logical volume "home", type the below mention command.

lvdisplay NEWLVMGROUP

reduce size of logical volume on linux

Thanks for Read this Article

Comments