How to setup user quotas ?

Started by Administrator, September 09, 2014, 09:59:48 PM

Previous topic - Next topic

Administrator

Let's say that your /home partition is in / mount point

install quota on your centos
yum install quota

Edit: /etc/fstab   
vi /etc/fstab 
replace "defaults" with "usrjquota=quota.user,jqfmt=vfsv0" for / mount point

Before (in some cases this can be different!):
UUID=ac567666-9385-4ef5-885c-80f61ec64647       /       ext3    defaults        1       1
After Replace: UUID=ac567666-9385-4ef5-885c-80f61ec64647       /       ext3    usrjquota=quota.user,jqfmt=vfsv0        1       1

mount -o remount /
quotacheck -avugm
quotaon -avug




If you have /home in /etc/fstab then you will need to edit line matching /home
replace "defaults" with "usrjquota=quota.user,jqfmt=vfsv0" for /home mount point

Before: UUID=ac567666-9385-4ef5-885c-80f61ec64647       /home       ext3    defaults        1       1
After Replace: UUID=ac567666-9385-4ef5-885c-80f61ec64647       /home       ext3    usrjquota=quota.user,jqfmt=vfsv0        1       1

mount -o remount /home
quotacheck -avugm
quotaon -avug


Now you need to add this into the CWP Configuration

mkdir -p /usr/local/cwp/.conf/
echo "/home" > /usr/local/cwp/.conf/quota_part.conf



How to check if quota works ?
repquota -a
This will display you user limits

Set a quota for all users by package from cwp
/scripts/cwp_api account update_diskquota_all


If you had previously added users then you will need to update the quota for them, you can do that by clicking on each account edit and then saving changes, or you can edit packages and save them for all users.


XFS Quota (only for XFS file system!!!)
yum -y install quota quota-devel

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
aftere example
/dev/mapper/centos_root-home /home xfs defaults,usrquota,grpquota 0 0

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

reboot the server

Next, activate quota for all accounts
in cwp.admin go to Left Menu -> Packages -> List Packages
edit all packages you have and select "Update Quota" to set the quota for all accounts using this package.

How to check if /home is mounted with quota
mount |grep home
if you have there listed usrquota,grpquota for /home then all should work fine.
=============
XFS: In some cases, you would also need to modify grub conf if the above fails

# mount | grep ' / '
/dev/mapper/cl-root on / type xfs (rw,relatime,attr2,inode64,noquota)



If you see "noquota" in the xfs mount options for the / partition then you would need to modify file: /etc/default/grub
Find the line with the variable "GRUB_CMDLINE_LINUX" and at end of the line add: "rootflags=uquota,pquota"

Example:
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet rootflags=uquota,pquota"

Make backup and create grub config for boot
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
grub2-mkconfig -o /boot/grub2/grub.cfg
echo xfs > /usr/local/cwp/.conf/quota_type.conf


now reboot the server
reboot

after reboot run API to set quota for all users
/scripts/cwp_api account update_diskquota_all

Note: If you want emails and user home to be under the same quota then /var/vmail and /home need to be on the same partition.

skycom

Hello, I had install my CentOS Web Panel and I config Quota like said here. Now I create a Domain and I´m traying to upload an archive.

In the FileZilla, give me an error and its create me a file with 0K of space.

Any Help?

Administrator

login to user panel and check quota usage

Teucrus

Hi,
My /etc/fstab only has these records in it:

none    /dev/pts        devpts  rw,gid=5,mode=620       0       0
none    /dev/shm        tmpfs   defaults                0       0

I can't seem to find the / mount point. The above is the only contents of the file.

Administrator

on the OpenVZ VPS servers you should contact your hosting provider to do that for you.

Teucrus

I am my hosting provider. I own the whole dedicated server. Are you saying I should install it on the host server?
I have root access to both the vps and the dedicated server.


ashokjp

Should we enable journalled quota ?

at hardware level secondary quota enabled but still this is the output
Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs       60G  3.5G   57G   6% /
none            512M  4.0K  512M   1% /dev
[root@s2 ~]# mount -o remount /
mount: permission denied

[root@s2 ~]# quotacheck -avugm
quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
quotacheck: Quota for users is enabled on mountpoint / so quotacheck might damage the file.
Please turn quotas off or use -f to force checking.

Administrator

for openvz system you need to contact your hosting provider.

erm3nda

Related to OpenVZ, the first check we have to do is change another's fresh user account the try to write disk.

If you can write disk with ANY user you have not reach OpenVZ container and it's your server problem/missconfiguration. If you reach global Container limits, you can write at all, plus the VPS can shutdown due to that and restart in recovery mode.

A example to write test can be using dd, by creating dummy file:
dd if=/dev/urandom of=delete-me bs=128M count=1; sync; rm -f delete-me; echo "Test finished. File removed.";

This will write 128Mb of random content and show you statistitcs.

Regards.
8==D it's a function that try to compare 8 (int) against D (string) which returns True or False depending on the asker.

infinitech07

I had the quota installed and set the necessary settings on /etc/fstab, but sometimes when restarted the server and re-login onto CWP it showed the quota notification again.

How can I set the quota permanently onto the server??

Quote[root@server ~]# ll /dev/root
ls: cannot access /dev/root: No such file or directory
[root@server ~]# ln -s /dev/xvda /dev/root
[root@server ~]# ll /dev/root
lrwxrwxrwx 1 root root 9 Dec 30 10:37 /dev/root -> /dev/xvda
[root@server ~]# mount -o remount /
[root@server ~]# quotacheck -avugm
quotacheck: Scanning /dev/root [/] done
quotacheck: Old group file name could not been determined. Usage will not be substracted.
quotacheck: Checked 11062 directories and 110366 files
[root@server ~]# quotaon -avug
/dev/root [/]: user quotas turned on

Administrator

what is the output of:
df -h
cat /etc/fstab

alexchar

What about KVM? I didn't understood what should I replace as I don't have
UUID=ac567666-9385-4ef5-885c-80f61ec64647       /       ext3    defaults        1       1
or
mount -o remount /
quotacheck -avugm
quotaon -avug


I'm using KVM Vps server.
Sorry for my English :(

MyBuddyBen

Can someone do a YouTube video of how to do this?  ;D It would help me a bunch!
Trying to help people :)
Chords and Lyrics

Administrator

new version will have quota setup script to do this automatically for you.