缩小文件系统空间--LVM

在缩减逻辑卷的大小时,一定要注意操作顺序,逐级减小:先缩减依赖该LV的文件系统的大小,再缩减该LV的大小,否则该LV上的所有数据可能报废!本示例基于EXT4格式的文件系统。
下面我们将逻辑卷lv01的大小缩减到80M,具体操作过程如下:
1、执行如下操作,查看当前文件系统的信息:

[root@wa ~]# df -hP
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_wa-lv_root   23G   11G   11G  50% /
tmpfs                 499M     0  499M   0% /dev/shm
/dev/sda1             485M   33M  427M   8% /boot
/dev/mapper/vg_wa-lv01  101M  5.3M   91M   6% /test01

2、卸载文件系统:

[root@wa ~]# umount /dev/mapper/vg_wa-lv01

3、检查文件系统:

[root@wa ~]# e2fsck /dev/mapper/vg_wa-lv01
e2fsck 1.41.12 (17-May-2010)
/dev/mapper/vg_wa-lv01: clean, 11/24752 files, 8485/106496 blocks

4、缩小文件系统:

[root@wa ~]# resize2fs -f /dev/mapper/vg_wa-lv01 80M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_wa-lv01 to 81920 (1k) blocks.
The filesystem on /dev/mapper/vg_wa-lv01 is now 81920 blocks long.

5、缩小逻辑卷

[root@wa ~]# lvreduce -L 80M /dev/mapper/vg_wa-lv01
  WARNING: Reducing active logical volume to 80.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv01? [y/n]: y
  Reducing logical volume lv01 to 80.00 MiB
  Logical volume lv01 successfully resized

6、重新挂载文件系统:

[root@wa ~]# mount -t ext4 /dev/mapper/vg_wa-lv01 /test01
[root@wa ~]# df -hP
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_wa-lv_root   23G   11G   11G  50% /
tmpfs                 499M     0  499M   0% /dev/shm
/dev/sda1             485M   33M  427M   8% /boot
/dev/mapper/vg_wa-lv01   78M  5.3M   69M   8% /test01

你可能感兴趣的:(缩小文件系统空间--LVM)