In order to use disk quotas, you must first enable them. This process involves several steps:
- Modifying /etc/fstab
- Remounting the file system(s)
- Running quotacheck (quotacheck -avug)
- Assigning quotas (edquota)
- Viewing quota usage (repquota
)
Lets look at the detailed steps:
You'll need to add the usrquota option to the /etc/fstab file to let it know that you are enabling user quotas in your file system.
/dev/md0 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
LABEL=/home /home ext3 defaults,usrquota,grpquota 1 2
In this example, we can see that the /home file system has both user and group quotas enabled.
At this point you must remount each file system whose fstab entry has been modified. You may be able to simply umount and then mount the file system(s) by hand, but if the file system is currently in use by any processes, the easiest thing to do is to reboot the system.
Running quotacheck
The quotacheck command examines quota-enabled file systems, building a table of the current disk usage for each one. This table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated (or created, if they do not already exist).
In our example, the quota files (named aquota.group and aquota.user, and residing in /home/) do not yet exist, so running quotacheck will create them. Use this command:
quotacheck -avug
The options used in this example direct quotacheck to:
Check all quota-enabled, locally-mounted file systems (-a)
Display status information as the quota check proceeds (-v)
Check user disk quota information (-u)
Check group disk quota information (-g)
Assigning Quotas
Use the edquota command for this purpose.
# edquota -u
The above command will invoke the vi editor which will allow you to edit a number of fields.
Add the values for soft or hard limits.
and save it.
Getting quota reports - The repquota command lists quota usage limits of all users of the system. Here is an example.
# repquota /home