Disk /dev/hda: 21.4 GB, 21474836480 bytes 15 heads, 63 sectors/track, 44384 cylinders Units = cylinders of 945 * 512 = 483840 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2068 977098+ 8e Linux LVM /dev/hda2 2069 4136 977130 8e Linux LVM /dev/hda3 4137 6204 977130 8e Linux LVM接下来就开始创建物理卷: [root@localhost ~]# pvcreate /dev/hda{1,2,3} Writing physical volume data to disk "/dev/hda1" Physical volume "/dev/hda1" successfully created Writing physical volume data to disk "/dev/hda2" Physical volume "/dev/hda2" successfully created Writing physical volume data to disk "/dev/hda3" Physical volume "/dev/hda3" successfully created使用pvs命令可以查看物理卷的详细信息,我这里显示的可用空间没有达到原始大小是因为LVM需要保存一些元数据: [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/hda1 lvm2 a-- 954.20M 954.20M /dev/hda2 lvm2 a-- 954.23M 954.23M /dev/hda3 lvm2 a-- 954.23M 954.23M /dev/sda2 VolGroup00 lvm2 a-- 19.88G另外,使用怕pvdisplay可以查看物理卷的更详细的信息,使用pvscan可以查看一共创建了多少个pv。
第二步:创建vg,使用vgcreate命令。 l -s选项可以指定物理盘区的大小,默认为4M
[root@localhost ~]# vgcreate myvg /dev/hda{1,2,3} Volume group "myvg" successfully created使用vgremove命令可以移除vg:
[root@localhost ~]# vgremove myvg Volume group "myvg" successfully removed扩展vg,首先准备好一个pv分区: 12345 [root@localhost ~]# pvcreate /dev/hda5 Writing physical volume data to disk "/dev/hda5" Physical volume "/dev/hda5" successfully created [root@localhost ~]# vgextend myvg /dev/hda5 Volume group "myvg" successfully extended移除一块底层的磁盘的做法:首先要使用pvmove命令,作数据迁移的操作: [root@localhost ~]# pvmove /dev/hda3 No data to move for myvg然后使用vgreduce命令移除逻辑卷: [root@localhost ~]# vgreduce myvg /dev/hda3 Removed "/dev/hda3" from volume group "myvg"最后使用pvremove命令移除物理卷: [root@localhost ~]# pvremove /dev/hda3 Labels on physical volume "/dev/hda3" successfully wiped第三步:创建lv,使用lvcreate命令。
[root@localhost ~]# lvcreate -L 50M -n test0 myvg Rounding up size to full physical extent 56.00 MB Logical volume "test0" creat查看效果可以使用lvs命令或者lvdisplay命令: