LVM 逻辑卷的扩容/缩容(2)

注意:在进行扩容,缩容之后进行原有文件完整性校验的时候最好通过比较文件的md5值是否保持不变以判断操作对原有文件没有造成影响
如:
【1】扩容:两次/lv1/test1 的md5值均为d8b61b2c0025919d5321461045c8226f
[root@hyperStor ~]# md5sum  /lv1/test1
d8b61b2c0025919d5321461045c8226f  /lv1/test1
[root@hyperStor ~]# lvextend -L 2GB /dev/vg0/lv1
  Extending logical volume lv1 to 2.00 GiB
  Logical volume lv1 successfully resized
r[root@hyperStor ~]# resize2fs  /dev/vg0/lv1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/lv1 is mounted on /lv1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg0/lv1 to 524288 (4k) blocks.
The filesystem on /dev/vg0/lv1 is now 524288 blocks long.
[root@hyperStor ~]# df -H |grep lv1
/dev/mapper/vg0-lv1    2.2G  595M  1.5G  30% /lv1
[root@hyperStor ~]# md5sum  /lv1/test1
d8b61b2c0025919d5321461045c8226f  /lv1/test1

【2】缩容
[root@hyperStor ~]# md5sum  /lv1/test1
d8b61b2c0025919d5321461045c8226f  /lv1/test1
[root@hyperStor ~]# umount /lv1/
[root@hyperStor ~]# e2fsck  -f /dev/vg0/lv1
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/lv1: 12/131072 files (0.0% non-contiguous), 153389/524288 blocks
[root@hyperStor ~]# resize2fs  /dev/vg0/lv1  800M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg0/lv1 to 204800 (4k) blocks.
The filesystem on /dev/vg0/lv1 is now 204800 blocks long.
[root@hyperStor ~]# lvreduce  -L 800M /dev/vg0/lv1
  WARNING: Reducing active logical volume to 800.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv1? [y/n]: y
  Reducing logical volume lv1 to 800.00 MiB
  Logical volume lv1 successfully resized
[root@hyperStor ~]# mount  /dev/vg0/lv1  /lv1
[root@hyperStor ~]# md5sum  /lv1/test1
d8b61b2c0025919d5321461045c8226f  /lv1/test1

拓展:LVM 卷组“扩容/缩容”
上面说了如果对LVM 逻辑卷进行扩容以及缩容,这边说下如何对卷组进行所谓的扩容跟缩容,大家都知道卷组由物理卷组成,物理卷是卷组的最小组成单位,那么卷组的扩容跟缩容无非就是物理卷加入卷组以及移除卷组的过程。
vgextend vg0 new_pv //将新的pv设备加入vg0
vgreduce vg0 old_pv //将pv从vg0中删除,注意:是vgreduce 不是vgremove

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/19191.html