增加lv的容量
 
 1. 增加一个物理卷
[root@wangfc ~]# fdisk /dev/sdb
 
[root@wangfc ~]# pvcreate /dev/sdb6
  Physical volume "/dev/sdb6" successfully created
 
 2. 把物理卷加入到逻辑卷中
 
[root@wangfc ~]# vgextend vg0 /dev/sdb6
  Volume group "vg0" successfully extended
 
 3. 扩展逻辑卷[分区] logical volumes
 
[root@wangfc ~]# lvextend -L +30M /dev/vg0/lv0
 
  Rounding up size to full physical extent 32.00 MiB
  Extending logical volume lv0 to 44.00 MiB
  Logical volume lv0 successfully resized
 
 4 . 增加到文件系统  [重启计算机也没有用,只能用以下命令]
 
[root@wangfc ~]# resize2fs /dev/vg0/lv0
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/lv0 is mounted on /mnt/lvm0; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg0/lv0 to 45056 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 45056 blocks long.
 
[root@wangfc ~]# lvdisplay   查看
  --- Logical volume ---
  LV Name                /dev/vg0/lv0
  VG Name                vg0
  LV UUID                AzmuiW-GleK-3Gdp-d8tG-5KGX-fzEl-mtvPoB
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                44.00 MiB
  Current LE             11
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  
[root@wangfc ~]# vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               64.00 MiB
  PE Size               4.00 MiB
  Total PE              16
  Alloc PE / Size       11 / 44.00 MiB
  Free  PE / Size       5 / 20.00 MiB
  VG UUID               AMDxvI-i3Nw-O7hj-mU2R-jQiY-cu5p-ygcKhD
减小LV容量
 
需要严格按步骤执行,否则后果很严重
 
  1. 必须离线
 [root@wangfc ~]# umount /mnt/lvm0/
 
注意了:可能出现以下情况,细心谨慎
 
无法umount /home
可能是文件自动挂载的原因
 
如果停止文件自动挂载服务,也umount /home不成,查看vim /etc/fstab
 
原来/home下还挂载/rhome,所以要先 umount /home/rhome,再停止自动挂载服务。
还有一种办法:[root@desktop6 ~]# fuser -v /mnt
                [root@desktop6 ~]# kill -9 pid
 
  1. 强制扫描文件系统,只是必须的
 
[root@wangfc ~]# e2fsck -f /dev/vg0/lv0
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/vg0/lv0: 11/9216 files (9.1% non-contiguous), 2399/45056 blocks
 
  1. 减小文件系统
 
[root@wangfc ~]# resize2fs /dev/vg0/lv0 20M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg0/lv0 to 20480 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 20480 blocks long.
 
  1. 减小逻辑卷
 
[root@wangfc ~]# resize2fs /dev/vg0/lv0 20M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg0/lv0 to 20480 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 20480 blocks long.
[root@wangfc ~]# mount /dev/vg0/lv0 /mnt/lvm0/
[root@wangfc ~]# lvreduce -L -20M /dev/vg0/lv0   WARNING: Reducing active and open logical volume to 24.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv0? [y/n]: y
  Reducing logical volume lv0 to 24.00 MiB
  Logical volume lv0 successfully resized
[root@wangfc ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg0/lv0
  VG Name                vg0
  LV UUID                AzmuiW-GleK-3Gdp-d8tG-5KGX-fzEl-mtvPoB
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                24.00 MiB
  Current LE             6
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
 
  1. 检查数据
[root@wangfc ~]# cd /mnt/lvm01