How to Enable XFS Disk quota in CentOS and CWP panel

by Sandeep B.

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,prjquota”  :

mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)

For /home

mount | grep ' /home '
/dev/mapper/centos-root-home on /home type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)

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

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.

 

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

You may also like

16 comments

Saleh Fauzan July 15, 2020 - 10:06 am

Amazing!!!! 2 year and now been solved
Am i can donate?

Reply
Saleh Fauzan July 15, 2020 - 10:09 am

http://i.imgur.com/vTmm2PI.png

fail to donate from paypal
i will try another way

Reply
Sandeep B. July 15, 2020 - 10:36 am

you can share our site in place of donation 🙂

Reply
Saleh Fauzan July 28, 2020 - 4:53 am

ok Sandeep

Reply
Saleh Fauzan July 28, 2020 - 4:52 am

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)

Reply
Jose September 1, 2020 - 8:16 am

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!

Reply
Sandeep B. September 1, 2020 - 11:21 am

probably you missed the fstab edit section

Reply
Jose September 1, 2020 - 11:26 am

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

Reply
Sandeep B. September 1, 2020 - 11:30 am

after you edited grub and fstab reboot your server

Reply
Jose September 1, 2020 - 11:31 am

Yes, I did, which is why I find it odd that it follows the same result. 😀

Sandeep B. September 1, 2020 - 11:40 am

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.

Jose September 1, 2020 - 12:00 pm

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

Jose September 1, 2020 - 12:10 pm

I opened a ticket for the same server, if it helps you you can use the access data:

#765354

Sandeep B. September 1, 2020 - 12:39 pm

i added instruction for centos 8 since developer header package need to be installed check once again.

Jose September 1, 2020 - 12:56 pm

Nothing, I’m stuck, I can’t get out of it. 😀

Sandeep B. September 1, 2020 - 3:12 pm

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 😀

Leave a Comment