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
Is there a way to re calculate disk space usage for all users or particular user?
yes run this script api :
/scripts/cwp_api account update_diskquota_all
Hello,
I dont have xfs disk type, I m using contabo, and it shows ext4, do i need to change xfs to ext4 in /etc/fstab ?
please help
this tutorial is only for xfs, don’t try to change anything in /etc/fstab which is not mentioned in the tutorial.
Thanks for sharing this.
I had to modify this entry to make it function:
rootflags=uquota,pquota under GRUB_CMDLINE_LINUX
using this:
rootflags=usrquota,grpquota under GRUB_CMDLINE_LINUX
veryyyy gooood my friand
xfs defaults,usrquota,grpquota 0 0 OR usrquota,prjquota and here in GRUB ? rootflags=uquota,pquota OR rootflags=uquota,gquota
It didn’t work for me… after doing the grub and efi steps, I restarted. But the command shows:
mount | grep ‘ / ‘
/dev/md3 on / type xfs (rw,relatime,attr2,inode64,noquota)
What can happen? It’s cents 8.
Greetings!
probably you missed the fstab edit section
No, look what’s in the file:
/dev/md3 / xfs rw,relatime,attr2,inode64,usrquota,grpquota 0 0
UUID=”**” /boot xfs defaults 0 0
UUID=”**” swap swap defaults 0 0
UUID=”**” swap swap defaults 0 0
LABEL=EFI_SYSPART /boot/efi vfat defaults 0 0
after you edited grub and fstab reboot your server
Yes, I did, which is why I find it odd that it follows the same result. 😀
change from
/dev/md3 / xfs rw,relatime,attr2,inode64,usrquota,grpquota 0 0
to
/dev/md3 / xfs defaults,usrquota,grpquota 0 0
reboot then check.
if not you can contact via forum with server detail.
I just realised, CWP does show the result as it should, but the ssh command doesn’t. Curious, isn’t it?
https://i.gyazo.com/b235eb0530153374b11e63e9f1f70770.png
I opened a ticket for the same server, if it helps you you can use the access data:
#765354
i added instruction for centos 8 since developer header package need to be installed check once again.
Nothing, I’m stuck, I can’t get out of it. 😀
i checked it
[root@servidor system]# cat /proc/mounts | grep /dev/md3
/dev/md3 / xfs rw,relatime,attr2,inode64,noquota 0 0
[root@servidor system]# cat /etc/fstab | grep md3
/dev/md3 / xfs defaults,usrquota,grpquota 0 0
seems your server OS is hard coded somewhere to ignore fstab lol 😀
my review,, i have test this tutorial on aws LightSail (VPS) it working well, as i know in aws LightSail (VPS) not use KVM but use xenxen-hvmaws (see screenshoot : http://i.imgur.com/DJpldCS.png) and no problem just working well (http://i.imgur.com/ucTsBXx.png)
Amazing!!!! 2 year and now been solved
Am i can donate?
http://i.imgur.com/vTmm2PI.png
fail to donate from paypal
i will try another way
you can share our site in place of donation 🙂
ok Sandeep