zoukankan      html  css  js  c++  java
  • 磁盘配额

    LVM逻辑卷管理的课堂演示

    1. 在虚拟机添加一块新的虚拟硬盘(10G)

    [root@server01 ~]# fdisk -cul |grep -i vd
    ......

    Disk /dev/vdc: 10.7 GB, 10737418240 bytes

    2. 在系统中创建一个2G的分区,(建议把用作逻辑卷的分区的ID SYSTEM设为LVM类型)过程略。

    结果:
    [root@server01 ~]# fdisk -cul /dev/vdc
    ......
    Device Boot Start End Blocks Id System
    /dev/vdc1 2048 4196351 2097152 8e Linux LVM


    3. 将分区/dev/vdc1转换成物理卷(pv)

    [root@server01 ~]# pvcreate /dev/vdc1
    Physical volume "/dev/vdc1" successfully created

    4. 将物理卷加入一个卷组(vg)中,可以加入一个已有卷组,也可以创建一个新的卷组。

    [root@server01 ~]# vgcreate vg01 /dev/vdc1
    Volume group "vg01" successfully created


    5. 从卷组当中分配一定容量的空间给新建的逻辑卷(lv)

    [root@server01 ~]# lvcreate -L +1G -n lv01 vg01
    Logical volume "lv01" created


    6. 格式化该逻辑卷,并挂载使用。

    [root@server01 ~]# mkfs.ext4 /dev/vg01/lv01

    [root@server01 ~]# mkdir /docs
    [root@server01 ~]# mount /dev/vg01/lv01 /docs

    [root@server01 ~]# df -h |grep lv01
    /dev/mapper/vg01-lv01 1008M 34M 924M 4% /docs

    关于名称说明,挂载使用的名称是/dev/vg01/lv01 , 挂载之后在df看到设备路径和名称是/dev/mapper/vg01-lv01,两个名称都指的同一个设备,没有区别。

    [root@server01 ~]# ll /dev/vg01/lv01
    lrwxrwxrwx 1 root root 7 8月 1 10:07 /dev/vg01/lv01 -> ../dm-2
    [root@server01 ~]# ll /dev/mapper/vg01-lv01
    lrwxrwxrwx 1 root root 7 8月 1 10:07 /dev/mapper/vg01-lv01 -> ../dm-2
    [root@server01 ~]# ll /dev/dm-2
    brw-rw---- 1 root disk 253, 2 8月 1 10:07 /dev/dm-2


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

    如何查看lv vg pv

    查看逻辑卷:

    [root@server01 ~]# lvs
    LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
    lv01 vg01 -wi-ao---- 1.00g
    lv_root vg_mini -wi-ao---- 17.54g
    lv_swap vg_mini -wi-ao---- 1.97g

    其中,lv01是实验新建的, lv_root , lv_swap是在安装系统时自动创建的,lv_root是用于/分区,lv_swap用于交换分区。

    [root@server01 ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/vg_mini-lv_root 18G 1.7G 15G 11% /


    [root@server01 ~]# ll /dev/vg_mini/lv_swap
    lrwxrwxrwx 1 root root 7 8月 1 09:54 /dev/vg_mini/lv_swap -> ../dm-1

    [root@server01 ~]# cat /proc/swaps
    Filename Type Size Used Priority
    /dev/dm-1 partition 2064376 0 -1


    [root@server01 ~]# lvdisplay /dev/vg01/lv01
    --- Logical volume ---
    LV Path /dev/vg01/lv01
    LV Name lv01
    VG Name vg01
    LV UUID k0FvOD-xwpo-yY1q-2un2-ZdTE-dLoK-hBXU5v
    LV Write Access read/write
    LV Creation host, time server01, 2017-08-01 10:06:19 +0800
    LV Status available
    # open 1
    LV Size 1.00 GiB
    Current LE 256
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:2


    查看卷组:

    [root@server01 ~]# vgs
    VG #PV #LV #SN Attr VSize VFree
    vg01 1 1 0 wz--n- 2.00g 1020.00m
    vg_mini 1 2 0 wz--n- 19.51g 0


    [root@server01 ~]# vgdisplay vg01
    --- Volume group ---
    VG Name vg01
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 2
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 1
    Max PV 0
    Cur PV 1
    Act PV 1
    VG Size 2.00 GiB
    PE Size 4.00 MiB
    Total PE 511
    Alloc PE / Size 256 / 1.00 GiB
    Free PE / Size 255 / 1020.00 MiB
    VG UUID MDzsth-jgq3-Swcf-aF1X-T4tY-x2rr-qjfF8K


    PE是分区逻辑卷的最小单位4M,卷组的大小也可以用PE的个数来表示,511个PE。


    查看物理卷:
    [root@server01 ~]# pvs
    PV VG Fmt Attr PSize PFree
    /dev/vda2 vg_mini lvm2 a-- 19.51g 0
    /dev/vdc1 vg01 lvm2 a-- 2.00g 1020.00m

    [root@server01 ~]# pvdisplay /dev/vdc1
    --- Physical volume ---
    PV Name /dev/vdc1
    VG Name vg01
    PV Size 2.00 GiB / not usable 4.00 MiB
    Allocatable yes
    PE Size 4.00 MiB
    Total PE 511
    Free PE 255
    Allocated PE 256
    PV UUID 9mIE9U-bnrs-sQpM-xj83-W5mh-2Zvm-dg4Vwe

  • 相关阅读:
    Eclipse_debug异常_Source not found
    Mybatis异常_01_Invalid bound statement (not found)
    [转]Eclipse快捷键_01_常用快捷键汇总
    PL/SQL学习笔记_03_存储函数与存储过程
    PL/SQL学习笔记_02_游标
    PL/SQL学习笔记_01_基础:变量、流程控制
    Oracle学习笔记_05_分组函数
    博客园_01_为博客园添加目录的方法总结
    Oracle学习笔记_04_多表查询
    Oracle学习笔记_03_单行函数
  • 原文地址:https://www.cnblogs.com/yczlove/p/7326797.html
Copyright © 2011-2022 走看看