How to set disk quotas, which manages space

We may be able to limit disk space as soon as we enable disk quota, notifying the sysadmin before the user takes up too much disk space or the partition becomes full. A quota can only be created for partitions. There are two types of quota, for user and group. If we enable a quota of 100 MB for the / home partition, then every directory in / home or every user on the system, as well as every directory in / home presented to a user, can use a maximum of 100 MB.

Follow these steps to enable disk quota:

Step 1: First of all enable the disk space quota at the partition level by editing the / etc / fstab file. Just edit the line below in the file as shown below:

/dev/sde1 /home ext4 defaults,usrjquota=aquota.user,jqfmt=vfsv0 1 2

Step 2: Remount the / home partition.

# umount /home
# mount /home

or

# mount -o remount /home

Step 3: Scan / home and set quotas on it.

quotacheck -vcug /home

In some cases, you may encounter the error below.

quotacheck: Cannot create new quotafile /home/aquota.user.new: Permission denied

Therefore, to avoid such an error, you must disable SELinux.

After you run the quota check command in the result file “aquota.user” created under the / home partition.

[[email protected] home]# ls -l
total 24
-rw-------. 1 root root 6144 Jan 1 16:52 aquota.user

Step 4: Turn on quotas.

[[email protected] home]# quotaon -v /home
/dev/sde1 [/home]: user quotas turned on

Step 5: To check if there is a quota or not.

[[email protected] foo]# repquota -a
*** Report for user quotas on device /dev/sde1
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20 0 0 3 0 0
foo -- 4 0 0 4 0 0

In order to implement subsequent quotas, follow the procedures below:

Step 1: To change the quota for user “Foo”

[[email protected] ~]#  edquota -u foo

The above command opens an editor window as shown below, where you can change the values ​​to suit your needs.

In the above output:

1st column: Name of the disk or filesystem where quota is turned on
 
2nd column: Describes current blocks is in use.
 
3rd column: Soft limit on the File-system.
 
4th column: Hard limit on the File-system.
 
5th column: shows how many inodes the user is currently using.
 
6th and 7th column: are used to set the soft and hard inode limits for the user on the file system.

Step 2: To change the grace period for a user:

[[email protected] ~]# edquota -t

This also opens a single editor window as shown below:

  enable disk quota

Step 3: To copy the quota settings from one user to another

[[email protected] ~]# edquota -p foo bar

This will apply the Foo settings to the user “Bar”

So this is how we can enable disk quotas in Linux.

How to set disk quotas, which manages space

Sidebar