0、看有沒有lvs
#lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home vg_vhost -wi-ao---- 5.40t
lv_root vg_vhost -wi-ao---- 50.00g
lv_swap vg_vhost -wi-ao---- 7.80gnode
一、先來查看一下系統的空間分配狀況
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_vhost-lv_root
50G 40G 7.0G 86% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 28M 425M 7% /boot
/dev/mapper/vg_vhost-lv_home
5.4T 15G 5.1T 1% /homeapp
二、目標-》增長 /空間,減小 /home空間,縮減vg_vhost-lv_home到2Tide
#resize2fs -p /dev/mapper/vg_vhost-lv_home 2Tui
Filesystem at /dev/mapper/vg_vhost-lv_home is mounted on /home; on-line resizing required
On-line shrinking from 1449448448 to 536870912 not supported.spa
提示,在線不中orm
三、卸載目錄
#umount /home
四、縮減到2T
#resize2fs -p /dev/mapper/vg_vhost-lv_home 2T
resize2fs 1.41.12 (17-May-2010)
請先運行 'e2fsck -f /dev/mapper/vg_vhost-lv_home'.
五、提示先檢查
#e2fsck -f /dev/mapper/vg_vhost-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 檢查inode,塊,和大小
第二步: 檢查目錄結構
第3步: 檢查目錄鏈接性
Pass 4: Checking reference counts
第5步: 檢查簇概要信息
/dev/mapper/vg_vhost-lv_home: 21/362364928 files (4.8% non-contiguous), 26516105/1449448448 blocks
六、縮減
#resize2fs -p /dev/mapper/vg_vhost-lv_home 2T
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_vhost-lv_home to 536870912 (4k) blocks.
Begin pass 2 (max = 32768)
正在重定位塊 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 44234)
正在掃描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_vhost-lv_home is now 536870912 blocks long.
七、從新加載目錄
#mount /home
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_vhost-lv_root
50G 40G 7.0G 86% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 28M 425M 7% /boot
/dev/mapper/vg_vhost-lv_home
2.0T 15G 1.9T 1% /home
八、使生效,分出空間可用。注意若是有數據,要小於2T,不然丟人
#lvreduce -L 2T /dev/mapper/vg_vhost-lv_homeci
WARNING: Reducing active and open logical volume to 2.00 TiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg_vhost/lv_home? [y/n]: y
Size of logical volume vg_vhost/lv_home changed from 5.40 TiB (1415477 extents) to 2.00 TiB (524288 extents).
Logical volume lv_home successfully resized.it
九、查詢卷組的信息:
Free PE / Size指定的應該是如今可在分配的空間form
#vgdisplay
--- Volume group ---
VG Name vg_vhost
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 5.46 TiB
PE Size 4.00 MiB
Total PE 1430273
Alloc PE / Size 539084 / 2.06 TiB
Free PE / Size 891189 / 3.40 TiB
VG UUID q9cgCG-rlm0-KGYo-Z7xq-6JyO-1hAT-E0ZWpfclass
十、將可用的空間添加到 /
#lvextend -L +3.4T /dev/mapper/vg_vhost-lv_root
Rounding size to boundary between physical extents: 3.40 TiB.
Insufficient free space: 891290 extents needed, but only 891189 available
#lvextend -L +3.39T /dev/mapper/vg_vhost-lv_root
Rounding size to boundary between physical extents: 3.39 TiB.
Size of logical volume vg_vhost/lv_root changed from 50.00 GiB (12800 extents) to 3.44 TiB (901469 extents).
Logical volume lv_root successfully resized.
十一、仍是-l後面的參數好用,呵呵#lvextend -l +100%FREE /dev/mapper/vg_vhost-lv_rootSize of logical volume vg_vhost/lv_root changed from 3.45 TiB (903986 extents) to 3.45 TiB (903989 extents). Logical volume lv_root successfully resized.十二、查看空間,納悶啊!!#df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_vhost-lv_root 50G 40G 7.0G 86% /tmpfs 7.8G 0 7.8G 0% /dev/shm/dev/sda1 477M 28M 425M 7% /boot/dev/mapper/vg_vhost-lv_home 2.0T 15G 1.9T 1% /home1三、使生效,這個過程可慢,在線啊……#resize2fs -p /dev/mapper/vg_vhost-lv_rootFilesystem at /dev/mapper/vg_vhost-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 4, new_desc_blocks = 221Performing an on-line resize of /dev/mapper/vg_vhost-lv_root to 925684736 (4k) blocks.The filesystem on /dev/mapper/vg_vhost-lv_root is now 925684736 blocks long.1四、查看空間,ok# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_vhost-lv_root 3.4T 40G 3.2T 2% /tmpfs 7.8G 0 7.8G 0% /dev/shm/dev/sda1 477M 28M 425M 7% /boot/dev/mapper/vg_vhost-lv_home 2.0T 15G 1.9T 1% /home