How To Shrink XFS Partition For The Root Filesystem - 1 Easy Guide
How To Shrink XFS Partition For The Root Filesystem - 1 Easy Guide
Home Linux Distros Linux Servers How to Guides Monitoring Tools Unix & Unix Like Linux Misc
Subscribe
Subscribe To Our
0 0 0 0
Newsletter
Join our mailing list to receive the latest
news and updates from our team.
SUBSCRIBE!
Table of Contents
Introduction
In our previous how-to guide, we have seen how to reduce a “/” lesystem with ext4 le system type.
In this guide let’s focus on how to Shrink XFS partition for a root logical volume. To be clear the
lesystem reduce word is not applicable yet for the XFS le system. However, if you need to reduce XFS
lesystem on a logical volume is possible only by taking a backup and restore and recreating the logical
volume.
Recent Posts
Our intention is only to reduce the size of “/” partition which running with XFS lesystem.
Right now the logical volume size is 64 GB. On our rst single disk there are 3 partitions created and
“/” is assigned with more space which is not required at all.
Recent Comments
By following select the “Rescue a Red Hat Enterprise Linux system” to boot into rescue environment.
As we mentioned in the previous guide to perform a Shrink XFS we should not mount the lesystem.
Type 3 and enter into Rescue shell. To perform any actions on logical volumes we shouldn’t enter into
chroot environment.
# ls -lthr /mnt/sysimage/
# vgchange -ay
Now, create two directories under /mnt/sysimage/. 1 will be used to mount the actual “/” lesystem of
this server and another one is to store the backup of “/” lesystem.
# mkdir /mnt/sysimage/rt
# mkdir /mnt/sysimage/backup
# mount /dev/mapper/rhel-root /mnt/sysimage/rt/
# mount /dev/mapper/rhel-home /mnt/sysimage/backup/
We have enough free space on “/home” lesystem, so instead of adding a new disk, we are going to use
it for taking the backup.
While taking the dump use level 0 which will dump all the les, It will prompt to enter a dump session
label and media label, we can avoid the prompt by adding -L and -M by the following use -f to save the
dump as a le.
-l 0 – Dump level is set to 0, A level 0 dump is absolute, all les are dumped.
-L – Speci es a label for the dump session
-M – Speci es a label for the rst media object
-f – Speci es a dump destination to a le or device like tape drives
At the end of dump output we can see the dump status as SUCCESS
Find what currently using the lesystem and kill the PIDS.
Once the PIDS are cleared, now unmount only the current “/” le system.
# umount /mnt/sysimage/rt/
Create a logical volume with the new desired size for the root “/” le system. Use -Zy to zero the rst
4KiB of data in the new LV.
-Z --zero
-y - yes
# lvremove /dev/mapper/rhel-root
Right after that, create the desired size of the logical volume. I’m creating with a 15 GB of the logical
volume in the same existing (rhel) volume group.
The restore will take some time depends on how many GB of data have in the dump le.
That’s it, we have completed with Shrinking an XFS lesystem and a logical volume with the help of
xfsdump and xfsrestore utility.
Conclusion
To reduce a root LVM with XFS lesystem is not possible by running lvreduce, Instead, we need to
back up the les and restore from the dump using xfsdump and xfsrestore. In our one of the previous
guide, we have covered with XFS lesystem dump and restore, However, this guide is focused on how
to resize the root logical volume with XFS.
To perform the LV reduce, rst, we need to boot into rescue mode, then we need to activate the
volume group and mount the old lesystem which is about to dump. Then remove the old logical
volume and create a new logical volume with the desired size. Right after that create the XFS le
system and restore the dump using xfsrestore command. Finally, reboot the server to back online with
the new size of LV and XFS lesystem with the existing data.
Subscribe to our newsletter for more guide related to nix, stay safe and stay tune. If you like the above
write-up provide your feedback in below comment section.
Share
Facebook Twitter Pinterest LinkedIn
About Author
Babin Lonston
Overall 14+ Years of experience in the IT eld, currently working as a
Senior Linux administration with Virtualization & Cloud. Being
numismatist for a long time.
75 % 0% 0% 0% 25 % 0%
Storage Servers
Logical Volume Management
Resize root LVM Partition in RHEL and Oracle Linux 7/8 | Easy guide
Centralized Syslog server with Syslog-ng in 3 easy steps
martin2665
September 8, 2021 at 2 55 am
Thanks a lot. Great article. /device/mapper/root-name did not work for me.
Instead I use /dev/Volname/ root-name
Reply
Leave a Comment
Name
Website
Save my name, email, and website in this browser for the next time I comment.
Post Comment
© 2022 • Built with GeneratePress Copyright Policy Contact About Privacy Policy