Set Disk Quota2018/11/27 |
Limit amount of disk usage to set Disk Quota.
For example on here, Set Quota on /home which is ext4 formatted.
For using Quota on XFS file system, refer to here. |
|
[1] | Install Quota tools. |
root@dlp:~# apt -y install quota quotatool
|
[2] | Enable Quota to add mount options. |
# re-mount with adding quota options root@dlp:~# umount /home root@dlp:~# mount -o usrquota,grpquota /dev/sdb1 /home
root@dlp:~#
vi /etc/fstab # add options
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=cf3f9660-e40d-459d-8763 /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /home xfs defaults,usrquota,grpquota 0 0
|
[3] | Set user Quota. For example, Apply quota to [ubuntu] user. |
# show status root@dlp:~# quotaon -ap group quota on /home (/dev/sdb1) is off user quota on /home (/dev/sdb1) is on project quota on /home (/dev/sdb1) is off # set Soft Limit 4G, Hard Limit 5G (specify with kilo bytes) Disk quotas for user ubuntu (uid 500): Filesystem blocks soft hard inodes soft hard /dev/sdb1 32 4096000 5120000 7 0 0 # show status root@dlp:~# repquota -au
*** Report for user quotas on device /dev/mapper/vg_volume01-lv_volume01
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20 0 0 2 0 0
ubuntu -- 32 4096000 5120000 10 0 0
|
[4] | If you'd like to apply setting of quota of a user to another user, set like follows. |
# apply setting of [ubuntu] to [fedora] root@dlp:~# edquota -p ubuntu fedora root@dlp:~# repquota -au *** Report for user quotas on device /dev/mapper/vg_volume01-lv_volume01 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 20 0 0 2 0 0 ubuntu -- 32 4096000 5120000 10 0 0 fedora -- 16 4096000 5120000 4 0 0 |
[5] | Set group Quota. For example, Apply quota to [ubuntu] group. |
# show status root@dlp:~# quotaon -ap group quota on /home (/dev/sdb1) is on user quota on /home (/dev/sdb1) is on project quota on /home (/dev/sdb1) is off # set Soft Limit 4G, Hard Limit 5G (specify with kilo bytes)
Disk quotas for group ubuntu (gid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 5120000 4096000 5120000 7 0 0
# show status root@dlp:~# repquota -ag *** Report for group quotas on device /dev/sdb1 Block grace time: 7days; Inode grace time: 7days Block limits File limits Group used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 20 0 0 2 0 0 ubuntu +- 5120000 4096000 5120000 6days 7 0 0 fedora -- 16 0 0 4 0 0 |
[6] | It's possible to send warnings to use Warnquota. This setting needs SMTP server on your server. |
root@dlp:~#
vi /etc/quotatab # add device and description which quota is set
/dev/sdb1: Your Home Director
root@dlp:~#
vi /etc/warnquota.conf # change mail sender or others if you need MAIL_CMD = "/usr/sbin/sendmail -t" FROM = "root@localhost" # but they don't have to be: SUBJECT = Over quota CC_TO = "root@localhost" SUPPORT = "root@localhost" PHONE = "<enter your phone number here>" # CHARSET = UTF-8 # run warnquota root@dlp:~# warnquota -s
# if a user is over the limit when warnquota runs, following warning is sent From root@dlp.srv.world Fri Oct 23 09:38:10 2011 Return-Path: <root@dlp.srv.world> X-Original-To: ubuntu Delivered-To: ubuntu@dlp.srv.world From: root@srv.world Reply-To: root@srv.world Subject: NOTE: You are exceeding your allocated disk space limits To: ubuntu@dlp.srv.world Cc: root@srv.world Date: Fri, 23 Oct 2011 09:38:10 +0900 (JST) Status: R Your disk usage has exceeded the agreed limits on this server Please delete any unnecessary files on following filesystems: Your Home Director (/dev/sdb1) Block limits File limits Filesystem used soft hard grace used soft hard grace /dev/sdb1 +- 5000M 4000M 5000M 6days 7 0 0 root@srv.world |
Sponsored Link |
|