zoukankan      html  css  js  c++  java
  • Linux磁盘管理:lvcreate 常用命令

    查看当前LV及PV信息:

    [root@rusky ~]# hostnamectl
       Static hostname: localhost.localdomain
    Transient hostname: rusky.com
             Icon name: computer-vm
               Chassis: vm
            Machine ID: 9c10c7a9e32e40acb19659a30f73603b
               Boot ID: d20cdc4bccf04de3bc2639830b61a8e6
        Virtualization: kvm
      Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
           CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
                Kernel: Linux 3.10.0-327.el7.x86_64
          Architecture: x86-64
    ------------------------------------------------------------------------------------------------
    [root@rusky ~]# pvs
      PV         VG          Fmt  Attr PSize  PFree 
      /dev/sda2  rhel        lvm2 a--   7.51g 40.00m
      /dev/sdb   yum_repo_vg lvm2 a--  15.00g 15.00g    --有一个15G大小的PV,VG名字为yum_repo_vg
    [root@rusky ~]# lvs    --有两个默认的LV:root、swap
      LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root rhel -wi-ao----   6.67g                                                    
      swap rhel -wi-ao---- 820.00m                                                    
    

    1在名为yum_repo_vg的卷组上创建一个大小为5GB的逻辑卷

    [root@rusky ~]# lvcreate -L 5G yum_repo_vg 
      Logical volume "lvol0" created.
    [root@rusky ~]# lvs
      LV    VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root  rhel        -wi-ao----   6.67g                                                    
      swap  rhel        -wi-ao---- 820.00m                                                    
      lvol0 yum_repo_vg -wi-a-----   5.00g           
    

    虽然没有用-n指定逻辑卷的名字,但是lvcreate命令会自动命名逻辑卷lvo10.

    2. 在名为yum_repo_vg的卷组上创建一个大小为2GB的逻辑卷yum_repo_lvm

    [root@rusky ~]# lvcreate -L 2G -n yum_repo_lvm yum_repo_vg 
      Logical volume "yum_repo_lvm" created.
    [root@rusky ~]# lvs
      LV           VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root         rhel        -wi-ao----   6.67g                                                    
      swap         rhel        -wi-ao---- 820.00m                                                    
      lvol0        yum_repo_vg -wi-a-----   5.00g                                                    
      yum_repo_lvm yum_repo_vg -wi-a-----   2.00g            
    

    使用-n指定逻辑卷的名字

    3. 在名为yum_repo_vg的卷组上创建一个逻辑卷yum_repo_lvm2,大小为50%的VG 

    [root@rusky ~]# pvs
      PV         VG          Fmt  Attr PSize  PFree 
      /dev/sda2  rhel        lvm2 a--   7.51g 40.00m
      /dev/sdb   yum_repo_vg lvm2 a--  15.00g  8.00g
    [root@rusky ~]# lvcreate -l 50%VG -n yum_repo_lvm2 yum_repo_vg
      Logical volume "yum_repo_lvm2" created.
    [root@rusky ~]# lvs
      LV            VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root          rhel        -wi-ao----   6.67g                                                    
      swap          rhel        -wi-ao---- 820.00m                                                    
      lvol0         yum_repo_vg -wi-a-----   5.00g                                                    
      yum_repo_lvm  yum_repo_vg -wi-a-----   2.00g                                                    
      yum_repo_lvm2 yum_repo_vg -wi-a-----   7.50g   ---使用的是50%VG.PSize                 
    

    注意:-l 50%VG是使用PSize的50%,而不是PFree的50%,如果是使用%80VG=12G,大于PFree8G,则报错

    4. 在名为yum_repo_vg的卷组上创建一个逻辑卷yum_repo_lvm3,使用全部可用VG空间

    [root@rusky ~]# pvs
      PV         VG          Fmt  Attr PSize  PFree  
      /dev/sda2  rhel        lvm2 a--   7.51g  40.00m
      /dev/sdb   yum_repo_vg lvm2 a--  15.00g 512.00m
    [root@rusky ~]# lvcreate -l 100%FREE -n yum_repo_lvm3 yum_repo_vg
      Logical volume "yum_repo_lvm3" created.
    [root@rusky ~]# lvs
      LV            VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root          rhel        -wi-ao----   6.67g                                                    
      swap          rhel        -wi-ao---- 820.00m                                                    
      lvol0         yum_repo_vg -wi-a-----   5.00g                                                    
      yum_repo_lvm  yum_repo_vg -wi-a-----   2.00g                                                    
      yum_repo_lvm2 yum_repo_vg -wi-a-----   7.50g                                                    
      yum_repo_lvm3 yum_repo_vg -wi-a----- 512.00m   --使用全部的PFee                                                 
    [root@rusky ~]# pvs
      PV         VG          Fmt  Attr PSize  PFree 
      /dev/sda2  rhel        lvm2 a--   7.51g 40.00m
      /dev/sdb   yum_repo_vg lvm2 a--  15.00g     0   --PFree为0
    

    原文参考:http://www.ehowstuff.com/4-lvcreate-command-examples-on-linux/

  • 相关阅读:
    Atitit  Uncaught (in promise) SyntaxError Unexpected token < in JSON at position 0
    Atitit  验证 数字验证 非空验证的最佳算法  h5
    Atitit 转移特效attilax总结
    Atitit Loading 动画效果
    Atitit 项目管理 提升开发效率的项目流程方法模型 哑铃型  橄榄型 直板型
    Atitit hibernate3 hinernate4 hibernate5新特性attilax总结
    Atitit js es5 es6新特性 attilax总结
    Atitit mybatis 3 3.2 3.3  3.4 新特性attilax总结
    Atitit spring 3.0 3.1 3.2 4.0 4.3 5.0 新特性
    Atitit jquery  1.4--v1.11  v1.12  v2.0  3.0 的新特性
  • 原文地址:https://www.cnblogs.com/rusking/p/5955491.html
Copyright © 2011-2022 走看看