在之前LVM分区无损增减 篇中有提到过LVM分区的无损增大和减小,不同的是,当是只是针对LVM下的ext分区的,在新版的RHEL7/centos7中默认使用的分区格式是xfs ,本篇就针对LVM下ext4和xfs分区的增大和缩小再唠叨下。
一、ext4分区下LVM的动态调整
在使用lvresize调整大小时结常需要注意与resize2fs执行的顺序。缩小空间时,一定要先执行resize2fs再执行lvresize;而增大时一定要先执行lvextend再执行resize2fs 。
1、减小大小
减小LVM分区时,一定要先umount掉挂载点再进行操作。
[root@361way.com ~]# df -H /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg-lvol0 805M 2.7M 760M 1% /mnt
[root@361way.com ~]# umount /mnt/
[root@361way.com ~]# resize2fs -f /dev/vg/lvol0 100M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg/lvol0 to 102400 (1k) blocks.
The filesystem on /dev/vg/lvol0 is now 102400 blocks long.
[root@361way.com ~]# lvresize -L 100M /dev/vg/lvol0
WARNING: Reducing active logical volume to 100.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvol0? [y/n]: y
Size of logical volume vg/lvol0 changed from 800.00 MiB (200 extents) to 100.00 MiB (25 extents).
Logical volume lvol0 successfully resized
[root@361way.com ~]# mount /dev/vg/lvol0 /mnt/
[root@361way.com ~]# df -H /mnt/
Filesystem Size Used Avail