How to Configure Disk Quotas

A week ago (02-Mar-2014), One of our web hosting support client ask me to Format, Partition and to Mount the new drive to his cloud server, while doing the process, i forget to enable quota. After few days, he asked me about all the cpanel accounts shows 0MB disk usage. so, now I’m preparing this article based on these issues only. All the articles, which i’m preparing is a PRACTICAL ONE.

1) How to check quota is enabled or not ?

Use the below command to check whether the quota is enabled or not on your new mounted partition.

[email protected] [~]# repquota /home1
repquota: Mountpoint (or device) /home1 not found or has no quota enabled.
repquota: Not all specified mountpoints are using quota.

The output clearly shows the quota is not enabled on server.

2) Enabling the quota ?

Just open the /etc/fstab file on your terminal and add the user quota to your new mounted drive. Make sure your kernel supported quota because our server supported journaled quota and add it according that.

[email protected] [~]# cat /etc/fstab

# /etc/fstab
# Created by anaconda on Sat Oct 20 05:18:25 2012
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
UUID=02b56de1-a737-48ec-945f-c6f6301541aa       /       ext3    usrjquota=quota.user,jqfmt=vfsv0        1       1
UUID=b18386ae-633c-430c-85be-76132db5dd5a /boot                   ext2   defaults        1 2
UUID=d6059278-6690-4877-8660-c70d05af30fe swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults,noexec,nosuid        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/xvdc1              /home1                  ext3    defaults,usrjquota      1 2

I have added usrjquota on our newly added drive.

3) Remounting the File Systems ?

Use the below command to remount the drive to enable the added quota.

[email protected] [~]# mount -o remount /home1

4) Creating the User Quota Database File ?

Use the below command to create User Quota Database File to /home1 directory.

[email protected] [/home1]# touch aquota.user

And file permission should be 600.

[email protected] [/home1]# chmod 600 aquota.user

By default the owner & group permission is root. Anyhow modify it once again.

[email protected] [/home1]# chown root:root aquota.user

5) Enabling the quota to all users ?

Use the below command to enable the User Quota to /home1 directory users.

[email protected] [/home1]# quotacheck -auvm
quotacheck: Scanning /dev/xvdc1 [/home1] 
quotacheck: Checked 60202 directories and 495168 files

The major common options for quotacheck command.

a : Check all quota-enabled, locally-mounted file systems.
v : Display verbose status information as the quota check proceeds.
u : Check user disk quota information.

6) Checking disk usage on users ?

Use the below command to check whether user disk usage is shows or not at /home1 directory users.

[email protected] [~]# repquota /home1
*** Report for user quotas on device /dev/xvdc1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
root      --  452428       0       0            205     0     0
jpserver  --     720       0       0             76     0     0
jpssindi  --    9576       0       0            620     0     0
abodeofj  --   22488       0       0           1598     0     0
accesser  --    5452       0       0            373     0     0
adhavaca  --    2528       0       0            206     0     0
adhavacs  --    1732       0       0            201     0     0
shivanig  --  476472       0       0           3800     0     0
syosisgl  --  834604       0       0           2675     0     0

Now, Its showing the used disk usage to all the users.

7) Run the fixquota to fix the cpanel quota issue ?

After enabling the diskquota, run the below command to fix user quota on cpanel server.

[email protected] [~]# /scripts/fixquotas
Installing Default Quota Databases...../home1/aquota.user..../home1/quota.user.....Done
Quota Mode: Linux
checking out /backup
checking out /backup
Warning : Your system does not have a separate filesystem for backups. This may cause performance degradation during the backup process.
UUID=51571c83-d99b-49bc-a891-08d8a5d7eaa3 (already configured quotas = 1).
UUID=b90ef47e-d438-4a0c-aac0-1d1de719600d (already configured quotas = 0).
/dev/xvdc1 (already configured quotas = 1).
Updating Quota Files......
	quotacheck: Scanning /dev/xvda2 [/]

	quotacheck: Cannot stat old user quota file /home1/aquota.user: No such file or directory. Usage will not be substracted.
	quotacheck: Cannot stat old user quota file /home1/aquota.user: No such file or directory. Usage will not be substracted.
	quotacheck: Checked 60202 directories and 495167 files
	quotacheck: Old file not found.
	quotacheck: Old file not found.
Quotas have been enabled and updated.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...