User home folder size limit
-
Open
/etc/fstab
with a commandline editor (vi, sed, nano) to add theusrquota
and/orgrpquota
to the partition (depending on your needs: pick one or both)(and yes, it assumes you use a partition for it and in this case that would be /home/):- userquota is for users
- grpquouta is for groups
-
Create a file for user and/or group:
touch /home/aquota.user touch /home/aquota.group
-
The files need to be owned by
root
and have600
as permissionssudo chown root:root /home/aquota.user sudo chown root:root /home/aquota.group sudo chmod 600 /home/aquota.user sudo chmod 600 /home/aquota.group
-
reboot or remount the partition.
- command
quotaon -av
will enable quota -
command
edquota -u {user_id}
will let you edit them where {user_id} is the id of the user. This will openvi
for editing the quota.Setting the quota is done in "blocks" or "inodes" and there are 2 options:
- soft: Max number of blocks/inodes a user may have on the partition before a warning is issued and a grace period countdown begins.
- hard: Max number of blocks/inodes user may have on partition. (If set to zero then no limit is enforced on either of the options).
The best would be by percentage for two users 45% and 45%. But by gigabytes will be fine as well.
- Blocks are probably 4kB (
stat -f .
will show the blocksize on your system). - Inodes means amount of files and directories.
Answer based on this how to. The link has a lot more information about commands related to this and explains it a bit more in depth.
Related videos on Youtube
user3324547
Updated on September 18, 2022Comments
-
user3324547 almost 2 years
I am trying to find anything on the web no success. Is there any way to limit size of home directory for user ? Or any directory ? The best would be by percentage for two users 45% and 45%. But by gigabytes will be fine as well.
Thank you so much.
-
Edward Torvalds over 8 yearsdoes this method requires
/home/
dir to be mounted on separate partition? -
Rinzwind over 8 yearsyes it needs a partition.