1.首先查看磁碟使用情況
df -h
 

目標:/home 修改成20G空間,剩下的空間給/目錄
 

2.卸載掛載分區
umount /home
如果提示無法卸載,則是有進程佔用/home,使用如下命令來終止佔用process:
fuser -m -v -i -k /home
之後再執行
umount /home
或強制umount
umount -l /home
 

3.檢查VolGroup-lv_home文件的錯誤性,-f 即使文件系統沒有錯誤跡象,仍強制地檢查正確性。
e2fsck -f /dev/mapper/VolGroup-lv_home
 
e2fsck 1.41.12 (17-May-2010)
第一步: 檢查inode,塊,和大小
第二步: 檢查目錄結構
第三步: 檢查目錄連接性
第四步: Checking reference counts
第五步: 檢查簇概要信息
/dev/mapper/VolGroup-lv_home: 27/69304320 files (0.0% non-contiguous), 4400705/277215232 blocks
 

4.調整/home為20G
resize2fs -p /dev/mapper/VolGroup-lv_home 20G
如果提示運行「e2fsck -f /dev/mapper/vg-lvhome」,則執行相關命令:
e2fsck -f /dev/mapper/vg-lvhome
然後重新執行命令:
resize2fs -p /dev/mapper/VolGroup-lv_home 20G
 
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.
Begin pass 2 (max = 32784)
正在重定位塊 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 8460)
正在掃瞄inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 15)
正在更新inode引用 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long.


 
 
 
 
5.重新掛載並查看
mount /home
df -h

6.使用lvextend指令:擴展邏輯卷空間到/dev/mapper/VolGroup-lv_root目錄下,也就是「/」目錄下。
lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
 
Size of logical volume VolGroup-lv_root changed from 50.00 GiB (12800 extents) to 404.24 GiB (103485 extents).
Logical volume lv_root successfully resized
 
執行操作,使之生效,中間一定要耐心等待。
 
resize2fs -p /dev/mapper/VolGroup-lv_root
 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 68
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 284227584 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 284227584 blocks long.
 

7.查看分區
df -h

8.重啟
shutdown -h now
1435842250395

Tags: , ,