xfs LVM 缩容分享
2022/4/13 23:14:00
本文主要是介绍xfs LVM 缩容分享,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
背景知识:
- 我们都是知道在rhel系列上ext4文件系统的LVM可以随意扩容和缩容,但是xfs只能扩容 ,不能缩小。\
- 我们换个思路:备份文件系统-卸载文件系统分区-新建文件系统分区-恢复文件系统
目前想缩小home分区到10GB:
[root@LinuxVm ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cs-root xfs 70G 3.8G 67G 6% / /dev/mapper/cs-home xfs 160G 1.2G 158G 1% /home /dev/sdb2 xfs 1014M 215M 800M 22% /boot /dev/sdb1 vfat 599M 7.3M 592M 2% /boot/efi [root@LinuxVm ~]# yum -y install xfsdump [root@LinuxVm ~]# xfsdump -f /home.xfsdump /home # 期间会有两次确认信息 [root@LinuxVm ~]# ll -h /home.xfsdump -rw-r--r--. 1 root root 29K Apr 13 21:55 /home.xfsdump [root@LinuxVm ~]# fuser -km /home /home: 5728c 5760c [root@LinuxVm ~]# umount /home [root@LinuxVm ~]# lvreduce -L 10G /dev/cs/home WARNING: Reducing active logical volume to 10.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce cs/home? [y/n]: y Size of logical volume cs/home changed from 159.10 GiB (40730 extents) to 10.00 GiB (2560 extents). Logical volume cs/home successfully resized. [root@LinuxVm ~]# lvextend -l +100%FREE /dev/cs/root Size of logical volume cs/root changed from 70.00 GiB (17920 extents) to 219.10 GiB (56090 extents). Logical volume cs/root successfully resized. [root@LinuxVm ~]# xfs_growfs /dev/cs/root [root@LinuxVm ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cs-root xfs 220G 4.8G 215G 3% / #剩余空间已经全部给到了根分区 /dev/sdb2 xfs 1014M 215M 800M 22% /boot /dev/sdb1 vfat 599M 7.3M 592M 2% /boot/efi [root@LinuxVm ~]# mkfs.xfs /dev/cs/home -f [root@LinuxVm ~]# mount /dev/cs/home /home [root@LinuxVm ~]# xfsrestore -f /home.xfsdump /home [root@LinuxVm ~]# grep home /etc/fstab /dev/mapper/cs-home /home xfs defaults 0 0 [root@LinuxVm ~]# blkid | grep home #确认一下,万一是UUID挂载,需要更新一下fastab /dev/mapper/cs-home: UUID="62ffb186-26e2-4fe9-abb1-8dff33975da7" BLOCK_SIZE="512" TYPE="xfs" [root@LinuxVm ~]# df -Th | egrep 'home|root' /dev/mapper/cs-root xfs 220G 4.8G 215G 3% / /dev/mapper/cs-home xfs 10G 104M 9.9G 2% /home
至此完成。
这篇关于xfs LVM 缩容分享的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?