Set Disk Quota2023/07/17 |
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 feature. |
root@dlp:~# df -h /home Filesystem Size Used Avail Use% Mounted on /dev/sdb1 157G 48K 149G 1% /home # set quota feature and re-mount root@dlp:~# umount /home root@dlp:~# tune2fs -O quota /dev/sdb1 tune2fs 1.47.0 (5-Feb-2023)
root@dlp:~#
mount /dev/sdb1 /home
# confirm root@dlp:~# tune2fs -l /dev/sdb1 | grep -i quota Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize quota metadata_csum User quota inode: 3 Group quota inode: 4 |
[3] | Set user Quota. For example, Apply quota to [debian] user. |
# 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 user debian (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 28 4096000 5120000 10 0 0
# show status root@dlp:~# repquota -au *** Report for user quotas on device /dev/sdb1 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 debian -- 20 4096000 5120000 5 0 0 |
[4] | If you'd like to apply setting of quota of a user to another user, set like follows. |
# apply setting of [debian] to [bookworm] root@dlp:~# edquota -p debian bookworm root@dlp:~# repquota -au *** Report for user quotas on device /dev/sdb1 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 debian -- 20 4096000 5120000 5 0 0 bookworm -- 16 4096000 5120000 4 0 0 |
[5] | Set group Quota. For example, Apply quota to [debian] 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 debian (gid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 28 4096000 5120000 10 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 debian -- 20 4096000 5120000 5 0 0 bookworm -- 16 0 0 4 0 0 |
[6] | It's possible to send warnings to use Warnquota. This setting needs SMTP service on your server. |
root@dlp:~#
vi /etc/quotatab # add device and description which quota is set
/dev/sdb1: Home Directory
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 Return-Path: <root@dlp.srv.world> X-Original-To: root@localhost Delivered-To: root@localhost Received: by dlp.srv.world (Postfix, from userid 0) id B0716A031A; Sun, 16 Jul 2023 20:37:53 -0500 (CDT) From: root@localhost Reply-To: root@localhost Subject: Over quota To: debian@dlp.srv.world Cc: root@localhost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Message-Id: <20230717013753.B0716A031A@dlp.srv.world> Date: Sun, 16 Jul 2023 20:37:53 -0500 (CDT) X-IMAPbase: 1689557878 2 X-UID: 1 Status: O Hi, We noticed that you are in violation with the quotasystem used on this system. We have found the following violations: Home Directory (/dev/vdb1) Block limits File limits Filesystem used soft hard grace used soft hard grace /dev/vdb1 +- 5000M 4000M 5000M 7days 10 0 0 We hope that you will cleanup before your grace period expires. Basically, this means that the system thinks you are using more disk space on the above partition(s) than you are allowed. If you do not delete files and get below your quota before the grace period expires, the system will prevent you from creating new files. For additional assistance, please contact us at root@localhost or via phone at 111122223333. |
Sponsored Link |
|