Filesystem and quotas
By default, disk quotas displayed in the DirectAdmin panel rely on system quotas, so they should be working from the OS level.
My System Quota values are too high or too low
When viewing the "System Quota" numbers from your bandwidth breakdown page, you may determine that the numbers don't appear to be correct.
System Quotas are too low
If your system quotas are too low, meaning that the sum of the domain files and email files are more than the system quotas or even 0.0, then it would imply that the quotas are not correctly set up or are not working properly.
In that case, you'd go through the debug guide here.
If you do require technical support, please include the output from all of the commands at the bottom of the guide in your support request.
System Quotas are too high
If you can't seem to figure out how the system quotas are adding up, meaning you've counted all files under /home/user
, and the sum is just not adding up to be that high, that's when you'd need to search your system to find out where those files are. In that case, you'd use the find command to search the entire partition holding the User data to show you where all User files exist. Anything outside of /home/user
is probably what's causing the confusion.
Use this guide.
Disk Usage is showing 0.00 or is too low
- First of all, let's determine the partition where files should be counted:
df -h
If you have a /home
partition, then your quota_partition value will be /home
.
If you have no /home
partition, then most likely your quota partition will be /
.
In some cases, you might have a symbolic link: /home -> /usr/home
, in which case your quota_partition will be /usr
.
Set the partition value here, as needed:
- DirectAdmin relies on the system quotas to return a value for how much space is being used. Check the quotas per partition with:
repquota "/home"
- If you see no output, it means quotas are not enabled on the OS level. Check what partition is actually in use on /home:
cat /proc/mounts | grep " /home "
If you see ext3/ext4, then use this guide:
How to enable quota support on ext4
If you see xfs, then use this guide:
How to enable quota support on xfs
- If you see a table after checking the quota on /home (step 2), however, the used column contains all zero values, then quota should be re-checked.
Run command:
quotaoff -a; quotacheck -avugm; quotaon -a
- 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:
echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue
This task.queue command will get picked up by the dataskq binary. It calls the repquota command and dumps it into /home/tmp/quota-dump
.
Check /var/log/directadmin/errortaskq.log
for any errors resulting from this.
Running the tally manually for a User can also help with debugging these issues.
Information for a Support Request about quota issues
If you're completely confused and will be contacting a support department about the issue, run these commands and paste the full output from them:
cat /etc/fstab
df -h
cat /proc/mounts
/usr/local/directadmin/directadmin config | grep quota_partition
repquota `/usr/local/directadmin/directadmin config | grep quota_partition= | cut -d= -f2`
ls -lad /home/tmp
ls -la /home/tmp
How to enable quota support on EXT4
Assuming quotas are not configured in the OS while you are using an ext4 filesystem, the following command will return no output:
repquota -a
If so, quota support must be enabled.
Edit the
/etc/fstab
file, and on Linux, add the usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv1 next to the partition that should have quotas enabled.An example
/etc/fstab
from CentOS 7 is:/dev/mapper/vg_s4-lv_home /home ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv1 1 2
Remount the modified partition where quota was enabled with:
mount -o remount /home
Recreate quota database files
quotaoff -ug /home quotacheck -ugcm -F vfsv1 /home quotaon -ug /home
Rewrite quotas
da taskq --run "action=rewrite&value=quota"
How to enable EXT4 quota feature
The quota feature causes quota database files to be hidden so they would not get corrupted by user space programs.
To enable quota feature on new filesystems use:
mkfs.ext4 -O quota /dev/mapper/vg_s4-lv_home
To enable quota feature on existing sysems, filesystem meeds to be brought offline and unmounted
- Make sure no on will use the filesystem to be able to unmount it with:
umount /home
- Enable quota feature using
tune2fs
tune2fs -O quota /dev/mapper/vg_s4-lv_home
- Mount filesystem
mount /home
- Rewrite quotas
da taskq --run "action=rewrite&value=quota"
Enabling quota feature on /
will require booting into rescue media and running tune2fs
tune2fs -O quota /dev/mapper/vg_s4-lv_home
How to enable quota support on XFS
The xfs filesystem is different than the previous ext4. If you need quotas set up on the /home
partition, then this guide should be very similar to the standard quota setup guide. However, if you need quotas set up on /
, where /
uses use an XFS partition (/home
is only a directory under /
), then extra steps are required.
We replace the grpquota with pquota (project quotas), which will allow DA to set up directory quotas, for things like enforcement of per-domain disk quotas.
To confirm what setup you have, run the df command, e.g.,
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 2.3G 12G 17% /
devtmpfs 915M 0 915M 0% /dev
tmpfs 921M 24K 921M 1% /dev/shm
tmpfs 921M 8.5M 912M 1% /run
tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/sda1 497M 125M 372M 26% /boot
As you can see, /home
is not a partition, so it falls under the /
partition, and we must ensure that quotas are functional on the /
partition.
- Next confirm that / is actually using the XFS filesystem:
# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
If you see the noquota option, then you need to go to step 1 below.
If you do not see 'noquota', then you should be able to follow the standard quota setup guide and instead, add uquota,pquota to the /etc/fstab
after the default option.
If you see "noquota" in the xfs mount options for the / partition
Because "noquota" is a default kernel mounting option, we must change it in the kernel boot options. Edit the file
/etc/default/grub
.Find the line with the variable "GRUB_CMDLINE_LINUX", that might look like this (it may not look exactly the same, so don't worry):
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet"
- We're going to put a "rootflags=" variable at the end of the line and add uquota,pquota as the values. It might look something like this:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=uquota,pquota"
- Now, based on that setup, we'll create a backup, and then create a new grub.cfg file:
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
grub2-mkconfig -o /boot/grub2/grub.cfg
The path on some OSs has been changed to:
/boot/efi/EFI/centos/grub.cfg
- Lastly, we must reboot the box in order for the kernel to see these new options:
reboot
- We keep our fingers crossed that the box comes back, and login again. Go back to step (0) to check the mounting options to ensure that "noquota" is gone, e.g.,
# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)
Once it's gone, we want to see usrquota,prjquota
(or uquota,pquota
, they're the same thing).
If you don't see them, then add them to the /
partition with the standard quota setup guide.
- If there are already Users created in DA, then you'll also want to reset their quota limits to ensure their upper disk usage limits are enforced:
echo "action=rewrite&value=quota" >> /usr/local/directadmin/data/task.queue
AlmaLinux 9.X the quota for XFS should be enabled using these commands:
grubby --update-kernel=ALL --args="rootflags=uquota,pquota"
reboot
If you also need CGroup PSI (pressure) enabled in Kernel, the command will be changed to:
grubby --update-kernel=ALL --args="rootflags=uquota,pquota psi=1"
reboot
CloudLinux on DigitalOcean
Note that /etc/default/grub
may be ignored for these setups.
The file /etc/rc.d/init.d/kexec
applies instead (untested):
https://docs.cloudlinux.com/index.html?digitalocean.html
You'll add the rootflags=uquota,pquota
to the end of the line that starts with:
kexec -l
System quotas reporting too high for user
If you have a user, , and you find that he is using more system quotas than you think he should be, there could be other files on your system causing this error.
When a tar.gz file is extracted as root, the file ownership of its contents will generally stay the same as they were on the system that compressed the tar.gz file. This means that the user id number of the files will be extracted along with the files. When you create your new user, his new user id might match the user id of the files that were extracted, so the system quotas will assume that the new user owns these other files. This will add large amounts of disk usage to the new user.
To resolve the problem, you'll have to find these other files and chown them to another user (or root) so that the new user doesn't absorb the "cost" of their space.
- Find the UID of problematic user with:
id "fred"
Let's say example output was:
uid=510("fred") gid=510("fred") groups=510("fred")
Now use the UID from above and find all of the files owned by that user:
find / -uid 510 | less
It may take some time to process. Press space to scroll.
Once you find the directory and files that shouldn't belong to the new user, then cd to that directory and do the following:
chown root:root /path/to/files
so that they no longer belong to the user.
To see the current disk usage for that user, type:
quota -v "fred"
If it isn't correct with the new settings, run through steps 4 and 5 from the [Disk usage is showing 0.00.html#disk-usage-is-showing-000-or-is-too-low) guide.
I have more than one home partition, how to use old and new partitions?
If you have more than one home partition, then you have to define a 'create_user_home_override' option in the directadmin.conf
file, as well 'home_override_list'.
More info here.
How to move user to a new partition
DirectAdmin does support the ability to create/restore Users on a desired partition (see above).
There are plausibly cases where you'd want to move an existing User from one partition to another partition, so let's assume:
Username:
Old home:
New home:
Steps to move fred from /home to /home2 would be:
- Copy the data to the new drive:
cd "/home2"
cp -Rp "/home/fred" "./fred"
- Once you have 2 copies of the data (one in each partition), and the permissions match, change the system to point to the new path with:
usermod -d "/home2/fred" "fred"
Note, we don't use the -m option (which would have moved the data, allowing us to skip step #1, to allow us time to change other configs without breaking the live website).
- Update the configs to point to the new path by issuing a rewrite:
da build rewrite_confs
echo "action=rewrite&value=email_passwd&user=fred" >> /usr/local/directadmin/data/task.queue
- CloudLinux: If you're running in CageFS, you'll need to re-initiate CageFS:
cagefsctl --force-update
cagefsctl --remount-all
My file system does not support quotas. I'd like a manual count of User files.
The /usr/sbin/repquota
efficiently reports disk usage for Users and keeps track of that usage in real-time through the kernel as files are written to disk. Sometimes, quotas are not an option, such as with NAS/NFS setups.
One option is to create your own repquota script for DA to call, instead of /usr/sbin/repquota
.
- Create the new script
/usr/sbin/repquota2
with content:
#!/bin/sh
calculate_usage() {
DAUSERS=`cat /etc/virtual/domainowners | cut -d ":" -f 2 | sed 's/ //g' | sort -u`
echo " Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------"
for u in $DAUSERS; do
DIR=`getent passwd $u | cut -d: -f6`
if [ -d $DIR ]; then
CALC=`du -sk $DIR | cut -f1`
echo "$u -- $CALC 0 0 0 0 0 "
fi
done
}
calculate_usage
exit 0;
- Make it executable:
chmod 755 /usr/sbin/repquota2
- Tell DA to use it:
da config-set repquota /usr/sbin/repquota2
systemctl restart directadmin
Script credit: https://cyberfusion.nl/
What is an inode?
DirectAdmin can now track and limit inodes:
http://www.directadmin.com/features.php?id=1445
What is an inode?
Each file and folder under a User account is an inode. Having a limit on inodes in DirectAdmin prevents a runaway User from having too many of them.
Just like large files, many small files can also tax the filesystem, as each file/folder needs to be stored somewhere.
What is a good inode limit value?
The clean WordPress has approximately 1,200 files/directories, and a default Magento install has over 10,000, so you would need to consider at least 30,000 to be an inode limit for a minimal package for your customers.
The number of email messages could be really high, so consider increasing the inode limit to 50,000 for packages with more email activity.
To count real usage for users on a live server, execute:
repquota -a
And review the "File limits -> Used" column.
How to move MySQL to another location if /var is full
If you have a /var
partition, and if that partition is too small, it may fill up quickly. If you want to move the data which is stored in "/var" to another partition, run the following:
cd /var
du | sort -n
This will give you a full readout of all the directories that are using the most space. The directory using the most disk space will appear at the bottom of the list.
One common culprit is mysql ( /var/lib/mysql
on Redhat). To move that path to another partition, run the following:
- Prepare the target location:
cd /home
mkdir mysql
chown mysql:mysql mysql
cd mysql
- Shut down mysql and copy its content:
perl -pi -e 's/mysqld=ON/mysqld=OFF/' /usr/local/directadmin/data/admin/services.status
systemctl stop mysqld
cp -Rp /var/lib/mysql/* .
cd /var/lib
mv mysql mysql_old
ln -s /home/mysql ./mysql
- Restore mysql and the service status checking option:
systemctl start mysqld
perl -pi -e 's/mysqld=OFF/mysqld=ON/' /usr/local/directadmin/data/admin/services.status
- Once satisfied that mysqld is running and functioning correctly, remove the old data:
rm -rf mysql_old
You can also specify a new socket path in the file /usr/local/directadmin/conf/mysql.conf
if you want, but it shouldn't be required if you've correctly created the symbolic link with the above 'ln -s' command.
Note1: If you run into the error:
[Warning] Can't create test file /home/mysql/server.lower-test
after you've moved it to /home
, check the /etc/systemd/system/mariadb.service
or mysqld.service
file for:
ProtectHome=true
and change this to false.
Note2: on CloudLinux servers with CageFS, you would also need to execute:
cagefsctl --force-update
cagefsctl --remount-all
How to check if I am running any RAID ?
You can see your available disk space in DirectAdmin with:
df -h
But say you wanted to confirm if the partitions are single disk or multiple disks in** Raid 1** or** Raid 0**. In that case, you can use the following commands to look deeper into the file system:
lsblk
cat /proc/mdstat
lshw -class disk
lspci | grep -i raid
How to activate quota support for MySQL and E-Mail
MySQL has no native quota support, so there is no way to limit the size of the database. However, it is counted in the user's used disk space, and the user would get alert when he is near the limit.
How to configure the system to allow 20Gb for web quota and 40Gb for email quota?
E-Mail also has no native quota support. Quotas are per-user, especially on EXT filesystems. XFS quota does have per-directory support, so custom scripts could be created to utilize that for email quota limitations. If you want this, please create/vote on a feature request at https://feedback.directadmin.com/.
As of now, the best option is to limit the maximum size per mailbox, which uses Dovecot's quota functionality.
How to enable quota checks on a 2nd /home partition
If you want DirectAdmin to count quotas properly on any partition other than default /home partition, the ext_quota_partitions can be used.
This feature will allow multiple drives to work with quotas correctly, e.g.,
/home
/home2
/home3
This can be a comma separated list for multiple partitions (no spaces), e.g.,
da config-set ext_quota_partitions /home2,/home3,/home4
systemctl restart directadmin
Do not use the value for quota_partition in ext_quota_partitions or else you'll have the main partition counted twice.
**IMPORTANT if you are to add /var
to this list, and /var
is separate from your /home
partition, you will need to tell DA not to manually count the /var email usage. You must do this by setting:
count_email_usage=2
in your directadmin.conf.
This feature is designed for extra home partitions more so than /var
partitions, but should work anyway with /var
.