0

in RHEL 8.9, I have a 100gb XFS formatted /home partition; all local user accounts in /etc/passwd have their home directories under /home. And all user accounts primary gid is and will always be 100 {users}.

I would like to apply a quota of 1GB per user on their /home account as an administration effort to manage data. I have 80 users currently in /etc/passwd can expect it to grow back up over 150.

I currently have in /etc/fstab

UUID=12345   /home   xfs    defaults,nodev,nosuid,uquota,gquota    0 0
  • What are the correct arguments to pass to the xfs_quota command?
  • If I have 80 users, do I have to do 80 xfs_quota commands one for each account under /home? Or can it be done with one command instance?
  • should a mount -o remount /home work? I'm finding it doesn't and either a successful umount or reboot is needed. Will a umount -l work? How dangerous is this on an active system with users logged in?
  • For all new users in the future, will a new xfs_quota need to be performed on their home folder or is there a way to have it automatically applied?

1 Answer 1

0
  • xfs_quota needs the -x option (supposedly "expert mode") to do anything useful. This is very easy to overlook.

  • If you want to give all 80 users the same quota, you could do something like:

    for user in $(awk -F: '($3 > 1000 && $3 < 60000){print $1}' /etc/passwd); do \
    xfs_quota -x -c "limit -u bhard=1024m $user" /home; done
    
  • I think you need to set uquota (or gquota) at mount time. I don't think you can switch it on (or off) with a remount.

  • For a default quota, you can set a quota for UID 0 - that will be used as the default quota for any user that does not have a specific quota set. For example, you could create a test FS:

    # mkdir /mnt/test
    # lvcreate -L 1G -n test datavg
    # mkfs.xfs /dev/mapper/datavg-test
    # mount /dev/mapper/datavg-test /mnt/test -o uquota
    # xfs_quota -x -c "report" /mnt/test
    User quota on /mnt/test (/dev/mapper/datavg-test)
                                   Blocks
    User ID          Used       Soft       Hard    Warn/Grace
    ---------- --------------------------------------------------
    root                0          0          0     00 [--------]
    
  • Then you could set a specific quota (100k for UID 101), and a default quota (200k for UID 0):

    # xfs_quota -x -c "limit -u bhard=100k 101" /mnt/test
    # xfs_quota -x -c "limit -u bhard=200k 0" /mnt/test
    
  • Then if you create some data owned by UID 101 (with a specific quota) and UID 102 (with no specific quota), and look at a quota report:

    # dd if=/dev/zero of=/mnt/test/f1 bs=1k count=10; chown 101 /mnt/test/f1
    # dd if=/dev/zero of=/mnt/test/f2 bs=1k count=10; chown 102 /mnt/test/f2
    # xfs_quota -x -c "report" /mnt/test
    User quota on /mnt/test (/dev/mapper/datavg-test)
                                   Blocks
    User ID          Used       Soft       Hard    Warn/Grace
    ---------- --------------------------------------------------
    root                0          0        200     00 [--------]
    #101               12          0        100     00 [--------]
    #102               12          0        200     00 [--------]
    

You can see that UID 101 has the specific quota that was set, but UID 102 inherited the default quota.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .