centos根目录扩容,home目录减小容量

参考:

https://blog.csdn.net/evandeng2009/article/details/49814097

主要命令:

15  cd /
16  ll
17  mkdir backup
18  ll
20  cp -r /home/* /backup/      # 备份/home目录到/backup
21  cd /home/
22  ll
26  cd /
27  cd backup/
30  ll
31  cd /
32  ll
33  umount /home
34  w
35  reboot 
36  w
37  umount /home            #  卸载这个/home的挂载关联
38  df -h
39  lvremove /dev/centos/home   # 删除逻辑卷home
40  vgdisplay       #  查看卷组可用空间
41  lvcreate -L 200G -n home centos       # -L表示大小,默认单位为M;-n表示卷名;这里的centos是CentOS7安装系统的时候就默认建立好的卷组名
42  lvdisplay       # 查看逻辑卷home
43  vgdisplay 
44  df -h
45  vgchange -ay centos  #  可选步骤:激活卷组centos,使得这个新建的home逻辑卷生效
46  mkfs -t xfs /dev/centos/home   #  在新建的逻辑卷home上建立xfs文件系统
47  mount /dev/centos/home /home/  #  把这个新逻辑卷home挂到之前的文件夹/home中去,直接重启用fstab来挂载也行
48  df -h
49  cp -r /backup/* /home/  # 再把之前拷出来的东西拷回新建的/home中
50  cd /home/
53  ll
54  cd /
55  ll
56  lvextend -L +200G /dev/centos/root # 把释放出来多余的空间分配给root卷;+号表示在原来的基础上额外增加,不要加好则设定为具体额度,剩下那点渣渣空间让它闲着
57  df -h
58  lvdisplay 
59  vgchange -ay centos
60  df -h  
61  xfs_growfs /dev/centos/root   #  扩展root卷,xfs_growfs扩展文件系统。不使用xfs_growfs扩展文件系统,磁盘是不认得多的空间的
62  df -h  # 再看root大小已经生效,200多G了

  

猜你喜欢

转载自www.cnblogs.com/andy9468/p/11041619.html
今日推荐