How to Configure User, Group, and Project Disk Quotas on Ubuntu Server Using Quota and Xfs_quota

How to Configure User, Group, and Project Disk Quotas on Ubuntu Server Using Quota and Xfs_quota is an essential skill for any system administrator managing shared hosting, multi-user environments, or web servers. Without disk quotas, a single user or process can fill up your entire filesystem. That brings everything to a halt. This tutorial walks you through setting hard and soft limits for users, groups, and projects on Ubuntu Server. You’ll work with both the quota package for ext4 filesystems and xfs_quota for XFS filesystems. By the end, you’ll have a fully working quota system that keeps your server storage under control.

Prerequisites and Requirements for Configuring Disk Quotas

Before you start configuring user, group, and project disk quotas on your Ubuntu server, make sure you have the following in place.

What you need:

  • Ubuntu Server 20.04 or 22.04 (fresh or existing installation)
  • Root or sudo access to the server
  • A mounted filesystem , either ext4 or XFS
  • Basic familiarity with Linux terminal commands
  • SSH access to your server (if managing remotely)

Estimated time: 30–45 minutes

You should know how to edit files using nano or vim. You should also understand basic Linux filesystem concepts like mount points and /etc/fstab. If you’re running a WordPress hosting server or a multi-user VPS, disk quotas are especially valuable. They prevent one account from hogging all available storage. Check the official Ubuntu Server documentation for additional context on filesystem management.

How to Configure User, Group, and Project Disk Quotas Step by Step

Related tutorial: How to Manage Application Configuration in Kubernetes Using Configmaps and Secrets

Follow these steps carefully. The process differs slightly depending on whether you’re using ext4 or XFS. Both methods are covered below.

Step 1: Install the quota package

First, update your package list and install the required tools.

sudo apt update
sudo apt install quota -y

For XFS filesystems, the tools are already included with xfsprogs. Install that package too.

sudo apt install xfsprogs -y

Step 2: Enable quota options in /etc/fstab

Open your /etc/fstab file in a text editor.

sudo nano /etc/fstab

Find the line for your target filesystem. For ext4, add usrquota,grpquota to the options field. It should look like this:

UUID=your-uuid  /  ext4  defaults,usrquota,grpquota  0  1

For XFS, use uquota,gquota,pquota instead:

UUID=your-uuid  /data  xfs  defaults,uquota,gquota,pquota  0  2

Save and close the file.

Step 3: Remount the filesystem

Apply the new mount options without rebooting.

sudo mount -o remount /

For XFS partitions, replace / with your actual mount point, such as /data.

Step 4: Create quota database files (ext4 only)

For ext4 filesystems, you need to generate the quota database files.

sudo quotacheck -ugm /

This scans the filesystem and creates aquota.user and aquota.group files in the root directory. Skip this step if you’re using XFS , it handles quota tracking natively.

Step 5: Enable quotas

Turn on quota enforcement for ext4.

sudo quotaon -v /

For XFS, quotas activate automatically at mount time. You can verify with:

sudo xfs_quota -x -c 'state' /data

Step 6: Set user and group quotas

For ext4, use the edquota command to set limits for a specific user.

sudo edquota -u username

This opens a text editor showing soft and hard limits for blocks and inodes. Set your values and save. To set group quotas, use:

sudo edquota -g groupname

For XFS, set limits directly from the command line.

sudo xfs_quota -x -c 'limit bsoft=1g bhard=2g username' /data

This gives the user a soft limit of 1GB and a hard limit of 2GB on the /data partition.

Step 7: Configure project quotas on XFS

Project quotas let you limit storage for a specific directory, regardless of which user writes to it. This is useful for web hosting directories or shared folders.

First, define the project in /etc/projects and /etc/projid.

echo "1:/var/www/mysite" | sudo tee -a /etc/projects
echo "mysite:1" | sudo tee -a /etc/projid

Then initialize and set the project quota.

sudo xfs_quota -x -c 'project -s mysite' /data
sudo xfs_quota -x -c 'limit -p bsoft=5g bhard=6g mysite' /data

Step 8: Verify your quota settings

Check current usage and limits for all users on ext4.

sudo repquota -a

For XFS, run:

sudo xfs_quota -x -c 'report -h' /data

The -h flag displays sizes in a human-readable format. You should see your configured limits listed for each user, group, or project. For more detail on XFS quota options, refer to the xfs_quota man page on Linux.org.

Troubleshooting Common Quota Configuration Issues

Even with careful setup, things can go wrong. Here are the most common problems and how to fix them.

Quotas not enforcing after reboot
This happens when the quotaon command doesn’t run at startup. Add it to your /etc/rc.local file or create a systemd service to run it automatically.

quotacheck fails with “filesystem is busy”
You can’t run quotacheck on a live root filesystem in write mode. Boot into recovery mode or use a live USB to run the check on an unmounted partition.

XFS quota state shows “off”
Double-check your /etc/fstab entry. Make sure you used uquota, gquota, and pquota , not the ext4 options. Remount the filesystem after fixing the entry.

edquota opens but limits don’t save
Make sure you’re editing the correct user. Also confirm that aquota.user exists in the filesystem root. Run quotacheck again if the file is missing.

Project quota not applying to a directory
Run sudo xfs_quota -x -c 'project -s mysite' /data again. The project must be initialized before limits take effect. Verify the project ID matches in both /etc/projects and /etc/projid.

Conclusion

You now know how to configure user, group, and project disk quotas on Ubuntu Server using both quota for ext4 and xfs_quota for XFS filesystems. This setup gives you precise control over how much storage each user, group, or directory can consume. It’s a critical step for anyone running shared hosting, development environments, or multi-tenant servers. From here, consider automating quota reports with cron jobs. You can also explore integrating quota alerts with monitoring tools like Nagios or Zabbix. Keeping storage usage in check prevents downtime and protects all users on your system.

Similar Posts