/dev/vg_db5/lv_home: 29/32989184 files (0.0% non-contiguous), 2121120/131926016 blocks
3.开始缩小文件系统:
#resize2fs /dev/vg_db5/lv_home 1024M
resize2fs 1.41.12 (17-May-2010)
resize2fs: New size smaller than minimum (307344)
显示1G太小了,最小是307344个块。得了,10个G吧
#resize2fs /dev/vg_db5/lv_home 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_db5/lv_home to 2621440 (4k) blocks.
The filesystem on /dev/vg_db5/lv_home is now 2621440 blocks long.
4.缩小lv大小:
#lvreduce -L 10G /dev/vg_db5/lv_home
WARNING: Reducing active logical volume to 10.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Size of logical volume vg_db5/lv_home changed from 503.26 GiB (128834 extents) to 10.00 GiB (2560 extents).
Logical volume lv_home successfully resized
#vgdisplay 发现空间已经释放出来了
--- Volume group ---
VG Name vg_db5
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 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 557.26 GiB
PE Size 4.00 MiB
Total PE 142658
Alloc PE / Size 16384 / 64.00 GiB
Free PE / Size 126274 / 493.26 GiB
VG UUID Ji4TQc-IbhS-O6Cb-XH5Q-q4Uk-DIer-DvSMMD
5.增大LV:lv_root 的大小,增大到500G
#lvextend -L 500G -f -r /dev/vg_db5/lv_root
Size of logical volume vg_db5/lv_root changed from 50.00 GiB (12800 extents) to 500.00 GiB (128000 extents).
Logical volume lv_root successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_db5-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 32
Performing an on-line resize of /dev/mapper/vg_db5-lv_root to 131072000 (4k) blocks.
The filesystem on /dev/mapper/vg_db5-lv_root is now 131072000 blocks long.
想再增加操作系统大小,看来不用做了。
# resize2fs /dev/vg_db5/lv_root 500G
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 131072000 blocks long. Nothing to do!
#resize2fs -p /dev/vg_db5/lv_root
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 131072000 blocks long. Nothing to do!
重启之后:
#df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_db5-lv_root 493G 6.2G 461G 2% /
tmpfs 160G 144K 160G 1% /dev/shm
/dev/sdq1 477M 37M 415M 9% /boot
/dev/mapper/vg_db5-lv_home 9.8G 37M 9.2G 1% /home
终于搞定了。