linux 縮減LV大小

huzhichengforce發表於2017-03-02
    
一、確定lv、lv 掛載目錄
df -h
[root@hzwmesdb1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hzwmesdb2-lv_root
50G 8.1G 39G 18% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sdy1 477M 52M 400M 12% /boot
/dev/mapper/vg_hzwmesdb2-lv_home
210G 13G 187G 7% /home
二、解除安裝掛載目錄
umount /home
三、檢查是否能夠進行縮減操作
e2fsck -f /dev/mapper/vg_hzwmesdb2-lv_home
四、變更系統大小
resize2fs /dev/mapper/vg_hzwmesdb2-lv_home 10G
五、縮減LV大小
lvresize -L 10G /dev/mapper/vg_hzwmesdb2-lv_home
六掛載目錄
mount -a

例項:
[root@hzwmesdb1 ~]# umount /home
[root@hzwmesdb1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hzwmesdb2-lv_root
50G 8.1G 39G 18% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sdy1 477M 52M 400M 12% /boot
[root@hzwmesdb1 ~]# e2fsck -f /dev/mapper/vg_hzwmesdb2-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 檢查inode,塊,和大小
第二步: 檢查目錄結構
第3步: 檢查目錄連線性
Pass 4: Checking reference counts
第5步: 檢查簇概要資訊
/dev/mapper/vg_hzwmesdb2-lv_home: 7196/13975552 files (0.1% non-contiguous), 4314765/55873536 blocks
[root@hzwmesdb1 ~]# resize2fs /dev/mapper/vg_hzwmesdb2-lv_home 50G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_hzwmesdb2-lv_home to 13107200 (4k) blocks.
The filesystem on /dev/mapper/vg_hzwmesdb2-lv_home is now 13107200 blocks long.

[root@hzwmesdb1 ~]# lvresize -L 50G /dev/mapper/vg_hzwmesdb2-lv_home
WARNING: Reducing active logical volume to 50.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg_hzwmesdb2/lv_home? [y/n]: y
Size of logical volume vg_hzwmesdb2/lv_home changed from 213.14 GiB (54564 extents) to 50.00 GiB (12800 extents).
Logical volume lv_home successfully resized.
[root@hzwmesdb1 ~]# mount -a
[root@hzwmesdb1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hzwmesdb2-lv_root
50G 8.1G 39G 18% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sdy1 477M 52M 400M 12% /boot
/dev/mapper/vg_hzwmesdb2-lv_home
50G 13G 34G 28% /home

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26764973/viewspace-2134559/,如需轉載,請註明出處,否則將追究法律責任。

相關文章