xfs文件系统不支持缩小操作,如果要踢盘,那就必须把目录做备份,重做挂接点拷贝恢复了。
[root@oem /]# umount /app
[root@oem /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 132.00g
swap centos -wi-ao---- <6.69g
datalv datavg -wi-a----- 924.00m
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m
[root@oem /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 140G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 138.7G 0 part
├─centos-root 253:0 0 132G 0 lvm /
└─centos-swap 253:1 0 6.7G 0 lvm [SWAP]
sdb 8:16 0 1G 0 disk
└─datavg-datalv 253:2 0 924M 0 lvm
sdc 8:32 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
[root@oem /]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 138.69g 4.00m
datavg 1 1 0 wz--n- 1020.00m 96.00m
[root@oem /]# mkfs.xfs /dev/datavg/datalv
mkfs.xfs: /dev/datavg/datalv appears to contain an existing filesystem (ext4).
mkfs.xfs: Use the -f option to force overwrite.
[root@oem /]# mkfs.xfs /dev/datavg/datalv -f
meta-data=/dev/datavg/datalv isize=512 agcount=4, agsize=59136 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=236544, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@oem /]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Oct 6 19:45:05 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=14d08e59-107d-4e6d-b7ef-e77f1bbd49a3 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/datavg/datalv /app xfs defaults 0 0
192.168.52.141@tcp:/sgfs /lustre/sgfs lustre defaults 0 0
~
"/etc/fstab" 13L, 578C written
[root@oem /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Oct 6 19:45:05 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=14d08e59-107d-4e6d-b7ef-e77f1bbd49a3 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/datavg/datalv /app xfs defaults 0 0
192.168.52.141@tcp:/sgfs /lustre/sgfs lustre defaults 0 0
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv xfs 921M 33M 889M 4% /app
[root@oem /]# cp /home/oracle/soft/em13400_linux64-5.zip /app/
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv xfs 921M 803M 118M 88% /app
[root@oem /]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@oem /]# vgextend datavg /dev/sdc
Volume group "datavg" successfully extended
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1020.00m
[root@oem /]# lvextend -l +100%free /dev/datavg/datalv
Size of logical volume datavg/datalv changed from 924.00 MiB (231 extents) to 1.99 GiB (510 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# xfs_growfs /dev/datavg/datalv
meta-data=/dev/mapper/datavg-datalv isize=512 agcount=4, agsize=59136 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=236544, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 236544 to 522240
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv xfs 2.0G 804M 1.3G 40% /app
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 0
/dev/sdc datavg lvm2 a-- 1020.00m 0
[root@oem /]# vgreduce datavg /dev/sdc
Physical volume "/dev/sdc" still in use
[root@oem /]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 centos lvm2 a-- 138.69g 4.00m <138.69g
/dev/sdb datavg lvm2 a-- 1020.00m 0 1020.00m
/dev/sdc datavg lvm2 a-- 1020.00m 0 1020.00m
[root@oem /]# lvresize -L 0.9G -r /dev/datavg/datalv
Rounding size to boundary between physical extents: 924.00 MiB.
fsadm: Xfs filesystem shrinking is unsupported.
/usr/sbin/fsadm failed: 1
Filesystem resize failed.
[root@oem /]#
2019-01-17 Centos7 LVM XFS 分区大小调整 - 简书
继续做备份恢复:安装xfsdump做备份,需注意足够的空间存储备份。
[root@oem /]# yum install xfsdump -y
Loaded plugins: fastestmirror
Determining fastest mirrors
(1/2): attr-2.4.46-13.el7.x86_64.rpm | 66 kB 00:00:00
(2/2): xfsdump-3.1.7-1.el7.x86_64.rpm | 308 kB 00:00:02
-------------------------------------------------------------------------------------------------------------------------------------------
Total 11 kB/s | 374 kB 00:00:34
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : attr-2.4.46-13.el7.x86_64 1/2
Installing : xfsdump-3.1.7-1.el7.x86_64 2/2
Verifying : attr-2.4.46-13.el7.x86_64 1/2
Verifying : xfsdump-3.1.7-1.el7.x86_64 2/2
Installed:
xfsdump.x86_64 0:3.1.7-1.el7
Dependency Installed:
attr.x86_64 0:2.4.46-13.el7
Complete!
[root@oem /]# xfsdump --help
xfsdump: version 3.1.7 (dump format 3.0)
xfsdump: usage: xfsdump [ -a (dump DMF dualstate files as offline) ]
[ -b <blocksize> ]
[ -c <media change alert program> ]
[ -d <dump media file size> ]
[ -e (allow files to be excluded) ]
[ -f <destination> ... ]
[ -h (help) ]
[ -l <level> ]
[ -m (force usage of minimal rmt) ]
[ -o (overwrite tape) ]
[ -p <seconds between progress reports> ]
[ -q <use QIC tape settings> ]
[ -s <subtree> ... ]
[ -t <file> (use file mtime for dump time ]
[ -v <verbosity {silent, verbose, trace}> ]
[ -z <maximum file size> ]
[ -A (don't dump extended file attributes) ]
[ -B <base dump session id> ]
[ -D (skip unchanged directories) ]
[ -E (pre-erase media) ]
[ -F (don't prompt) ]
[ -I (display dump inventory) ]
[ -J (inhibit inventory update) ]
[ -K (generate format 2 dump) ]
[ -L <session label> ]
[ -M <media label> ... ]
[ -O <options file> ]
[ -R (resume) ]
[ -T (don't timeout dialogs) ]
[ -Y <I/O buffer ring length> ]
[ - (stdout) ]
[ <source (mntpnt|device)> ]
[root@oem /]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 6.6G 0 6.6G 0% /dev
tmpfs tmpfs 6.7G 0 6.7G 0% /dev/shm
tmpfs tmpfs 6.7G 12M 6.6G 1% /run
tmpfs tmpfs 6.7G 0 6.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 132G 97G 36G 74% /
/dev/sda1 xfs 1014M 198M 817M 20% /boot
tmpfs tmpfs 1.4G 0 1.4G 0% /run/user/0
/dev/mapper/datavg-datalv xfs 2.0G 804M 1.3G 40% /app
[root@oem /]# xfsdump -l 0 -L app -M app -f /app.xfsdump /app
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.7 (dump format 3.0) - type ^C for status and control
xfsdump: level 0 dump of oem:/app
xfsdump: dump date: Tue Sep 3 14:09:46 2024
xfsdump: session id: 520e46be-d668-49dd-8c54-54d96b87f77a
xfsdump: session label: "app"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 808039040 bytes
xfsdump: /var/lib/xfsdump/inventory created
xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 808238880 bytes
xfsdump: dump size (non-dir files) : 808203712 bytes
xfsdump: dump complete: 3 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /app.xfsdump OK (success)
xfsdump: Dump Status: SUCCESS
[root@oem /]# du -sh /app.xfsdump
771M /app.xfsdump
[root@oem /]# umount /app
[root@oem /]# lvresize -L 0.9G /dev/datavg/datalv
Rounding size to boundary between physical extents: 924.00 MiB.
WARNING: Reducing active logical volume to 924.00 MiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce datavg/datalv? [y/n]: y
Size of logical volume datavg/datalv changed from 1.99 GiB (510 extents) to 924.00 MiB (231 extents).
Logical volume datavg/datalv successfully resized.
[root@oem /]# mount /app
mount: /dev/mapper/datavg-datalv: can't read superblock
[root@oem /]# mkfs.xfs /dev/datavg/datalv
mkfs.xfs: /dev/datavg/datalv appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
[root@oem /]# mkfs.xfs /dev/datavg/datalv -f
meta-data=/dev/datavg/datalv isize=512 agcount=4, agsize=59136 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=236544, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@oem /]# mount /app
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv xfs 921M 33M 889M 4% /app
[root@oem /]#
[root@oem /]#
[root@oem /]# xfsrestore -f /app.xfsdump /app
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.7 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: oem
xfsrestore: mount point: /app
xfsrestore: volume: /dev/mapper/datavg-datalv
xfsrestore: session time: Tue Sep 3 14:09:46 2024
xfsrestore: level: 0
xfsrestore: session label: "app"
xfsrestore: media label: "app"
xfsrestore: file system id: e894c5c7-cf16-438a-8413-a14d9df2f840
xfsrestore: session id: 520e46be-d668-49dd-8c54-54d96b87f77a
xfsrestore: media id: c559d15f-722f-45ee-a466-e1f99962d18e
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 1 directories and 1 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /app.xfsdump OK (success)
xfsrestore: Restore Status: SUCCESS
[root@oem /]# df -hT /app
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv xfs 921M 803M 118M 88% /app
[root@oem /]# ll /app
total 789080
-rw-r--r-- 1 root root 808014516 Sep 3 13:53 em13400_linux64-5.zip
[root@oem /]#
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1020.00m
[root@oem /]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 centos lvm2 a-- 138.69g 4.00m <138.69g
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m 924.00m
/dev/sdc datavg lvm2 a-- 1020.00m 1020.00m 0
[root@oem /]# vgreduce datavg /dev/sdc
Removed "/dev/sdc" from volume group "datavg"
[root@oem /]# pvremove /dev/sdc
Labels on physical volume "/dev/sdc" successfully wiped.
[root@oem /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 138.69g 4.00m
/dev/sdb datavg lvm2 a-- 1020.00m 96.00m