Page 1 of 1

[HOWTO] fix centos7 quota system on a xfs filesystem

Posted: Mon Oct 05, 2020 7:38 am
by bberg
centos7 seems to use xfs for the root filesystem (/) by default.
if you install vesta with the quota option enabled, this will cause errors.

vesta will change the fstab, adding mount options that are unknown to xfs.
when you boot with those options on, the root filesystem will be mounted read-only and services will not start.

here's the fix:

if your root filesystem is already mounted read-only, remount it

Code: Select all

mount -o remount,rw partition-id /
edit /etc/fstab and replace the mount options from something like this

Code: Select all

UUID=partition-id / xfs defaults,usrquota,grpquota,and-other-opts 0 0
to this

Code: Select all

UUID=partition-id / xfs defaults,uquota 0 0
the fstab option is not enough to enable quota on that partition.
you need to add kernel grub parameter to your grub configuration.
edit /etc/default/grub and append rootflags=uquota to GRUB_CMDLINE_LINUX
it may look like this

Code: Select all

GRUB_CMDLINE_LINUX="console=tty0 crashkernel=auto net.ifnames=0 console=ttyS0 rootflags=uquota"
backup the current grub file and rebuild it.

Code: Select all

cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bkp
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot the machine.

you may confirm that quotas are enabled if you see the usrquota option when listing your parititions.

Code: Select all

mount | grep xfs
vesta's quota system is managed by a script located at

Code: Select all

/usr/local/vesta/bin/v-update-user-quota
this script calls the setquota command to set users limits, but xfs uses the xfs_quota command.
append this line to the end of the script, but before logging

Code: Select all

test ! "$quota" == 'unlimited' && xfs_quota -x -c "limit -u bsoft=${quota}m bhard=${quota}m $user" $mnt
now that quotas are enabled, and the script is fixed, you must set the limits for each of your users.

Code: Select all

/usr/local/vesta/bin/v-update-user-quota user1
/usr/local/vesta/bin/v-update-user-quota user2
you may confirm that a user has limits by checking the xfs_quota reports

Code: Select all

xfs_quota -x -c 'report -h' /
and that's it.
future updates may replace this script, so you must keep an eye on it.

warning: editing fstab and grub may break your system. use caution.

Re: [HOWTO] fix centos7 quota system on a xfs filesystem

Posted: Sun Aug 14, 2022 11:26 pm
by dlozev
Thanks! That working.
But I have a problem with editing /etc/default/grub. When I tried to edit it as root, I receved error: Permission denied

OS: CentOS 7