在线扩展根分区 red hat 4.8.3-9
跑程序的时候发现报错,提示空间不足,仔细查看后发现是根分区已满
27G的空间只有20k剩余
考虑从/data分区压缩一点空间到/分区
切换到root用户
执行下面的命令
1. umount /data
$ umount /data
2. shrink the /data filesystem
$ fsck -f /dev/mapper/centos-data
$ resize2fs /dev/mapper/centos-data 300G3. shrink the /data logical volume
$ lvreduce -L -160G /dev/mapper/centos-data
这一步报了
Couldn't create temporary archive name.
Volume group "centos" metadata archive failed.这样的错误,原因是根目录已满,删除一些文件后,即可正常执行
4. resize the /data partition to the size of the LV$ resize2fs /dev/mapper/centos-data
5. extend the /root logical volume$ lvextend -L +160G /dev/mapper/centos-root
6. extend the /root filesystem$ fsck -f /dev/mapper/centos-root
$ resize2fs /dev/mapper/centos-root (这一步会报bad magic number in super-block之类的错,因为我这里使用的文件系统是xfs而不是ext4,故使用下一条命令代替)
$ xfs_growfs /dev/mapper/centos-root
7. mount /data$ mount /data
最终结果如下,成功在线扩展根分区
参考资料
http://unix.stackexchange.com/questions/213245/increase-root-partition-by-reducing-home
http://blog.itpub.net/24486203/viewspace-1790666
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用