方案一:將home空間擴容給根目錄
若home分區(qū)有足夠的空間且從來不使用,則可以將home分區(qū)空間擴容給/根目錄
1.解除掛載并刪除/home卷
[root@localhost ~]# umount /home
若提示分區(qū)正在被使用,則通過名稱查詢占用進(jìn)程并將進(jìn)程殺死
[root@localhost ~]# fuser -mv /home //查詢占用進(jìn)程
[root@localhost ~]# kill -9 進(jìn)程號 //殺死占用進(jìn)程
[root@localhost ~]# lvremove /dev/centos/home //刪除邏輯卷
2.分配冗余空間給根目錄
# 將冗余的50G分配給根目錄
[root@localhost ~]# lvextend -L +50G /dev/centos/root
# 查看硬盤情況
[root@localhost ~]# df -h
# 若在df -h中根目錄空間沒有增加成功,則執(zhí)行以下命令讓系統(tǒng)重新識別分區(qū)大小
[root@localhost ~]# xfs_growfs /dev/centos/root
方案二:對原有磁盤進(jìn)行擴容然后將冗余空間分配給根目錄
1.分區(qū)
使用fdisk等命令對冗余空間創(chuàng)建一個分區(qū)
2.創(chuàng)建pv卷
使用pvcreate命令創(chuàng)建pv卷
[root@localhost ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
3.將創(chuàng)建的pv卷加入至根目錄vg組中
[root@localhost ~]# vgs //查看已有vg組
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <49.00g 0
[root@localhost ~]# vgextend centos /dev/sda3 //將sda3加入centos的vg組中
Volume group "centos" successfully extended
4.擴展lv文章來源:http://www.zghlxwxcb.cn/news/detail-800352.html
[root@localhost ~]# lvextend -L +20G /dev/mapper/centos-root
[root@localhost ~]# df -h //查看硬盤情況
#若df -h沒有變化則使用命令讓系統(tǒng)重新讀取大小
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
[root@localhost ~]# df -h //再次查看硬盤情況
擴容完成文章來源地址http://www.zghlxwxcb.cn/news/detail-800352.html
到了這里,關(guān)于CentOS運維之根目錄擴容的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!