Linux Disk quota Management

Source: Internet
Author: User


linux- User disk quotas

Disk quotas are where administrators can limit the amount of disk space a user can use, and each user can only use disk space in the maximum quota range

disk quotas can limit the amount of disk space that a specified account can use , which avoids the excessive use of disk space by one user causing other users to not work or even affect the system's operation. This feature is very important in server management, but it does not mean much to a single user.

The disk quotas under Linux are set up in partitions (only partitions), and quota throttling is enabled for the partition before users can be restricted.

Disk quotas are set up in two ways: hard limits and soft limits.

1. the hard limit is an absolute limit to the use of space, and in no case will the user allow it to exceed this limit;

2. the soft limit allows the user to exceed their soft limit (by default, 7 days) within a certain timeframe (usually the hard limit is set higher than the soft limit, otherwise the soft limit is meaningless), Without exceeding the hard limit can continue to use space, the system will issue a warning, but if the user reaches the default 7- day time period still does not free up space to limit the quota, the system will no longer allow the user to use more space, will remain in the user's space and only allow users to delete and read files.

There are two ways to use disk quotas to limit space: the inode and The block are respectively restricted.

1. The blocks limit, or disk quota, can limit the amount of space the user uses in the partition;

2. the inode can limit the number of files that users can create in a partition (inodes), and it is important to note that as long as the user creates a file that exceeds the inode amount that he can use , even if the files are empty, His behavior of creating files again will also be limited.

Basic steps to implement disk quotas

l Check if the kernel is supported (this step can be skipped)

l To start the partition quota feature

l Generate quota information file

l set user or group quotas

l Start disk quota service

The environment and requirements of this experiment
System: CentOS-6.6
Enable quota disk size:20G

Requirements: Quota disk mount point in /disk/, System users have ZS and ls,ZS can use disk space 1G, can create a total number of files ,LS can use disk space 100M, can create a total number of files unlimited

1. Check if the kernel supports
Use the command uname–r to view the kernel version, the version must be more than 2.4 to support the use of disk quotas, if the Linux kernel is not 2.4 The above need to recompile the kernel to achieve quotas

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/56/wKioL1VHDiOSNSvWAAB_F98_2ak305.jpg "style=" float: none; "title=" 001.PNG "alt=" Wkiol1vhdiosnsvwaab_f98_2ak305.jpg "/>


2. enable the partition quotas feature to re-mount the disks to enable the quotas feature.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/5A/wKiom1VHDLTCV9OBAADVDFWBoNE312.jpg "style=" float: none; "title=" 002.PNG "alt=" Wkiom1vhdltcv9obaadvdfwbone312.jpg "/>



If you want the partition quota feature to take effect permanently, you will need to modify the/etc/fstab file to change the device that needs to enable disk quotas to:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/56/wKioL1VHDiTxwiW0AADB05-l7RA582.jpg "style=" float: none; "title=" 003.PNG "alt=" Wkiol1vhditxwiw0aadb05-l7ra582.jpg "/>


( Uuid= is the unique identifier of the partition you want to mount, for example, to view /dev/sdb1 's UUID use command)

3. generate disk quota file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/5A/wKiom1VHDLWAqQ77AAMZpQJxOjc777.jpg "style=" float: none; "title=" 004.PNG "alt=" Wkiom1vhdlwaqq77aamzpqjxojc777.jpg "/>


[[email protected]~" #quotacheck [ option ] [ Span style= "font-family: ' The song Body '; > partition name ] options:
-a: Scan /etc/ Mtab "rescan and create a new profile regardless of the original configuration file
-u file
-G : Create a configuration file for group quotas, which generates Aquota.group file
-v: Display the scanning process
-m: Forces a read-write scanning of the file system, and
-m similar. Typically used when scanning the root partition.
-f: Forces the file system to be scanned and writes a new configuration file. General scan of newly added hard disk partitions using

after executing the command, you will see that a file named Aquota.user is generated under the/disk directory.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/56/wKioL1VHDiTgNam6AACBgOoVhAU685.jpg "style=" float: none; "title=" 005.PNG "alt=" Wkiol1vhditgnam6aacbgoovhau685.jpg "/>


4. set user quotas using the command edqouta–u ZS Modify to save exit as shown below

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/5A/wKiom1VHDLaDiaI1AADGQXB0dsI910.jpg "style=" float: none; "title=" 006.PNG "alt=" Wkiom1vhdladiai1aadgqxb0dsi910.jpg "/>


set user ls

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/5A/wKiom1VHDLbw-SQeAADjw0KzBB8281.jpg "style=" float: none; "title=" 007.PNG "alt=" Wkiom1vhdlbw-sqeaadjw0kzbb8281.jpg "/>


5. Enable disk quotas service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/56/wKioL1VHDiWDRc15AAC0TV-2rhE409.jpg "style=" float: none; "title=" 008.PNG "alt=" Wkiol1vhdiwdrc15aac0tv-2rhe409.jpg "/>


Test users use ZS users to create more than a few files in the disk, test

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/5A/wKiom1VHDLex987PAADhhCcnUUk759.jpg "style=" float: none; "title=" 009.PNG "alt=" Wkiom1vhdlex987paadhhccnuuk759.jpg "/>


This error occurs if the configuration is successful











This article is from the "Aforetime for the King" blog, please be sure to keep this source http://zhanshanweiwang.blog.51cto.com/9764673/1641714

Linux Disk quota Management

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.