鸟哥的Linux私房菜笔记-配额

文章目录

  1. 1. 配额
    1. 1.1. quota
    2. 1.2. quotaon
    3. 1.3. quotaoff
    4. 1.4. edquota
    5. 1.5. quota
    6. 1.6. repquota
    7. 1.7. warnquota
    8. 1.8. setquota
    9. 1.9. journaled quota
    10. 1.10. mdadm
    11. 1.11. LVM

笔记记录于《鸟哥的Linux私房菜-第三版》,以备多看。

配额

单次生效:
mount -o remount,usrquota,grpquota 单独的filesystem #对应/etc/mtab

每次开机有效 编辑/etc/fstab
UUID=XXX 单独的filesystem ext4 defaults,usrquota,grpquota 0 0
umount 单独的filesystem
mount -a
mount|grep 单独的filesystem #确认是否添加quota

quota

  • -auvg #扫描需要quota的filesystem [a-/etc/mtab中找需要quota的filesystem;u-user;g-group]
  • -mf #强制执行检查写入

quotaon

  • -avug #第一次启动quota

    quotaoff

  • -aug

    edquota

  • -u user #用户配额

  • -g group #组配额

  • -t #修改宽限时间

  • -p 范本账号 -u 新账号 #复制配额

单位kb

quota

  • -u user #显示用户配额

  • -v #显示所有用户配额

  • -g group #显示用户配额

  • -s #按M显示配额

    repquota

  • -auvgs #显示整个filesystem配额

    warnquota

  • 执行会判断是否需要邮件提醒,需要则会发给root和目标用户邮件

  • 每日自动执行

    echo "/usr/sbin/warnquota"> /etc/cron.daily/warnquota
    chmod 755 /etc/cron.daily/warnquota

    setquota

    setquota [-u|-g] [-rm] [-F quotaformat] <user|group> -a|
    setquota [-u|-g] [-rm] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|
    setquota [-u|-g] [-rm] [-F quotaformat] -b [-c] -a|
    setquota [-u|-g] [-F quotaformat] -t -a|
    setquota [-u|-g] [-F quotaformat] <user|group> -T -a|

    journaled quota

    quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
    yum install quota

Edit: /etc/fstab

vi /etc/fstab 

replace “defaults” with “usrjquota=quota.user,jqfmt=vfsv0” for / mount point

Before:

UUID=ac567666-9385-4ef5-885c-80f61ec64647       /       ext3    defaults        1       1

After Replace:

UUID=ac567666-9385-4ef5-885c-80f61ec64647       /       ext3    usrjquota=quota.user,jqfmt=vfsv0        1       1

mount -o remount /
quotacheck -avugm
quotaon -avug

If you have /home in /etc/fstab then you will need to edit line matching /home
replace “defaults” with “usrjquota=quota.user,jqfmt=vfsv0” for /home mount point

Before:

UUID=ac567666-9385-4ef5-885c-80f61ec64647       /home       ext3    defaults        1       1

After Replace:

UUID=ac567666-9385-4ef5-885c-80f61ec64647       /home       ext3    usrjquota=quota.user,jqfmt=vfsv0        1       1

mount -o remount /home
quotacheck -avugm
quotaon -avug

Now you need to add this into the CWP Configuration

mkdir -p /usr/local/cwp/.conf/
echo "/home" > /usr/local/cwp/.conf/quota_part.conf

How to check if quota works ?

repquota -a

This will display you user limits

[添加组配额要加上]: grpjquota=aquota.group

参考自:How to setup user quotas

mdadm

  • RAID

    LVM

如有疑问,请文末留言交流或邮件:newbvirgil@gmail.com 本文链接 : https://newbmiao.github.io/2015/09/15/Niaoge-Linux-Desktop-Guide-notes-quota.html