Quota: Difference between revisions

From Leo's Notes
This page was last edited on 14 June 2020, at 22:17.
Created page with " == Installation == To enable quotas under Linux (RH based), you will need the <code>quota</code> package. yum install quota You will then need to make your mounts support..."
 
mNo edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:


== Installation ==
== Installation ==
To enable quotas under Linux (a RHEL based system), you will need the {{code|quota}} package.


To enable quotas under Linux (RH based), you will need the <code>quota</code> package.
{{highlight|lang=terminal|code=
$ yum install quota
}}


yum install quota
The filesystem must be mounted with the {{code|usrquota}} option for user quotas, {{code|grpquota}} for group quotas, or both.
 
You will then need to make your mounts support quotas using <code>usrquota</code> as a option. For example, in fstab, to make <code>/export</code> have quota support:


You may set this in {{code|/etc/fstab}}. In this example, {{code|/export}} will be made to have user quota support:
{{highlight|lang=text|code=
  /dev/sdb1              /export                ext4    defaults,usrquota 1 2
  /dev/sdb1              /export                ext4    defaults,usrquota 1 2
}}


Remount the mount to apply:
Remount the filesystem (or reboot) after editing {{code|/etc/fstab}} to apply:
 
{{highlight|lang=terminal|code=
mount -o remount /export
# mount -o remount /export
}}


With quotas enabled, you will need to create your quotas
With quotas enabled, you will need to create your quotas
{{highlight|lang=terminal|code=
# quotacheck -cug /export


quotacheck -cug /export
## If you get the following error
## quotacheck: Cannot guess format from filename on /dev/sda. Please specify format on commandline.
## quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
## ... specify the format like so:
# quotacheck -cugvF vfs0 /export
}}


Note that:
where:
* -c - creates
{| class="wikitable flags"
* -u - quotas for users
! Flag || Description
* -g - quotas for groups
|-
| {{code|-c}} || creates
|-
| {{code|-u}} || quotas for users
|-
| {{code|-g}} || quotas for groups
|-
| {{code|-v}} || verbose
|-
| {{code|-F}} || force format
|}


== Configuration ==
== Configuration ==
Use {{code|edquota}} or {{code|setquota}} to modify the quota for a specific user.
=== Using {{code|edquota}} ===
When you run {{code|edquota leo}} you will see:
{{highlight|lang=terminal|code=
# edquota leo
Disk quotas for user leo (uid 1061):
  Filesystem                  blocks      soft      hard    inodes    soft    hard
  /dev/sdb1                    91380          0          0      1127        0        0
}}


Use <code>edquota</code> or <code>setquota</code> to modify the quota for a specific user.
By default, there will be no quotas set (represented as 0-values in the output). To specify the soft and hard limits for both blocks (actual space, in bytes) and inodes (number of inode records available that points to a file or directory), edit the values under each column. Quota values will be applied once you save and quit the text editor.


When you run <code>edquota leo3</code> you will see:
If you run {{code|edquota}} again, you should see the new values:
{{highlight|lang=terminal|code=
# edquota
Disk quotas for user leo (uid 1061):
  Filesystem                  blocks      soft      hard    inodes    soft    hard
  /dev/sdb1                    91380    102400    153600      1127    8000    9000
}}


1 Disk quotas for user leo3 (uid 1061):
In the above example, I gave leo 100MB soft and 150MB hard quota and a 8000 soft and 9000 hard inode limit. This means leo will be able to write up to 150MB or have 9000 files and directories before writes fail. Exceeding the soft quota for more than the grace period will also prevent leo from writing to the filesystem.
2  Filesystem                  blocks      soft       hard     inodes    soft     hard
3  /dev/sdb1                    91380          0          0      1127        0        0


By default, there is no quotas for users (hence 0). To specify the soft/hard values for both blocks and inodes, edit the appropriate columns and then save and quit the editor.
You may set the grace period by running
{{highlight|lang=terminal|code=
# edquota -t
}}


1 Disk quotas for user leo3 (uid 1061):
2  Filesystem                  blocks      soft      hard    inodes    soft    hard
3  /dev/sdb1                    91380    102400    153600      1127    8000    9000


In the above example, I gave leo3 100MB of (soft) quota and a 150MB hard limit. The number of inodes enforces a file limit. That is, I have given leo3 an upper limit of 8000 (soft) file/directories and a upper hard limit of 9000.
=== Using {{code|setquota}} ===
{{highlight|lang=terminal|code=
# setquota -u -F vfsv1 username 460800 563200 22500 33000 /export/ug
}}


See Also: http://pages.cpsc.ucalgary.ca/~leo/support/quota.html


[[Category:Linux]]
{{Navbox Linux}}[[Category:Linux]]
[[Category:Todo]]
[[Category:LinuxUtilities]]

Latest revision as of 22:17, 14 June 2020

Installation

To enable quotas under Linux (a RHEL based system), you will need the quota package.

$ yum install quota

The filesystem must be mounted with the usrquota option for user quotas, grpquota for group quotas, or both.

You may set this in /etc/fstab. In this example, /export will be made to have user quota support:

/dev/sdb1               /export                 ext4    defaults,usrquota 1 2

Remount the filesystem (or reboot) after editing /etc/fstab to apply:

# mount -o remount /export

With quotas enabled, you will need to create your quotas

# quotacheck -cug /export

## If you get the following error
## quotacheck: Cannot guess format from filename on /dev/sda. Please specify format on commandline.
## quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
## ... specify the format like so:
# quotacheck -cugvF vfs0 /export

where:

Flag Description
-c creates
-u quotas for users
-g quotas for groups
-v verbose
-F force format

Configuration

Use edquota or setquota to modify the quota for a specific user.

Using edquota

When you run edquota leo you will see:

# edquota leo
 Disk quotas for user leo (uid 1061):
   Filesystem                   blocks       soft       hard     inodes     soft     hard
   /dev/sdb1                     91380          0          0       1127        0        0

By default, there will be no quotas set (represented as 0-values in the output). To specify the soft and hard limits for both blocks (actual space, in bytes) and inodes (number of inode records available that points to a file or directory), edit the values under each column. Quota values will be applied once you save and quit the text editor.

If you run edquota again, you should see the new values:

# edquota
 Disk quotas for user leo (uid 1061):
   Filesystem                   blocks       soft       hard     inodes     soft     hard
   /dev/sdb1                     91380     102400     153600       1127     8000     9000

In the above example, I gave leo 100MB soft and 150MB hard quota and a 8000 soft and 9000 hard inode limit. This means leo will be able to write up to 150MB or have 9000 files and directories before writes fail. Exceeding the soft quota for more than the grace period will also prevent leo from writing to the filesystem.

You may set the grace period by running

# edquota -t


Using setquota

# setquota -u -F vfsv1 username 460800 563200 22500 33000 /export/ug

See Also: http://pages.cpsc.ucalgary.ca/~leo/support/quota.html