centos根目錄擴容,home目錄減少容量

參考:python

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

 

主要命令:.net

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了
相關文章
相關標籤/搜索