LVM 管理之二:缩减 LV 大小

转载http://francs3.blog.163.com/blog/static/4057672720122299250175/

今天学习了 RHEL6 缩减 LV 大小,下面的例子目标是将LV "/dev/mapper/vg_redhat6-lv_pgdata_01"
缩小 86 M。    
 

--1 当前LVM 信息

 /dev/mapper/vg_redhat6-lv_root
                       13G  7.7G  4.6G  63% /
tmpfs                 250M  264K  250M   1% /dev/shm
/dev/sda1             485M   31M  429M   7% /boot
/dev/sr0              2.9G  2.9G     0 100% /media/RHEL_6.2 i386 Disc 1
/dev/mapper/vg_redhat6-lv_pgdata_01
                      786M  593M  154M  80% /database/skytf/pgdata1

   
                     

--2 卸载文件系统 ( unmount )

 [root@redhat6 ~]# umount /dev/mapper/vg_redhat6-lv_pgdata_01

--3 检查文件系统( e2fsck )

 [root@redhat6 ~]# e2fsck /dev/mapper/vg_redhat6-lv_pgdata_01
e2fsck 1.41.12 (17-May-2010)
/dev/mapper/vg_redhat6-lv_pgdata_01: clean, 236/49152 files, 154817/179200 blocks

   

   
--4 缩小文件系统 ( resize2fs )

 [root@redhat6 ~]# resize2fs -f /dev/mapper/vg_redhat6-lv_pgdata_01 700M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_redhat6-lv_pgdata_01 to 179200 (4k) blocks.
The filesystem on /dev/mapper/vg_redhat6-lv_pgdata_01 is now 179200 blocks long.         

                
 
--5 缩小LV大小( lvreduce )

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

     
 
--6 查看当前 LV 大小

 [root@redhat6 ~]# lvs
  LV           VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_pgdata_01 vg_redhat6 -wi-a- 700.00m                                     
  lv_root      vg_redhat6 -wi-ao  13.10g                                     
  lv_swap      vg_redhat6 -wi-ao   1.91g  


  
 备注: 逻辑卷  lv_pgdata_01 已经缩减成 700M了。
 

--7 重新挂载文件系统,查看 

 [root@redhat6 ~]# mount  -t ext4 /dev/mapper/vg_redhat6-lv_pgdata_01 /database/skytf/pgdata1
[root@redhat6 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_redhat6-lv_root
                       13G  7.7G  4.6G  63% /
tmpfs                 250M  264K  250M   1% /dev/shm
/dev/sda1             485M   31M  429M   7% /boot
/dev/sr0              2.9G  2.9G     0 100% /media/RHEL_6.2 i386 Disc 1
/dev/mapper/vg_redhat6-lv_pgdata_01
                      688M  593M   61M  91% /database/skytf/pgdata1      

       
                    
       备注:目录 /database/skytf/pgdata1  已成功缩减到 700M 左右。         
       --8 总结
 
    在缩减LV 大小前,首先得先缩减文件系统大小。 

猜你喜欢

转载自www.cnblogs.com/useradd/p/10005207.html