How to Enable XFS Disk quota in CentOS and CWP panel
In this tutorial we’ll configure XFS disk quota in centos and CWP control web panel. In server xfs quota setup will not work because of Kernel parameter is set to “noquota” we’ll bypass and configure it with the help of below tutorial which is easy to follow and configure.
The XFS quota subsystem manages limits on disk space (blocks) and file (inode) usage. XFS quotas control or report on usage of these items on a user, group, or directory or project level.
Install quota packages :
yum -y install quota*
For EL8/RHEL 8/CentOS 8 only :
dnf --enablerepo=Devel install quota*
Now we’ll check the disk type and double check if it is XFS file system :
mount | grep ' / '
output :
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
If you’ve separate disk/partition for /home :
mount | grep ' /home '
output
/dev/mapper/centos-root-home on /home type xfs (rw,relatime,attr2,inode64,noquota)
**** if you see “xfs“ and “noquota” in output proceed with this steps :
Edit grub and add this kernel grub parameter rootflags=uquota,pquota
:
rootflags=uquota,pquota under GRUB_CMDLINE_LINUX option at last and under quotes
chattr -i /etc/default/grub nano /etc/default/grub
Example :
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="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet rootflags=uquota,pquota"
GRUB_DISABLE_RECOVERY="true"
Now backup current grub config and rebuild grub :
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig grub2-mkconfig -o /boot/grub2/grub.cfg
On some OS boot path has been changed for EFI [EFI BOOT] :/boot/efi/EFI/centos/grub.cfg
Check if you’ve EFI grub support is there :
If this command reports there is no such file you can ignore this step
ls /boot/efi/EFI/centos/grub.cfg
If file is present then you also need to rebuild EFI grub :
cp /boot/efi/EFI/centos/grub.cfg /boot/efi/EFI/centos/grub.cfg.org grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Now edit fstab :
edit file: /etc/fstab and add usrquota,grpquota example:/dev/mapper/centos_root / xfs defaults,usrquota,grpquota 0 0
before example :
/dev/mapper/centos-root / xfs defaults 0 0
after example :
/dev/mapper/centos-root / xfs defaults,usrquota,grpquota 0 0
Then reboot you Server :
reboot
Then check if the quota is enabled or not “noquota” should be gone now and replaced with “usrquota,grpquota” :
mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
For CWP only :
Activate quota as XFS for /
in CWP.admin go to Left Menu -> Server Settings –> Disk Quota , and set
Quota Partition: /
Quota Type: xfs
If you’ve separate disk/partition for /home :
edit file: /etc/fstab and add usrquota,grpquota example:/dev/mapper/centos-root-home /home xfs defaults,usrquota,grpquota 0 0
before example
/dev/mapper/centos-root-home /home xfs defaults 0 0
after example
/dev/mapper/centos-root-home /home xfs defaults,usrquota,grpquota 0 0
Then reboot you Server :
reboot
Then check if the quota is enabled or not “noquota” should be gone now and replaced with “usrquota,prjquota” :
For /home
mount | grep ' /home '
/dev/mapper/centos-root-home on /home type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
For CWP only :
Activate quota as XFS for /home
in CWP.admin go to Left Menu -> Server Settings –> Disk Quota , and set
Quota Partition: /home
Quota Type: xfs
Done you’ve enabled xfs quota update the packages for the users by selecting update quota for users option and check the disk quota.
CWP only :
After enabling the quota run this command to update the user quota in CWP :
/scripts/cwp_api account update_diskquota_all