码迷,mamicode.com
首页 > 其他好文 > 详细

LVM

时间:2014-06-26 06:02:51      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:技术   lvm   

Linux分区----------物理卷-----------卷组-----------逻辑卷

1.创建分区(fdisk /dev/sdx)

2.同步分区(partprobe)   //这两步简单我就直接略过

3.创建物理卷

[root@localhost ~]# pvcreate /dev/sda8 /dev/sda9 /dev/sda10

  Physical volume "/dev/sda8" successfully created

  Physical volume "/dev/sda9" successfully created

  Physical volume "/dev/sda10" successfully created

查询:pvdisplay

4.创建卷组

[root@localhost ~]# vgcreate vg01 /dev/sda8 /dev/sda9 /dev/sda10

  Volume group "vg01" successfully created

如果需要指定PE的大小则用-s选项

[root@localhost ~]# vgcreate vg01 -s  8M  /dev/sda8 /dev/sda9 /dev/sda10        //指定PE的大小为8M

查询:vgdisplay

5.创建逻辑卷

[root@localhost ~]# lvcreate -L 100M vg01 -n lv01   //-L直接指定分区的大小

  Logical volume "lv01" created

[root@localhost ~]# lvcreate -l 50   -n   lv01  vg01    //-l指定PE的个数

查询:lvdisplsy

6.格式化分区

#mkfs.ext3  /dev/vg01/lv01

7.挂载(步骤简单,此处略去。。)

8.扩展卷组

首先我们去创建一个新的分区,转换成物理卷

[root@localhost ~]# pvcreate /dev/sda11

  Physical volume "/dev/sda11" successfully created

[root@localhost ~]# vgextend vg01 /dev/sda11

  Volume group "vg01" successfully extended

[root@localhost ~]#

可以看到,vg01被成功的扩展。

9.扩展逻辑卷(例如原来是100M,增加50M)

[root@localhost ~]# lvextend -L 150M /dev/vg01/lv01    //或者: lvextend -L +50M /dev/vg01/lv01

  Rounding up size to full physical extent 152.00 MB

  Extending logical volume lv01 to 152.00 MB

  Logical volume lv01 successfully resized

有个很重要的地方,虽然我们用lvdisplay看到逻辑卷的确被扩展到150MB但用df –h查看到,我们逻辑卷的大小还是100MB。

现在有条命令可以解决这个问题

这条命令的作用就是将逻辑卷的大小拉升到挂载点上面,不需离线操作

[root@localhost ~]# resize2fs /dev/vg01/lv01 

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/vg01/lv01 is mounted on /mnt/lvm; on-line resizing required

Performing an on-line resize of /dev/vg01/lv01 to 155648 (1k) blocks.

The filesystem on /dev/vg01/lv01 is now 155648 blocks long.

10.减小卷组(将一个物理卷从卷组中T出去)

[root@localhost ~]# vgreduce vg01 /dev/sda11

  Removed "/dev/sda11" from volume group "vg01"

11.减小逻辑卷(减小到300M)

减小逻辑卷必须离线,必须卸载

#umount  /mnt/lvm                              卸载

#e2fsck –f /dev/vg01/lv01                  扫描

#resize2fs /dev/vg01/lv01 300M         减小文件系统

#lvreduce  -L 300M  /dev/vg01/lv01   减小逻辑卷

12删除LVM(删除的时候是倒着删除,先删除lv再删除vg在删除pv)

删除lvm

[root@localhost ~]# lvremove /dev/vg01/lv01 

Do you really want to remove active logical volume lv01? [y/n]: y

  Logical volume "lv01" successfully removed

删除vg

[root@localhost ~]# vgremove vg01

  Volume group "vg01" successfully removed

删除pv

[root@localhost ~]# pvremove /dev/sda8 /dev/sda9 /dev/sda10

  Labels on physical volume "/dev/sda8" successfully wiped

  Labels on physical volume "/dev/sda9" successfully wiped

Labels on physical volume "/dev/sda10" successfully wiped


本文出自 “精彩IT圈” 博客,转载请与作者联系!

LVM,布布扣,bubuko.com

LVM

标签:技术   lvm   

原文地址:http://jiagd.blog.51cto.com/3915719/1430807

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!