Published on: March 21, 2017 by Anitta Jose
Disk quotas can be used to limit the amount of disk space or the number of files allocated to a user or members of a group. This prevents one user or group of users from consuming all of the available disk space. It is very useful in large multi-user environment.
This is a warning level where users are informed that they are nearing their limit. If they are not using grace periods, the soft limit is the maximum amount of available space for each user.
This is the exact limit beyond which a user cannot use. Hard limits are necessary only when the users are using grace periods. If grace periods are enabled, this will be the absolute limit a user can use. Any attempt to consume resources beyond this limit will be denied.
During this period the users are allowed to temporarily violate their quotas by certain amounts if necessary. Linux has provided the default of seven days for both inodes and block usage i.e, a user may exceed the soft limit on either resource for up to seven days. After that, further requests by that user to use files will be denied.
First step is the installation of quota package. Inorder to install quota, Open the terminal and type:
#apt-get install quota quotatool
Now edit the /etc/fstab file. Add usrquota and grpquota options to the mount point, so that the kernel knows it should manage that partition using quotas.
The usrquota and grpquota options are used to enable the user quota and group quota mount option(s) on selected file systems respectively.
Open “fstab” file using your favorite text editor, here I’m using VI editor since it is my favorite:
After adding the usrquota and grpquota options, fstab looks like this:
Then we need to create two files that manage the quota levels in the partition. To create, Open the terminal and type:
#touch /quota.user /quota.group
The file should be owned by root so change its permission as follows:
#chmod 600 /quota.*
To make the setting take affect, the / has to mounted using the new entries in the /etc/fstab. If you are setting up quota on a local machine, the easiest way is rebooting the system.
#shutdown -r now
If we’re unable to reboot the system, an alternative method is to remount the partition as shown below:
#mount -o remount /
After re-booting or re-mounting the file system, the partition will show up in the list of mounted file systems as having quotas.
You can confirm the mount options by executing th command
You can get the same result by checking /etc/mtab file
Instead of checking the /etc/mtab, an alternate method is to check /proc/mounts using any of the text editors as shown below:
When each quota-enabled file system is remounted, the system is now capable of working with disk quotas. However, the file system itself is not yet ready to support quotas.
To do this, we must first run quotacheck.
The options and its use are given below:
a – Check all mounted non-NFS file systems in /etc/mtab
v – Display a message for each file system affected
u – Check for user disk quotas
g – Check for group disk quotas
Now run quotaon command, which announces to the system that disk quotas should be enabled on one or more file systems.
The options used in the above command and its use is shown below:
a – Enable disk quotas on all mounted file systems in /etc/fstab
v – Display a message for each file system where quotas are turned on
u – Manipulate user quotas. This is the default.
g – Manipulate group quotas
To assign quota for particular user, Open the terminal and type:
#edquota -u madhav -f /
Now edit the default quota configuration file which is shown below:
We can confirm the change by entering the user quota command in terminal:
#quota -u madhav
In-order to view the quota summary report, use the following command:
The output of the above command is as follows:
I believe this blog will help you to have a clear view about disk quota 🙂
Category : Linux