查看分區大小
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 217G 188M 205G 1% /home
卸載/home分區
[root@easdb01 ~]# umount /home
可以看到/home分區不見了
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
重置/home分區大小
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_home 117G
resize2fs 1.41.12 (17-May-2010)
請先運行 'e2fsck -f /dev/mapper/vg_easdb01-lv_home'.
提示需要先運行:
[root@easdb01 ~]# e2fsck -f /dev/mapper/vg_easdb01-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 檢查inode,塊,和大小
第二步: 檢查目錄結構
第3步: 檢查目錄連接性
Pass 4: Checking reference counts
第5步: 檢查簇概要信息
/dev/mapper/vg_easdb01-lv_home: 11/14393344 files (0.0% non-contiguous), 951247/57542656 blocks
再運行重置分區大小:
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_home 117G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_easdb01-lv_home to 30670848 (4k) blocks.
Begin pass 3 (max = 1757)
正在掃描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_easdb01-lv_home is now 30670848 blocks long.
加載/home分區
[root@easdb01 ~]# mount /home/
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 116G 188M 110G 1% /home
將lv_home邏輯分區減小到指定大小
[root@easdb01 ~]# lvre
lvreduce lvremove lvrename lvresize
[root@easdb01 ~]# lvreduce -L 117G /dev/mapper/vg_easdb01-lv_home
WARNING: Reducing active and open logical volume to 117.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 117.00 GiB
Logical volume lv_home successfully resized
查看卷組信息:
[root@easdb01 ~]# vgdisplay
--- Volume group ---
VG Name vg_easdb01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 50432 / 197.00 GiB
Free PE / Size 26242 / 102.51 GiB
VG UUID Kopjdv-GfET-USVw-F1bK-1Qdn-Bf80-uUmTGg
擴展lv_root卷大小
[root@easdb01 ~]# lvextend -L +100G /dev/mapper/vg_easdb01-lv_root
Extending logical volume lv_root to 150.00 GiB
Logical volume lv_root successfully resized
重新設定lv_root卷大小
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_easdb01-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 10
Performing an on-line resize of /dev/mapper/vg_easdb01-lv_root to 39321600 (4k) blocks.
The filesystem on /dev/mapper/vg_easdb01-lv_root is now 39321600 blocks long.
查看分區,已將空間擴展至/根目錄
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 148G 3.5G 137G 3% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 116G 188M 110G 1% /home
[root@easdb01 ~]#
