In linux, we can’t reduce the XFS filesystem in general.
And to reduce any partition, we need to take backup of data at some other path and then re-create the XFS filesystem on the LV.
Lets see the process step by step.
Please take partition backup to some other path.
1. Check the partition which we want to reduce.
[root@ngelinux ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 252G 0 252G 0% /dev tmpfs 252G 0 252G 0% /dev/shm tmpfs 252G 54M 252G 1% /run tmpfs 252G 0 252G 0% /sys/fs/cgroup /dev/mapper/vg00-root 75G 26G 50G 35% / /dev/sda1 4.0G 281M 3.8G 7% /boot /dev/mapper/vg00-logs 210G 1.5G 209G 1% /logs /dev/mapper/vg00-var 30G 748M 30G 3% /var /dev/mapper/vg01-lmetadata 6.7T 84G 6.6T 2% /metadata [root@ngelinux ~]# [root@ngelinux ~]# ls -ld /metadata/ drwxr-xr-x. 3 ngeadm ngel_rnd 35 Mar 11 14:54 /metadata/
2. Umount the partition
[root@ngelinux ~]# umount /metadata [root@ngelinux ~]#
3. Now reduce the LV. (THIS WILL DESTROY DATA OF LV: MAKE SURE DATA BACKUP OF THIS PATH TAKEN)
[root@ngelinux ~]# lvreduce -L 6.4T vg01/lmetadata Rounding size to boundary between physical extents: 6.40 TiB. WARNING: Reducing active logical volume to 6.40 TiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce vg01/lmetadata? [y/n]: y Size of logical volume vg01/lmetadata changed from 6.67 TiB (1749503 extents) to 6.40 TiB (1677722 extents). Logical volume vg01/lmetadata successfully resized. [root@ngelinux ~]#
4. Create the XFS partition again.
[root@ngelinux ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
logs vg00 -wi-ao---- <209.62g
root vg00 -wi-ao---- 75.00g
swap vg00 -wi-ao---- 128.00g
var vg00 -wi-ao---- 30.00g
lbackup vg01 -wi-ao---- 900.00g
ljournal vg01 -wi-ao---- 100.00g
lmetadata vg01 -wi-a----- 6.40t
ltmp vg01 -wi-ao---- 330.00g
lusr1 vg01 -wi-ao---- 776.00g
[root@ngelinux ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 1 4 0 wz--n- <442.62g 0
vg01 1 5 0 wz--n- 8.73t 280.39g
[root@ngelinux ~]# mkfs.xfs -f /dev/vg01/lmetadata
meta-data=/dev/vg01/lmetadata isize=512 agcount=32, agsize=53687104 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1717987328, imaxpct=5
= sunit=64 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=512 sunit=64 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
5. Mount the path again.
[root@ngelinux ~]# mount -va ### Mounts paths from /etc/fstab file
/ : ignored
/boot : already mounted
/logs : already mounted
/var : already mounted
none : ignored
/tmp : already mounted
/backups : already mounted
/journal : already mounted
/usr1 : already mounted
mount: /metadata does not contain SELinux labels.
You just mounted an file system that supports labels which does not
contain labels, onto an SELinux box. It is likely that confined
applications will generate AVC messages and not be allowed access to
this file system. For more details see restorecon(8) and mount(8).
/metadata : successfully mounted
[root@ngelinux ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 252G 0 252G 0% /dev
tmpfs 252G 0 252G 0% /dev/shm
tmpfs 252G 54M 252G 1% /run
tmpfs 252G 0 252G 0% /sys/fs/cgroup
/dev/mapper/vg00-root 75G 26G 50G 35% /
/dev/sda1 4.0G 281M 3.8G 7% /boot
/dev/mapper/vg00-logs 210G 1.5G 209G 1% /logs
/dev/mapper/vg00-var 30G 749M 30G 3% /var
/dev/mapper/vg01-ljournal 100G 747M 100G 1% /journal
/dev/mapper/vg01-lmetadata 6.4T 46G 6.4T 1% /metadata
[root@ngelinux ~]#
