Restrict Linux users from occupying disk space

Source: Internet
Author: User
Article Title: Restrict Linux users from occupying disk space during transition. Linux is a technology channel of the IT lab in China. Some basic categories, such as desktop applications, Linux system management, kernel research, embedded systems, and open-source systems, are now growing in size. May someone ask, do I still need to configure the disk quota? The answer is yes. As the disk storage capacity increases, user data storage requirements increase, especially in some multi-user environments, some crazy Downloaders who use P2P software may occupy a large amount of space in a short time, which prevents other users from using the storage space to a certain extent. Can you stand by as a network manager?
 
Today, we will look at how to configure disk quotas in Linux to limit the abuse of space by users. Using the disk quota is quite simple, and it is useful for limiting those who take up too much disk space. You can also set a soft quota and a hard quota to remind a user of the soft quota when the user approaches its capacity limit. The hard quota will impose the maximum capacity limit.
 
A quota can be defined for each file system. Most releases support quotas. Although all features may have been installed during system installation, we may still need to install the disk quota package. To enable Disk Quota support, edit/etc/fstab as the root user, and add the usrquota and kgquota options for the file system that you want to enable quota support. Example:
 
/Dev/md5/myhome xfs defaults, nosuid, nodev, usrquota, or kgquota 1 2
 
Once a change is made, you need to reload the file system that has changed:
 
# Mount-o remount/myhome
 
To check whether the quota support is actually enabled, run the following command:
 
# Quotacheck? Augmv
 
This command instructs quotacheck to check the quota of users and groups on all file systems without reloading them as "read-only ". When "quotacheck" is run for the first time, it displays many errors because it has never checked the system before. Now we can use the quotaon command to enable the quota:
 
# Quotaon-augv
 
Once the disk quota is enabled, you can use the edquota command to edit the quota for a specific user. For example:
 
# Edquota-u mike
 
Command will open the default system Editor (usually vim), so that we can edit the hard limit and soft limit of block and node quotas.
 
Then, by using the repquota tool, we can view the current quota utilization:
 
# Repquota? A
 
After the user's soft quota is exceeded, a notification will be received, but the user can still write files to the system until the hard quota is reached. At this time, any newly created file will be 0 bytes. Of course, the administrator can change the transition time to determine whether to allow such default behavior. The default value is 7 days. During the transition period, if the soft quota is exceeded, you can continue to write files until the hard quota is reached. After the transition period, you cannot write files.
 
By using this soft and hard-working method, administrators can ensure that those who are greedy for disk space cannot affect the reasonable storage space utilization of other users.
 
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.