12 月 072012
 

卸载文件系统(默认600M容量)

[root@lvm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_lvm-lv_roo 2.0G 557M 1.3G 30% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 485M 40M 420M 9% /boot
/dev/mapper/vg_lvm-lv_tes 591M 17M 545M 3% /test
[root@lvm ~]# umount /test/
[root@lvm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_lvm-lv_roo 2.0G 557M 1.3G 30% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 485M 40M 420M 9% /boot
[root@lvm ~]#

扫描脱机文件系统

[root@lvm ~]# e2fsck -f /dev/mapper/vg_lvm-lv_test
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_lvm-lv_test: 16/38400 files (0.0% non-contiguous), 6629/153600 blocks

调整文件系统到200M大小

[root@lvm ~]# resize2fs -p /dev/mapper/vg_lvm-lv_test 200M
 resize2fs 1.41.12 (17-May-2010)
 Resizing the filesystem on /dev/mapper/vg_lvm-lv_test to 51200 (4k) blocks.
 Begin pass 2 (max = 4096)
 Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 Begin pass 3 (max = 5)
 Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 The filesystem on /dev/mapper/vg_lvm-lv_test is now 51200 blocks long.

调整逻辑卷到200M大小

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

重新挂载文件系统并查看容量

[root@lvm ~]# mount /test
 [root@lvm ~]# df -h
 Filesystem Size Used Avail Use% Mounted on
 /dev/mapper/vg_lvm-lv_root
 2.0G 557M 1.3G 30% /
 tmpfs 499M 0 499M 0% /dev/shm
 /dev/sda1 485M 40M 420M 9% /boot
 /dev/mapper/vg_lvm-lv_test
 197M 17M 170M 9% /test
 [root@lvm ~]#

查看调整逻辑卷容量后物理卷上的可用块

#pvdisplay /dev/sda2

逻辑卷的设备文件映射

[root@lvm ~]# ll /dev/vg_lvm/
 total 0
 lrwxrwxrwx. 1 root root 7 Dec 7 11:28 lv_root -> ../dm-0
 lrwxrwxrwx. 1 root root 7 Dec 7 11:28 lv_swap -> ../dm-1
 lrwxrwxrwx. 1 root root 7 Dec 7 11:43 lv_test -> ../dm-2
[root@lvm ~]# ll /dev/mapper/
 total 0
 crw-rw----. 1 root root 10, 58 Dec 7 11:28 control
 lrwxrwxrwx. 1 root root 7 Dec 7 11:28 vg_lvm-lv_root -> ../dm-0
 lrwxrwxrwx. 1 root root 7 Dec 7 11:28 vg_lvm-lv_swap -> ../dm-1
 lrwxrwxrwx. 1 root root 7 Dec 7 11:43 vg_lvm-lv_test -> ../dm-2
 [root@lvm ~]#

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)