一、查看逻辑卷状态
[root@instructor Desktop]# fdisk -cul /dev/testvg/testlv
Disk /dev/testvg/testlv: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
二、查看逻辑卷是否被挂载,并卸载逻辑卷
[root@instructor Desktop]# mount
/dev/mapper/GLSvg-GLSroot on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/GLSvg-GLShome on /home type ext4 (rw)
/dev/mapper/GLSvg-GLStmp on /tmp type ext4 (rw)
/dev/sda5 on /usr/local/share/gls/GLSINST type ext4 (ro)
/dev/mapper/GLSvg-GLSvar on /var type ext4 (rw)
/dev/mapper/GLSvg-GLSpub on /var/ftp/pub type ext4 (rw)
/usr/local/share/gls/GLSINST/rhel6/isos/rhel-server-6.3-x86_64-dvd.iso on /var/ftp/pub/rhel6/dvd type iso9660 (ro,loop=/dev/loop0)
/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)
[root@instructor Desktop]# umount /dev/testvg/testlv
[root@instructor Desktop]# mount
/dev/mapper/GLSvg-GLSroot on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/GLSvg-GLShome on /home type ext4 (rw)
/dev/mapper/GLSvg-GLStmp on /tmp type ext4 (rw)
/dev/sda5 on /usr/local/share/gls/GLSINST type ext4 (ro)
/dev/mapper/GLSvg-GLSvar on /var type ext4 (rw)
/dev/mapper/GLSvg-GLSpub on /var/ftp/pub type ext4 (rw)
/usr/local/share/gls/GLSINST/rhel6/isos/rhel-server-6.3-x86_64-dvd.iso on /var/ftp/pub/rhel6/dvd type iso9660 (ro,loop=/dev/loop0)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
三、检查并测试缩小逻辑卷是否合理
[root@instructor Desktop]# e2fsck -f /dev/testvg/testlv
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/testvg/testlv: 11/3276800 files (0.0% non-contiguous), 251699/13107200 blocks
[root@instructor Desktop]# resize2fs /dev/testvg/testlv 40G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/testvg/testlv to 10485760 (4k) blocks.
The filesystem on /dev/testvg/testlv is now 10485760 blocks long.
四、缩小逻辑卷
[root@instructor Desktop]# lvresize -L 40G /dev/testvg/testlv
WARNING: Reducing active logical volume to 40.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce testlv? [y/n]: Y
Reducing logical volume testlv to 40.00 GiB
Logical volume testlv successfully resized
五、重建逻辑卷的文件系统
[root@instructor Desktop]# resize2fs /dev/testvg/testlvresize2fs 1.41.12 (17-May-2010)
The filesystem is already 10485760 blocks long. Nothing to do!
六、挂载逻辑卷
[root@instructor Desktop]# mount /dev/testvg/testlv /tmp/testlv
[root@instructor Desktop]# mount
/dev/mapper/GLSvg-GLSroot on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/GLSvg-GLShome on /home type ext4 (rw)
/dev/mapper/GLSvg-GLStmp on /tmp type ext4 (rw)
/dev/sda5 on /usr/local/share/gls/GLSINST type ext4 (ro)
/dev/mapper/GLSvg-GLSvar on /var type ext4 (rw)
/dev/mapper/GLSvg-GLSpub on /var/ftp/pub type ext4 (rw)
/usr/local/share/gls/GLSINST/rhel6/isos/rhel-server-6.3-x86_64-dvd.iso on /var/ftp/pub/rhel6/dvd type iso9660 (ro,loop=/dev/loop0)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/mapper/testvg-testlv on /tmp/testlv type ext4 (rw)
[root@instructor Desktop]#