Does XFS support default quotas?

5,154

Solution 1

Not sure how you missed this, if you did read the man page.

limit [ -gpu ] bsoft=N | bhard=N | isoft=N | ihard=N | rtbsoft=N | rtb‐
   hard=N -d | id | name
       Set  quota  block  limits  (bhard/bsoft),  inode  count   limits
       (ihard/isoft)  and/or  realtime  block limits (rtbhard/rtbsoft).
       The -d option (defaults) can be used to set  the  default  value
       that  will be used, otherwise a specific user/group/project name
       or numeric identifier must be specified.

So you'll set a default quota something like:

# xfs_quota -x -c 'limit bsoft=1g bhard=1g -d' /home

Solution 2

I have something to add here that I hope will help other people with the same problem.

I have a single XFS filesystem mounted with uquota. I have multiple users using the filesystem whom I want limited, and one single super user (we'll call her "lisa") whom I do NOT want limited. I also have a postgres database on here (owned by user "postgres") which I do not want limited.

I found the xfs_quota man page somewhat lacking in its description of how the default limits actually work and couldn't find any resource anywhere else so this is what I have discovered.

Set the default limits...

xfs_quota -x -c 'limits bsoft=45G bhard=50g -d' /myxfs

Terrific. All quotas are set and any new user that logs in will automatically receive the default limit. Now I'll exclude my superuser and postgres from the default by setting their limits explicitly to 0.

xfs_quota -x -c 'limits bsoft=0 bhard=0 lisa' /myxfs
xfs_quota -x -c 'limits bsoft=0 bhard=0 postgres' /myxfs

Now I'll get a report...

xfs_quota -x -c 'report -h' /myxfs
User quota on /myxfs (/dev/sdc1)
                        Blocks              
User ID      Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
root        22.3G    45G    50G  00 [------]
postgres    59.1G      0      0  00 [------]
lisa        13.4T      0      0  00 [------]

Looks great! Right? Wrong! Despite this report, both postgres and lisa are still limited and are still using the default limits. As soon as I attempt to write anything as either user and run the report again...

                        Blocks              
User ID      Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
root        22.3G    45G    50G  00 [------]
postgres    59.1G    45G    50G  00 [------]
lisa        13.4T    45G    50G  00 [------]

settings have reverted!

To get around this, you have to set the limits of the users you don't want limited to a non zero value. So set it to something very high. I set mine to a PB.

                        Blocks              
User ID      Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
root        22.3G    45G    50G  00 [------]
postgres    59.1G  1000T  1000T  00 [------]
lisa        13.4T  1000T  1000T  00 [------]

This prevents my super user and postgres database from being limited, while maintaining the "default" 50G limit for all other users.

A couple of things to note:

  • The root user (or UID 0) is never limited by xfs_quota (according to the man page)
  • If you're wondering why no other users are showing in my report, it's because I am exporting them over NFS and although the limits are working and I can see them on the client, this is not reported by default on the server

Hope this helps someone.

Edit: You can display more UIDs by specifying the upper limit. E.g.

xfs_quota -x -c 'report -U 50000 -h' /storage/1
User quota on /myxfs (/dev/sdc1)
                        Blocks              
User ID      Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
#0          22.3G    50G    75G  00 [------]
#26         59.1G  1000T  1000T  00 [------]
#1000       13.4T  1000T  1000T  00 [------]
#2615       55.9G      0      0  00 [------]
#2705      207.4M      0      0  00 [------]
#2707      168.1G    50G    75G  00 [-none-]
#2718      178.5M    50G    75G  00 [------]
#16661     245.9M      0      0  00 [------]
#18806          0    50G    75G  00 [------]
#24403       2.5M      0      0  00 [------]
#24583       100K    50G    75G  00 [------]
#26153       4.1G    50G    75G  00 [------]
#26618        40K      0      0  00 [------]
#26765       320K    50G    75G  00 [------]
#27175      15.1G    50G    75G  00 [------]
#27189       2.5M    50G    75G  00 [------]

Awesome!

Share:
5,154

Related videos on Youtube

Systemspoet
Author by

Systemspoet

Updated on September 18, 2022

Comments

  • Systemspoet
    Systemspoet over 1 year

    We need to set a default quota for all users. From what I can see from man 8 xfs_quota, you can only set quotas for individual users. I need to set a quota that applies to everyone without having to enumerate each user.