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了

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM