Setting disk quotas

From ISPWiki
Jump to: navigation, search

Enabling disk quotas in ISPmanager

To enable disk quotas in ISPmanager, browse to the "Software" module, and set up or activate "Disk quotas".

  • If you run Linux, the quota packet will be installed
  • If you run FreeBSD, the quotas must be enabled in the kernel (in GENERIC has it enabled by default)

ISPmanager will:

  • activate required options in /etc/fstab
  • re-mount /
  • start quotacheck on /
  • enable quotaon on /

Once you are done, users will see the "Disk" column in the interface menu, and you will be able to set disk limit per each user (ISPmanager calculates quota every 2 minutes (in versions earlier than 5.15.0 - every 10 minutes)

Enabling disk quotas manually

If ISPmanager failed to enable disk quotas, complete the following steps:

Check mounting options

Find the directory that was selected for user files:

/usr/local/mgr5/sbin/mgrctl -m ispmgr pathlist |grep DefaultHomeDir ||  /usr/local/mgr5/sbin/mgrctl -m ispmgrnode pathlist |grep DefaultHomeDir

Check where it is located:

df  <found_directory> |tail -1 | awk '{print $6}'

Execute the command

mount | grep 'on <found_partition> '

It will show mounting options for file system's root. They must include

grpquota,usrquota

If quotas are not enabled, add the options into /etc/fstab like that:

UUID=<тут UUID> <found_partition>   ext4    defaults,grpquota,usrquota   1 1

Re-mount the found partition with the command

mount -o remount <found_partition>


Creating files for quota

Run

quotacheck -gum /

Enabling quotas

Execute the command

quotaon -guv /

Disk quotas for xfs on CentOS 7

The xfs file system is used by default On CentOS 7. Quotas are enabled during setup. Reboot the server after the disk quotas packet is installed in ISPmanager.

Manual configuration of disk quotas for xfs on CentOS 7

1. Add quota options into GRUB_CMDLINE_LINUX of the /etc/default/grub file

   rootflags=usrquota,grpquota

2. Make a backup copy:

   cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.back 

3. Generate a new config:

   grub2-mkconfig -o /boot/grub2/grub.cfg 

Restart the server.

The root directory will be mounted with required options:

   mount | grep ' / '
   /dev/vda3 on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)

Now you can enable disk quotas in ISPmanager.

FAQ

Disk space usage is not displayed in the control panel

You can see the following error in logs:

Dec  5 16:09:02 [3228:38] proc EXTINFO Run '/bin/sh -c quotasync\ -g\ /' pid 3658
Dec  5 16:09:02 [3228:38] proc EXTINFO Process 3658 finished with status 1

This is a typical behavior for the reiserfs file system ( OpenVZ).

To resolve this issue, add the DisableQuotasync option into the ispmgr.conf configuration file (or ispmgrnode.conf if you are using ISPmanager Business)

Option DisableQuotasync - do not call the quotasync command to get information on disk quotas.

After adding the option into the configuration file, execute killall core to restart the panel

Disk space usage in ISPmanager is different from the value shown by the du command

  • In the "Users" module you can see the disk space usage: 880/1000 MB

But du -sh on the user directory shows 1,6 GB

This means that the user directory contains the files which group does not correspond to the user group.

Execute the command to find the files

find /var/www/user/ -not -group user
  • if du shows a less value than the panel, this means that outside the user home directory there are files that belong to the user group.

Execute the command to find the files

find / -path /var/www/user/  -group user