Background
Enabling disk quotas are essential to managing your hard drive resources. Even if you don’t have restrictions, turning on quotas and putting in soft limits can give you a lot of extra scope when managing a server.
Here are some of useful commands to troubleshoot quotas on a Virtualmin server with an XFS file system.
Please note that it’s best to set up quotas when the server is installed as doing it retrospectively can be challenging to impossible.
Commands Used to Troubleshoot
fstab
The fstab entry for the file system needs to have three items to make quotes work:
- quota
- grpquota
- usrquota
Here is an example:
> cat /etc/fstab # # /etc/fstab # Created by anaconda on Fri Apr 17 08:51:42 2020 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs quota,attr2,grpquota,usrquota,inode64,relatime,rw 0 0 UUID=a9c6187c-7d38-4266-b818-d086f77086d4 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0
GRUB
Grub also needs to be aware of XFS quotas by way of the rootflags=uquota,gquota
switch.
Here is an example:
> cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet rootflags=uquota,gquota" GRUB_DISABLE_RECOVERY="true"
One can’t just upgrade GRUB, you have to run a special command to do so.
Here is the command to update GRUB:
> grub2-mkconfig -o /boot/grub2/grub.cfg
So make the change first, then run the command.
After quota have been enabled you can see if it’s worked by using any of the following two commands.
mount | grep quota
In the output below one can see the /
mount point has quota enabled by way of the usrquota
and grpquota
flags:
> mount | grep quota /dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota) /dev/vda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
The XFS command you can use to see if quotas are active is this one:
xfs_quota -x -c state
Here is sample output:
> xfs_quota -x -c state User quota state on / (/dev/mapper/centos-root) Accounting: ON Enforcement: ON Inode: #739207 (25 blocks, 24 extents) Group quota state on / (/dev/mapper/centos-root) Accounting: ON Enforcement: ON Inode: #981933 (19 blocks, 15 extents) Project quota state on / (/dev/mapper/centos-root) Accounting: OFF Enforcement: OFF Inode: #981933 (19 blocks, 15 extents) Blocks grace time: [7 days] Inodes grace time: [7 days] Realtime Blocks grace time: [7 days]
On this XFS file system User and Group quotas are enabled and Project quotas are not enabled.
Finally Virtualmin provides a command line way of enabling quotas, in case you didn’t want to do it through the UI. This command is:
virtualmin-config-system -i=Quotas
And here is the output: > virtualmin-config-system -i=Quotas [1/1] Configuring Quotas The filesystem / could not be remounted with quotas enabled. You will need to reboot your system to enable quotas. [ ⚠ ]