• 随笔记录 磁盘配额2019.8.2


    1.为主机增加80G SCSI 接口硬盘

    2.划分三个各20G的主分区
    [root@localhost ~]# vi fdisk.sh
    #!bin/bash
    fdisk /dev/sdb<<EOF
    n
    p
    1

    +20G

    n
    p
    2

    +20G

    n
    p
    3

    +20G

    n


    w
    EOF
    [root@localhost ~]# fdisk -l /dev/sdb

    磁盘 /dev/sdb:85.9 GB, 85899345920 字节,167772160 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0xda48581c

    设备 Boot Start End Blocks Id System
    /dev/sdb1 2048 41945087 20971520 83 Linux
    /dev/sdb2 41945088 83888127 20971520 83 Linux
    /dev/sdb3 83888128 125831167 20971520 83 Linux
    /dev/sdb4 125831168 167772159 20970496 5 Extended
    3.将三个主分区转换为物理卷(pvcreate),扫描系统中的物理卷
    [root@localhost ~]# pvcreate /dev/sdb1
    Physical volume "/dev/sdb1" successfully created
    [root@localhost ~]# pvcreate /dev/sdb2
    Physical volume "/dev/sdb2" successfully created
    [root@localhost ~]# pvcreate /dev/sdb3
    Physical volume "/dev/sdb3" successfully created

    4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
    [root@localhost ~]# vgcreate -s 8 myvg /dev/sdb[12]
    Volume group "myvg" successfully created
    [root@localhost ~]# vgdisplay /dev/myvg
    --- Volume group ---
    VG Name myvg
    System ID
    Format lvm2
    Metadata Areas 2
    Metadata Sequence No 1
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 0
    Open LV 0
    Max PV 0
    Cur PV 2
    Act PV 2
    VG Size 39.98 GiB
    PE Size 8.00 MiB
    Total PE 5118
    Alloc PE / Size 0 / 0
    Free PE / Size 5118 / 39.98 GiB
    VG UUID vReCKf-e33K-bjT3-WzZI-wJ9Y-hQGA-sR5TXZ

    5.创建逻辑卷mylv,大小为30G
    [root@localhost ~]# lvcreate -L 30G -n mylv myvg
    Logical volume "mylv" created.
    6.将逻辑卷格式化成xfs文件系统,并挂载到/data目录上,创建文件测试
    [root@localhost ~]# mkfs -t xfs /dev/myvg/mylv
    meta-data=/dev/myvg/mylv isize=256 agcount=4, agsize=1966080 blks
    = sectsz=512 attr=2, projid32bit=1
    = crc=0 finobt=0
    data = bsize=4096 blocks=7864320, imaxpct=25
    = sunit=0 swidth=0 blks
    naming =version 2 bsize=4096 ascii-ci=0 ftype=0
    log =internal log bsize=4096 blocks=3840, version=2
    = sectsz=512 sunit=0 blks, lazy-count=1
    realtime =none extsz=4096 blocks=0, rtextents=0
    [root@localhost ~]# mkdir /data
    [root@localhost ~]# mount /dev/myvg/mylv /data

    7.增大逻辑卷到35G
    [root@localhost ~]# lvextend -L +5G /dev/myvg/mylv
    Size of logical volume myvg/mylv changed from 30.00 GiB (3840 extents) to 35.00 GiB (4480 extents).
    Logical volume mylv successfully resized

    8.编辑/etc/fstab文件挂载逻辑卷,并支持磁盘配额选项
    [root@localhost ~]# vim /etc/fstab
    /dev/myvg/mylv /data xfs defaults,usrquota,grpquota 0 0

    9.创建磁盘配额,crushlinux用户在/data目录下文件大小软限制为80M,硬限制为100M,
    crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
    [root@localhost ~]# mount -a
    [root@localhost ~]# quotacheck -vug /data/
    quotacheck: Skipping /dev/mapper/myvg-mylv [/data]
    quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
    [root@localhost ~]# quotaon -uv /data/
    quotaon: Enforcing user quota already on /dev/mapper/myvg-mylv
    [root@localhost ~]# useradd -d /data/milk milk
    [root@localhost ~]# edquota -u milk
    /dev/mapper/myvg-mylv 12 81920 102400 7 80 100

    10.使用touch dd 命令在/data目录下测试
    [root@localhost ~]# su milk
    [milk@localhost root]$ cd
    [milk@localhost ~]$ touch a
    [milk@localhost ~]$ dd if=/dev/zero of=./b bs=1M count=100
    dd: 写入"./b" 出错: 超出磁盘限额
    记录了100+0 的读入
    记录了99+0 的写出
    104837120字节(105 MB)已复制,3.20284 秒,32.7 MB/秒

    11.查看配额的使用情况:用户角度
    [milk@localhost ~]$ du -sh
    100M .

    12.查看配额的使用情况:文件系统角度
    [root@localhost milk]# repquota -auvs
    *** Report for user quotas on device /dev/mapper/myvg-mylv
    Block grace time: 7days; Inode grace time: 7days
    Space limits File limits
    User used soft hard grace used soft hard grace
    ----------------------------------------------------------------------
    root -- 0K 0K 0K 3 0 0
    milk +- 100M 81920K 100M 6days 14 80 100

    *** Status for user quotas on device /dev/mapper/myvg-mylv
    Accounting: ON; Enforcement: ON
    Inode: #131 (2 blocks, 2 extents)

  • 相关阅读:
    iostream与iostream.h的区别
    [HAOI2011]向量
    [POI2011]Temperature
    [洛谷2839/国家集训队]middle
    [TJOI2013]松鼠聚会
    [HNOI2015]接水果
    [BZOJ3772]精神污染
    [BZOJ3251]树上三角形
    [ZJOI2011]道馆之战
    [SDOI2013]森林
  • 原文地址:https://www.cnblogs.com/lyqlyqlyq/p/11288212.html
Copyright © 2020-2023  润新知