Linux User disk quotas

Source: Internet
Author: User
Tags disk usage nfsd

One: The kernel supports quota:
[[email protected]/]# grep config_quota/boot/config-3.10.0-123.el7.x86_64config_quota=yconfig_quota_netlink_ interface=y# Config_quota_debug is not setconfig_quota_tree=yconfig_quotactl=yconfig_quotactl_compat=y
If you have the above output, the current kernel already supports quota.
Second: Modify/etc/fstab to join quota support:
[Email protected]/]# Vim/etc/fstab
/dev/sdb1/dvd XFS Defaults,usrquota,grpquota 1 2
Three: Initialize the quota database with Quotacheck:
Because Quotacheck searches the file system based on/etc/mtab, the/dev/sdb1 you just modified is re-mounted
[[email protected]/]# mount/dvd-o remount       [[email  Protected]/]# mountproc On/proc type proc (rw,nosuid,nodev,noexec,relatime) Sysfs on/sys type SYSFS (Rw,nosuid,nod Ev,noexec,relatime,seclabel) Devtmpfs On/dev type DEVTMPFS (rw,nosuid,seclabel,size=926912k,nr_inodes=231728,mode= 755) Securityfs on/sys/kernel/security type SECURITYFS (rw,nosuid,nodev,noexec,relatime) Tmpfs on/dev/shm type TMPFS (rw , Nosuid,nodev,seclabel) devpts on/dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode= Tmpfs on/run type TMPFS (rw,nosuid,nodev,seclabel,mode=755) Tmpfs on/sys/fs/cgroup type Tmpfs (Rw,nosuid,nodev, noexec,seclabel,mode=755) Cgroup on/sys/fs/cgroup/systemd type Cgroup (rw,nosuid,nodev,noexec,relatime,xattr, RELEASE_AGENT=/USR/LIB/SYSTEMD/SYSTEMD-CGROUPS-AGENT,NAME=SYSTEMD) Pstore on/sys/fs/pstore type Pstore (Rw,nosuid, Nodev,noexec,relatime) Cgroup on/sys/fs/cgroup/cpuset type Cgroup (Rw,nosuid,nodev,Noexec,relatime,cpuset) Cgroup On/sys/fs/cgroup/cpu,cpuacct type Cgroup (RW,NOSUID,NODEV,NOEXEC,RELATIME,CPUACCT, CPU) Cgroup on/sys/fs/cgroup/memory type Cgroup (rw,nosuid,nodev,noexec,relatime,memory) Cgroup on/sys/fs/cgroup/ Devices type Cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on/sys/fs/cgroup/freezer type Cgroup (Rw,nosuid, Nodev,noexec,relatime,freezer) Cgroup on/sys/fs/cgroup/net_cls type Cgroup (rw,nosuid,nodev,noexec,relatime,net_cls ) Cgroup On/sys/fs/cgroup/blkio type Cgroup (Rw,nosuid,nodev,noexec,relatime,blkio) Cgroup on/sys/fs/cgroup/perf_ Event Type Cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on/sys/fs/cgroup/hugetlb type Cgroup (Rw,nosuid, nodev,noexec,relatime,hugetlb) Configfs on/sys/kernel/config type Configfs (rw,relatime)/dev/sda3 on/type xfs (rw, Relatime,seclabel,attr2,inode64,noquota) selinuxfs on/sys/fs/selinux type SELINUXFS (rw,relatime) systemd-1 on/proc/ Sys/fs/binfmt_misc type AutoFS (rw,relatime,fd=32,pgrp=1,timeout=300,minproto=5, maxproto=5,direct) Hugetlbfs on/dev/hugepages type Hugetlbfs (rw,relatime,seclabel) Debugfs on/sys/kernel/debug type Debugfs (rw,relatime) mqueue on/dev/mqueue type Mqueue (rw,relatime,seclabel) sunrpc on/var/lib/nfs/rpc_pipefs type rpc_ Pipefs (rw,relatime) sunrpc on/proc/fs/nfsd type NFSD (rw,relatime)/dev/sda1 on/boot type XFS (rw,relatime,seclabel,attr 2,inode64,noquota)/dev/sdb1 On/dvd type ext2 (Rw,relatime,seclabel,quota,usrquota,grpquota) [[email protected]/]# Quotacheck-avugquotacheck:quota for users are enabled on Mountpoint/dvd so Quotacheck might damag e the file. Turn quotas off or use-f to force checking.-a: Scans all file systems that have/etc/mtab open in quota-V: Displays the scanning process-U: Scans all user quotas (USRQ Uota)-G: Scan all group quotas (Grpquota)
Four: Start quota: (Quotaon for startup Quotaoff to OFF)
[[email protected]/]# QUOTAON-AVUG/DEV/SDB1 [/DVD]: Group quotas turned ON/DEV/SDB1 [/DVD]: User quotas turned on-a: Open All quota settings, according to/etc/mtab set-V: Display information when quota is turned on
Five: Edit the user disk quota:
Here the user quota maximum usage capacity is 20M, when using to 10M will be warned to reduce to 10M can create up to 10 files, when the creation of 5 files will be warned to reduce the requirement to 5 files [[email protected]/]# Edquota -u redhat (Redhat for System user name) Disk quotas for user redhat (UID):  Filesystem           & nbsp       blocks       Soft       hard     inodes     Soft &N Bsp   hard /dev/sdb1                         0   & nbsp          0          0           0              0        0 change to   disk quotas for user Redhat (UID): &nbs P Filesystem                   blocks       Soft     & nbsp Hard     inodes     soft     hard /dev/sdb1                        0         10240       20480        0         5          1 0-u: Edit User's quota-g: Edit Group's quota-t: Edit Grace Time-P: Copy quota data to another user Blocks: Current user (quota:uid=5011) space used in/dev/hda7, in KB (do not modify) Soft:soft limit disk space limit value units: KB (required) Hard:hard limit disk space limit Value Unit: KB (requires setting) Inodes: The current user-used inodes, because it is not easy to use the Inode control, so do not modify it. Soft:soft Limit file Limits quantity (modified as needed) Hard:hard limit file limits quantity (modified as needed) soft limit: minimum limited capacity, within grace period, use capacity to exceed SOF T limit, but you must reduce the usage capacity below soft limit within the grace period. Hard limit: The final limit of capacity, if the user continues to write data within the grace period, the arrival of the drive limit will no longer be written. Grace Time: Use more than soft limit, grace time automatically start, the user will reduce the capacity to soft limit, the grace time automatically shut down, if the user does not reduce the capacity to soft limit within the grace time, then he will no longer write data, Even if the use of capacity does not reach hard limit
Six. Set the grace time:
[Email protected] dvd]# Edquota-tgrace period before enforcing soft limits for users:time units may be:days, hours, min                  Utes, or seconds Filesystem Block grace period Inode Grace Period/dev/sdb1 7days 7days [Email protected] dvd]# quota-uv Redhat (-u: Displays user. -V: Show quota value) Disk quotas for user Redhat (UID): Filesystem blocks quota limit grace files quota Li MIT grace/dev/sdb1 0 10240 20480 0 5 10
Seven. Copy the quota data to another user using the-p parameter:
[Email protected] dvd]# edquota-p Redhat AAA
[[email protected] dvd]# QUOTA-UV aaadisk quotas for user aaa (UID 1001): Filesystem Blocks Quota limit Grace Files Quota limit grace/dev/sdb1 0 10240 20480 0 5 10 Replicate to multiple users at the same time:
[[Email protected] DVD] #edquota-P redhat ' awk-f: ' $ >499 {print '} '/etc/passwd ' to replicate the quota disk quota data to all UID >499 users (Users with UID above 500 are usually real users)
Eight. Automatic activation of quota at system startup:
Can be added to/etc/rc.d/rc.sysinit or/etc/rc.d/rc.local, add a line at the end:/usr/sbin/quotaon-aug also remember the system shutdown/restart script (/etc/rc.d/rc[0,6]/) Add close quota to the statement:/usr/sbin/quotaoff-aug
Nine. Query disk quotas:
[[email protected] dvd]# repquota-a*** Report for user quotas on Device/dev/sdb1block Grace T ime:24:00; Inode Grace time:7days                         Block limits                 File limitsuser             used    soft    hard  grace    used  soft  hard  Grace----------------------------------------------------------------------root      --              0       0 & nbsp                      2     0      0       
10. Scheduled Tasks Quotcheck:
Quotcheck is used to scan the file system for disk usage, and update aquota.user,aquota.group to keep the quota record to the latest state. It is therefore best to perform at system startup or cron periodically: every Saturday, seven o'clock: 0 7 * * 6/sbin/quotacheck-avug

Linux User disk quotas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.