LVM逻辑卷管理(下)

 LVM相比较于传统分区其优势在于可以动态扩大缩小分区大小。

扩容vg

[root@lvm ~]# pvcreate /dev/sdg

  Physical volume "/dev/sdg" successfully created

[root@lvm ~]# pvcreate /dev/sdh

  Physical volume "/dev/sdh" successfully created

[root@lvm ~]# vgextend photo /dev/sd[gh]

  /dev/cdrom: open failed: 只读文件系统

  /dev/cdrom: open failed: 只读文件系统

  Attempt to close device '/dev/cdrom' which is not open.

  Volume group "photo" successfully extended

给photo 这个vg扩容,增加了2个pv进来

---------------------------------------------------------------------

扩容lv

[root@lvm 7yue5]# lvextend -L +20G /dev/photo/7yue5 扩容20G

  /dev/cdrom: open failed: 只读文件系统

  Extending logical volume 7yue5 to 40.00 GB

[root@lvm 7yue5]# resize2fs /dev/photo/7yue5 重新识别文件系统的大小 

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/photo/7yue5 is mounted on /7yue5; on-line resizing required

Performing an on-line resize of /dev/photo/7yue5 to 10485760 (4k) blocks.

The filesystem on /dev/photo/7yue5 is now 10485760 blocks long.

---------------------------------------------------------------------

然后缩小分区与扩大相似,只是resize2fs和lvextend(vgextend)的顺序相反,即先用resize2fs,再用resize2fs。

---------------------------------------------------------------------

另外要注意的是不要再没关闭LVM的情况下关闭分区

正确的步骤是:

1.umonut卸载LVM文件系统

2.lvremove删除逻辑卷

3.vgremove删除卷组

4.pvremove删除物理卷

5.清除/etc/fstab中的LVM挂载记录

6.fdisk修改分区ID

你可能感兴趣的:(lvm,缩小,动态扩容)