Installing and configuring Quota on Ubuntu

Writing this article because I had some weird stuff installing en enabling quota on my Ubuntu virtual server:

When using a shared webserver, it is always nice to know which site is using what amount of disk space. This is of course, when each site runs under its own user. Of course you can use df or other tools to find out, but using quota on Ubuntu is the way to go.

First we start by installing quota itself:

After installing this, you need to enable quota (usrquota and grpquota) on the disk which contains the websites.

and change the / partition by adding usrquota,grpquota to the mount option

In my case, on my Xen virtual machine:

Prepare quota to be enabled by creating the quota files:

You will also need to load the quota kernel module, and cause that to be loaded at boot time. You can do that by running:

Then run the quotacheck command:

 the quotacheck parameters above explained:
-a: checks all filesystems
-v: verbose check
-u: Only user quotas listed in /etc/mtab or on the filesystems specified are to be checked.  This is the default action.
-g:  Only group quotas listed in /etc/mtab or on the filesystems specified are to be checked
-m: same as –no-remount and thus forces quotacheck to run while the filesystem is mounted read/write, this way you don’t have to stop any services in order to perform the quotacheck.
-F vfsv0: to specify the quotaformat

This might take a while to complete… So grab a coffee.When the quotacheck has finished, enable quota itself by:

When I did this, I got the following errors: 

Fix this by:

Now, when you check the quota.user and file sizes, this might seem odd:

Wow, huge files! Now, don’t worry about this, as df show up as:

Also as explained on: HP SystemAdmin Forums

This is not a problem. The quota files are sparse files, i.e., they have “holes” of empty space that don’t actually take up any disk space. If you do an ls -ls on the file, the first field is the ACTUAL disk space used in KB. You’ll see that the file really occupies much less disk space than the length field would suggest. This is because the quota files are indexed based on the UID (for quota.user) or GID (for If you have very large UIDs or GIDs (or negative ones, which translate to very very large unsigned integers) it will make the files appear very large.

You can’t change this, short of removing the large UIDs/GIDs and changing ownership of any files belonging to them, and you can’t remove the quota files. But it’s really not a problem. The Tru64 backup utilities, and most third-party ones as well, handle the quota files properly. They either don’t back them up at all, or back up them up as sparse files.

Show all userquota’s with this command:


If you want to enable Hard and Soft Quota’s limits for your users and websites, you can implement this with quotatool. For now this is out of the scope of this article, as I’m not (yet) interested in this. 🙂



1 thought on “Installing and configuring Quota on Ubuntu”

Leave a Reply

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