How to Set Disk Quota in Linux (new version)

Source: Internet
Author: User
How to Set Disk Quota in Linux (new version)-General Linux technology-Linux technology and application information. For more information, see the following. [I = s] This post was last edited by gary168 at, September 17 ,.

Disk quota (quota) is a tool used by the system administrator to monitor and restrict the use of disks by users or groups.
Quota has two restrictions:
1. Restrict the inode (number of files) that can be owned by users or groups );
Second, limit the number of disk blocks allocated to users or groups (Disk Space in kilobytes ).
By using quota, the system administrator can restrict the uncontrolled use of disk space. The Quota program is for each user and each file system, so each file system must be set separately.

Compile a kernel that supports quota
First, make sure that your Linux kernel supports quota.
In the kernel of version 2.2.14, the following question must be answered during compilation: "y ".
Filesystems
Quota support (CONFIG_QUOTA) [N/y/?] Y

Modify the "/etc/fstab" File
The "/etc/fstab" file contains information about various file systems installed on Linux systems. Before using quota, you must set it in "fstab" to make it take effect. Because quota must be set for each file system separately, and in the "fstab" file, each file system is represented by a single line, therefore, in order to support quota, each row of "fstab" must be set separately. You can set quota for users, groups, or groups and users as needed. In the following example, we assume that the "/home" directory is on the "/dev/sda6" device, there are three possible situations.

The first possible situation:
Set the user quota on a specific file system and edit your "fstab" file (vi/etc/fstab ), add "usrquota" after "ults" or other settings for the file system ".
For example:
/Dev/sda6/home ext3 defaults 1 2 (as an example: the word "defaults ")
/Dev/sda6/home ext3 nosuid, nodev 1 2 (as an example: any other options you have set)

Changed:
/Dev/sda6/home ext3 defaults, usrquota 1 2
/Dev/sda6/home ext3 nosuid, nodev, usrquota 1 2

The second possible situation:
Set the quota group on the file system, edit your "fstab" file (vi/etc/fstab), and add "maid" after "defaults" or other settings for the File System"

For example:
/Dev/sda6/home ext3 defaults 1 2 (as an example: the word "defaults ")
/Dev/sda6/home ext3 nosuid, nodev 1 2 (as an example: any other options you have set)

Changed:
/Dev/sda6/home ext3 defaults, MAID 1 2
/Dev/sda6/home ext3 nosuid, nodev, MAID 1 2

The third possible situation:
Set users and groups on the file system, and edit the "fstab" file (vi/etc/fstab ), after "ults" or other settings made for the file system, add "usrquota, or kgquota ".
For example:
/Dev/sda6/home ext3 defaults 1 2 (as an example: the word "defaults ")
/Dev/sda6/home ext3 nosuid, nodev 1 2 (as an example: any other options you have set)

Changed:
/Dev/sda6/home ext3 defaults, usrquota, MAID 1 2
/Dev/sda6/home ext3 nosuid, nodev, usrquota, kgquota 1 2
Create "quota. user" and "quota. group" files
After modifying the "/etc/fstab" file, in order to establish quota on the file system, under the root directory of the file system (in our example, "/home ") there must be a file with "root" ownership: If you set the user quota, you must create a "quota. user. group "; if you want to set both the user and the group quota, both files must be created.

Step 1
Create the "quota. usr" or "quota. group" file as the root directory of the partition where you want to set quota:
[Root @ deep/] # touch/home/quota. user
[Root @ deep/] # touch/home/quota. group
[Root @ deep/] # chmod 600/home/quota. user
[Root @ deep/] # chmod 600/home/quota. group
The "touch" command creates an empty file in the "/home" directory .. The "chmod" command sets only the "root" User read and write permissions for these files.
Note:: The two quota files, "quota. user" and "quota. group", must be owned by "root" and "root" users have read and write permissions.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.