Linux | Centos7擴充套件磁碟空間(LVM管理)
阿新 • • 發佈:2021-10-21
Xshell連線
-
檢視磁碟
fdisk -l /dev/sda
-
檢視磁碟佔用情況
df -h
-
建立新分割槽
fdisk /dev/sda
- 命令列操作 (輸入m檢視幫助 輸入n開始建立分割槽)
Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
- 輸入
n
新建分割槽
- 輸入
p
設定分割槽為主分割槽
- 設定分割槽數量 (預設多少輸入多少)
按照預設值來就好 恩兩次回車
- 輸入
t
修改分割槽編號 (我的預設4 按回車)
- 輸入
L
檢視所有格式
- 選擇分割槽格式,選擇LVM,(輸入8e)
- 輸入 w 儲存分割槽並退出
- 重啟系統
reboot
- 檢視卷組(查詢 vg name)
vgdisplay
- 本機卷組為centos
- 使用新的物理捲來擴充套件 LVM 的 VolGroup
vgextend centos/dev/sda3
- 擴充套件 LVM 的邏輯卷
lvextend -l +100%FREE /dev/centos/root
lvextend引數-L是指定大小 如果不輸入-L +10G 則預設使用全部
- 同步到檔案系統,實現對根目錄的擴容
xfs_growfs /dev/centos/root
- 檢查
df -h
注:流程和命令沒有錯,中途意外斷了一次,又重新弄了一遍,重啟系統之前的是上一次的圖,後面是新圖 新的是根目錄 20G->50G