Configuring Quotas on a file server

ubuntuIf you are using your Ubuntu server as a file server, a very good practice is to implement quotas.  This will limit the amount of files that can be created by your groups and users, allowing you to protect your file systems from being over filled.


Start by installing quota.

$ sudo apt-get install quota



Now you will need to edit the fstab file, to include partitions that should have quotas enabled.

$ sudo vi /etc/fstab

Replace the default option on devices by changing them to something like this...

UUID=asioyu-wrte543-wer-123541234 /home ext4 errors=remount-ro,usrquota,grpquota 1 2

 To apply the quota, remount the drive...

$ sudo mount -o remount /mnt/storage1

To create a new quota file run the following...

$ sudo quotacheck -cum /mnt/storage1

The options operate as follows...

  • c = Create a new file.
  • u = A user index is to be created.  Use g for groups.
  • m = A read-only mount of the file system is not necessary (note that this can cause a slight mismatch of file sizes).

Now we can turn the quota feature on, and start editing quotas for individual users.

$ sudo quotaon /mnt/storage1


Editing Quotas

You can now edit quotas for individual users or groups.  We will start by editing a quota for a group.

$ sudo edquota -g <groupname>

Here you can simply enter values against the device that has quotas enabled on it.  Here is an example...

xDisk quotas for group <groupname> (gid 1001):
  Filesystem   blocks   soft   hard   inodes   soft   hard
  /dev/md0   72   0   0   19   0   0

We will make a soft and hard setting for blocks (eg. 900 GB hard, and 850 GB soft).  Soft limits can be exceeded for a limited period, however hard limits can never be exceeded.

xDisk quotas for group <groupname> (gid 1001):
  Filesystem   blocks   soft   hard   inodes   soft   hard
  /dev/md0   72  850000000 900000000   19   0   0

Once you've made your changes, press Ctrl-O, to write your changes, and Ctrl-X to exit the editor.

Now you can perform the same task for individual users.

$ sudo edquota <username>


Thanks for visiting,