三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

CentOS 7 home 磁盘空间转移至root下 (LVM分区)

三三 2022-04-04 2023 0条评论 Linux使用 home空间转移

首页 / 正文

注意,本文是介绍lvm分区下的home分区的空间,转换到/分区的方法。文件系统问xfs

1.查看CentOS的系统版本(系统版本必须为7版本)

cat /etc/redhat-release

2.查看分区
(centos-home和centos-root每人的名字可能不一样) 注意看一下/home分区的大小,这里假设是120G。

df -h 

3.备份home分区文件

tar cvf /tmp/home.tar /home

4.卸载/home,如果无法卸载,先终止使用/home文件系统的进程

umount /home (卸载)

卸载时,如果发现/home在使用中,所以先终止。

fuser -km /home/(终止)

再次卸载,没有报错,表示成功

5.删除/home所在的lv

lvremove /dev/mapper/centos-home

6.扩展/root所在的lv

lvextend -L +100G /dev/mapper/centos-root

注意,这里只转移100G过来,剩余的还依旧保留。

7.扩展/root文件系统xfs文件系统

xfs_growfs /dev/mapper/centos-root

或者ext文件格式用

resize2fs /dev/mapper/centos-root

查看分区情况

vgdisplay
df -h

如果不需要home,可以把所有分区大小都给home,那么下面的步骤就可以省略了。
但是需要多一个步骤就是在分区表里去掉挂载的home分区

vi /etc/fstab   /找到home的那个分区,在前面加一个#

----------------------------还需要home分区的继续向下------------------------------

8.重新创建home lv (创建时计算好剩余的磁盘容量,建议比剩余小1G左右)我们是120G-100G -1G=19G

lvcreate -L 19G -n /dev/mapper/centos-home 

9.创建文件系统

mkfs.xfs /dev/mapper/centos-home

10.挂载home

mount /dev/mapper/centos-home

11.home文件恢复

tar xvf /tmp/home.tar -C /home/

12.再次使用df -h查看系统磁盘大小

df -h

其他相关内容参考:
CentOS7根目录磁盘扩容(/dev/mapper/centos-root 空间不足)(示例代码)
http://www.33f.net/setup/centos_extend_hdd_root.html

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张