Linux LVM(Logical Volume Manager)

假设有3个disk 分区(/dev/sda1,/dev/sda2,/dev/sda3),先用2个做一个logical volume,在上面分一个区出来,然后假设这个区数据满了,把另外一个disk 分区弄上去,不丢数据

 

基本概念

物理卷

物理分区(physical extent)

卷组

逻辑卷(logical volume)

建立2个disk分区的logical volume

  1. 把/dev/sda1,/dev/sda2的分区类型修改为0x8e,"linux LVM" ( fdisk )

     

    [root@SpecialProtocol root]# fdisk /dev/sda
    
    The number of cylinders for this disk is set to 89410.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    
    Command (m for help): t
    Partition number (1-4): 1
    Hex code (type L to list codes): 8e
    Changed system type of partition 1 to 8e (Linux LVM)
    
    Command (m for help):
    

     

  2. 建立物理卷

     

    [root@SpecialProtocol root]# pvcreate /dev/sda1 /dev/sda2 
    pvcreate -- physical volume "/dev/sda1" successfully created
    pvcreate -- physical volume "/dev/sda2" successfully created
    

     

  3. 把物理卷加到卷组

     

    [root@SpecialProtocol root]# vgcreate test /dev/sda1 /dev/sda2
    vgcreate -- INFO: using default physical extent size 32 MB
    vgcreate -- INFO: maximum logical volume size is 2 Terabyte
    vgcreate -- doing automatic backup of volume group "test"
    vgcreate -- volume group "test" successfully created and activated
    

     

    检查

     

    [root@SpecialProtocol root]# vgdisplay -v test
    --- Volume group ---
    VG Name               test
    VG Access             read/write
    VG Status             available/resizable
    VG #                  0
    MAX LV                256
    Cur LV                0
    Open LV               0
    MAX LV Size           2 TB
    Max PV                256
    Cur PV                2
    Act PV                2
    VG Size               306.31 GB
    PE Size               32 MB
    Total PE              9802
    Alloc PE / Size       0 / 0
    Free  PE / Size       9802 / 306.31 GB
    VG UUID               6v7zQA-H22c-AeQ3-1wN1-KBV9-ByZd-LJfllT
    
    --- No logical volumes defined in "test" ---
    
    
    --- Physical volumes ---
    PV Name (#)           /dev/sda1 (1)
    PV Status             available / allocatable
    Total PE / Free PE    4901 / 4901
    
    PV Name (#)           /dev/sda2 (2)
    PV Status             available / allocatable
    Total PE / Free PE    4901 / 4901

     

  4. 建立逻辑卷

     

    [root@SpecialProtocol root]# lvcreate -L 306G -n lgdisk test
    lvcreate -- doing automatic backup of "test"
    lvcreate -- logical volume "/dev/test/lgdisk" successfully created
    

     

  5. 建立文件系统

     

    mkfs -t ext3 /dev/test/lgdisk
    

     

  6. mount 文件系统就可以用了

     

    [root@SpecialProtocol root]# mount  /dev/test/lgdisk  /mnt
    

     

 

增加一个disk分区

过一段时间后,/dev/test/lgdisk满了,把/dev/sda3加上去用

如果卷组有多的空间,直接调用e2fsadm就可以了,下面我们做的事情是假设要加一个硬盘上去

  1. umount 文件系统

  2. 增加卷组

     

    [root@SpecialProtocol root]# pvcreate /dev/sda3
    pvcreate -- physical volume "/dev/sda3" successfully created

     

     

    [root@SpecialProtocol root]#  vgextend  test /dev/sda3
    vgextend -- INFO: maximum logical volume size is 2 Terabyte
    vgextend -- doing automatic backup of volume group "test"
    vgextend -- volume group "test" successfully extended
    

     

  3. 增长逻辑卷

     

    [root@SpecialProtocol root]# lvextend -L+300G /dev/test/lgdisk
    lvextend -- extending logical volume "/dev/test/lgdisk" to 606 GB
    lvextend -- doing automatic backup of volume group "test"
    lvextend -- logical volume "/dev/test/lgdisk" successfully extended

     

  4. 增长文件系统(对ext2,ext3文件有效)

     

    [root@SpecialProtocol root]# e2fsck -f /dev/test/lgdisk
    e2fsck 1.32 (09-Nov-2002)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    /lost+found not found.  Create<y>? yes
    
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    
    /dev/test/lgdisk: ***** FILE SYSTEM WAS MODIFIED *****
    /dev/test/lgdisk: 257/40108032 files (0.0% non-contiguous), 6761839/80216064 blocks
    

     

     

    [root@SpecialProtocol root]# resize2fs /dev/test/lgdisk
    resize2fs 1.32 (09-Nov-2002)
    The filesystem on /dev/test/lgdisk is now 158859264 blocks long.
    

     

  5. mount文件系统,就可以使用了

     

    mount  /dev/test/lgdisk  /mnt

     

配置文件

/etc/lvmconf/ ./etc/lvmtab.d/ , /etc/lvmtab

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值