Quota Management in cPanel

Last modified: August 1, 2020
You are here:
Estimated reading time: 4 min

There can be many users present in a Linux system. A system administrator can limit the amount of disk space that may be consumed by users by implementing disk quota over them. This will restrict the users from over consuming the disk space. It is possible to enable quotas for individual users and user groups. It will help to manage the space allocated for user-specific files (for example, email) separately from the total space allocated to the projects a user works on, when the projects are given their own group. Implementing disk quota will restrict the number of disk blocks consumed, but it is not the only intention of setting quotas. They also help to control the number of inodes used. Inode is a special data structure that contain information about files in a Unix file system. This control is very essential as inode is also a resource that can be over consumed by the users. By limiting the files, limiting inodes is also implemented.

 

Installing Quota RPM

To implement Disk Quota, quota RPM must be installed on the server. Let’s see how to install quota RPM. Installing quota RPM includes the following steps.

 

Finding appropriate RPM package

It’s important that you locate the right RPM to install. When you search for an RPM package, many results will be returned. You can find the RPM packages built by Red Hat at these locations.

The Red Hat Enterprise Linux CD-ROMs

The Red Hat Errata Page available at http://www.redhat.com/apps/support/errata/

The RPM files will be having an extension .rpm. Usually the structure of an RPM file name is as follows. The filename, version, release and architecture. Eg: foo-1.0-1.i386.rpm

To install the RPM package, follow the below steps.

1) SSH to the server as root user.

2) Open the terminal.

3) type the command ‘rpm -Uvh foo-1.0-1.i386.rpm’ to install the package.

# rpm -Uvh foo-1.0-1.i386.rpm

You will get the following output if the installation is successful.

Preparing…  ########################################### [100%]

1:foo         ########################################### [100%]

Quota refers to disk quota allocated to various accounts. It refers to a limit on how much data can be contained in an account’s directory. You can set, modify quota on the accounts with the cPanel interface. The quota is usually defined in Megabytes (MB).

 

Enable quota in cPanel

We can enable quota in the cPanel/WHM interface. You need to go to Home >> Server Configuration >> Initial Quota Setup. However, you need to perform some additional steps to finish the process. After the initial setup done, you can click on the button that present in the top right corner. You need to click on this button so that the system will be rebooted. When the system is up after a successful reboot, the quota scan runs in the background to complete the process. You can do this with the help of Command Line Interface also. To achieve this, you need to run the script /scripts/fixquotas and then reboot the server. You can reboot the server by running the command reboot. Please keep in mind that, after each CloudLinux 7 update, you must run the /scripts/fixquotas script and reboot the server because CloudLinux 7 may break the quotas.

 

Checking Whether Quota is Enabled or not

You can check whether the quota is enabled or not with the help of the Command Line. To perform this checking, you need to follow the steps given below.

1) SSH into server as root user.

2) Run the command mount. This command will display the information for all mounted file systems.

3) Check for the variable usrquota in the result.

4) Identify the filesystems where quota enabled and not enabled with the help of usrquota variable. All the entries that contain this variable are quota enabled. For example:

root@host [~]# mount

/dev/mapper/VolGroup001-LogVol001 on / type ext3 (rw,usrquota)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

 

Checking fstab contents

There is a file called fstab which stands for the file system table. This file maps devices to their respective mount points in the system. You can identify file systems with quota enabled from this file also. If there is the variable usrquota in any of the entries, then it means that the system is quota enabled. An example of fstab entries is given below.

/dev/sda5        /backup                         ext3    defaults,noexec          0 0

LABEL=/boot      /boot                          ext3    defaults,usrquota        1 2

tmpfs            /dev/shm                          tmpfs               defaults            0 0

devpts           /dev/pts                           devpts gid=5,mode=620         0 0

 

Configuring Disk Quotas

We are going to see how to enable quota, remount file system, create database files, and assign quota policies in the rest of this article.

1) Enabling Quota

SSh into the server as root user. Open the /etc/fstab file with the help of a file editor. Add the usrquotq and/or grpquota to the desired file systems as shown below.

/dev/VlGroup00/LVol00 /         ext3    defaults        1 1

LABEL=/boot              /boot     ext3    defaults        1 2

none                     /dev/pts  devpts  gid=5,mode=620  0 0

none                     /dev/shm  tmpfs   defaults        0 0

none                     /proc     proc    defaults        0 0

none                     /sys      sysfs   defaults        0 0

/dev/VlGroup00/LVol02 /home     ext3    defaults,usrquota,grpquota  1 2

/dev/VlGroup00/LVol01 swap      swap    defaults        0 0 . . .

 

2) Remount File System

After you added the usrquota or grpquota, you need to remount each file system whose fstab entry has been modified. You can use the following methods if the particular file system is not used by any process.

1) Run the umount command followed by mount command

2) Run mount -o remount <file-system> command, <file-system> is the file system in question.

 

3) Create Database Files

After a quota enabled file system is remounted, the next step is to run the quotacheck command. This command will examine quota-enabled file system and then a table will be built with the details of current disk usage per file system.

# quotacheck -cug /home

The -c option specifies that the quota files should be created for each file system with quotas enabled. The -u option specifies user quotas where -g option specifies to check for group quotas.

 

4) Assigning Quotas per User

Now you can assign the disk quota. This can be done with the help of edquota command.

# edquota username

5) Assigning Quotas per Group

We can assign the quotas per group also with the edquota command.

# edquota -g group_name

 

If you need any further assistance please contact our support department.

Was this article helpful?
Dislike 0
Views: 6