How to solve quota problems in Directadmin

By | July 23, 2013

At our company we are running about 2000 Directadmin servers and we come across quota problems very often. There are some different reasons for this quota problems which all require a different solution. In this blogpost I want to introduce you to the different types of quota problems which can occur at Directadmin servers. After that, I will show you how you can solve these problems.

One user got a quota problem

If you have one user at your server which quota looks incorrect, there can be several issues.

First, there can be other files at the same user ID on your sytem causing this error. They will be added to the usage of the specific user which can lead to a “incorrect” quota.

You can find the files with the find command:

[[email protected]]# id username
uid=510(username) gid=510(username) groups=510(username)
[[email protected]]# find / -uid 510 | more

Once you find the files that shouldn’t belong to the new user, then change the owner of the file (for example to root) so that they no longer belong to the user.

After these changes, you can check the quota for the user again:

quota -v username

If this output is correct, you are good to go. Now update the quota within Directadmin:

echo "action=tally&value=username&type=user" >> data/task.queue

When this value is still bigger then you expected, you can check everything that Directadmin counts to the user quota with:

cd /usr/local/directadmin
echo "action=tally&value=username&type=user" >> data/task.queue
./dataskq d800

All (or most of) my users got a quota problem

If most or all your users got a quota problem, there is probably an issue with your system quota. The solution to this depends on your server itself.

First, check which partitions are used:

df -h

If you have a /home partition, then your quota_partition value will be /home. If you have no /home partition, then your quota partition will likely be /. In some cases, you might have a sybolic link from /home to /usr/home, in which case your quota_partition will be /usr.

Check your directadmin.conf to see if it is correct and matches your quota partitions:

grep -i 'quota_partition' /usr/local/directadmin/conf/directadmin.conf

If this is not the case, change this value in the directadmin.conf.

After this, you can run repquota to check the quota for a specific partition. Run it at the correct quota partition:

/usr/sbin/repquota /home

If the “used” column is not showing anything, or users are not in the list, then you’ll need to run the quotacheck program. The command for that depends on your operating system.

Redhat / CentOS / Fedora / Scientific Linux:

/sbin/quotaoff -a; /sbin/quotacheck -avugm; /sbin/quotaon -a;

FreeBSD:

/usr/sbin/quotaoff -a; /sbin/quotacheck -avug; /usr/sbin/quotaon -a;

Most of the time, this command will run correctly. If this is not the case and you get an error running this command, the user and/or group quota is probably not enabled at your server. You can check this in the fstab:

cat /etc/fstab

Now if there is no user quota or group quota enabled at the specific partition, you have to edit your fstab.

vi /etc/fstab

The specific entry you have to add depends on the OS.

Redhat / CentOS / Fedora / Scientific Linux:

usrquota,grpquota

FreeBSD:

userquota,groupquota

The result will be something like:

/dev/sda1             /               ext4 rw,usrquota,grpquota 1       1

Once the repquota program is returning a normal value, then you can run the tally to get the correct usage to show up in DirectAdmin:
When the repquota command outputs the correct value, you can run a tally on the system to update the quotes within Directadmin:

echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue

Leave a Reply

Your email address will not be published. Required fields are marked *