Disk quota settings under Linux

Source: Internet
Author: User

Disk Quota Concepts

Disk quotas are actually allocating a certain amount of disk to each user, allowing him to use only the amount of disk space in the range. In a Linux system, a multi-user multitasking environment, so there will be a lot of people sharing a disk situation. It is necessary for each user to limit a certain amount of disk space in order to appear fair. In Linux, the thing that is used to manage disk quotas is quota, and quota is limited to the entire partition in practice. For example, if we restrict/dev/sdb1 to this partition, and/DEV/SDB1 is mounted in the/home directory, then the/home directory will be restricted.

Quota command

Quota: Used to display a limit for a group or a user
Option: Quota [-guvs] [User,group]
- GShow limits for a group
- uShow limits for a user
- vShow Details
- SSelect Inode or hard disk space to display
QuotacheckThe quota space used to scan a disk
Option: Quotacheck [-AUGV]/path
-AScan all mounted disks with quota quotas
- uScan a user's files and directories
- GScan a group of files and directories
- vShow scanning process
- MForcing a scan
EdquotaUsed to edit the quota value of a user or group
Option: Edquota [-u user] [-G Group] [-T]
- uQuotas for a specified user
- GQuotas for a specified group
- TTo edit a soft limit for a wide range of hours
- PCopy the quota of a user or group to another user or group
QuotaonUsed to start quota, after setting the quota, need to start to be quota effective
Option: Quotaon [-A] [-UGV directory]
-AAll set quota start-up
- uLaunches the quota of the specified user
- GStarts the quota of the specified group
- SShow related information
Quotaoff
Quotaoff is used to close quota, the command is used in only one case, quota-a close all quota
(Note: The above command supports EXT file system, does not support XFS file system)
E ' dquota-u user, the system will enter an editing interface, a total of seven columns, respectively:
FilesystemDisk partitioning
blocksThe current user's disk capacity in the current filesystem, in kilobytes.
SoftThe current user's quota,soft in the filesystem refers to the minimum limit, which can exceed this value, but the disk capacity must be lowered below this value within the grace period.
HardRefers to the maximum limit, that is, the value cannot be exceeded.
inodesCurrently, the state of the inode is used without modification.

Disk quotas

1 Set up a test account, add Liu Bei, Guan Yu, Zhang Fei three users and Shu group
And the Shu group is a nearby group of three users

useradd liubeiuseradd guanyuuseradd zhangfeigroupadd shuoguogpasswd -a liubei -g shuguogpasswd -a guanyu -g shuguogpasswd -a zhangfei -g shuguo


2 Open the Quota function of the disk, use Vim to edit the/etc/fstab, modify the defaults to Usrquota, then re-mount once, then use the Mount command to view the/backup partition has been added "Usrquota,grpquota"

vim  /etc/fstab mount  -o remount /dev/sdb1mount


3 Scan disk for user usage and generate important aquota.group and Aquota.user
Quota.group and Quota.user are the configuration files that are required for the group and the user's disk quotas, respectively.
If you do not have these two files, the disk quotas will not take effect

quotacheck -cugm /backupls /backup


4 Starting Quota quotas

quotaon /backup

5 Edit User L Liu Bei's disk quota (block specifies the number of blocks, the default block is 4k, so the specific size needs our own calculation, here we set the size of 15m,25m)

edquota -u liubei /backupquota -v liubei


6. Quotas for the Shuguo group for the specified group (we set the 150m,250m here)

edquota -g shuguoquota -gv shuguo


This way our-user and group permissions are complete, but because we want to enter edit mode and need to calculate the size of the quota, we can use the non-interactive method to quota, as follows:

setquota -u[default] |-g  username|groupname 15M 25M 0. 0 /backup

Disk quotas for user Zhang Fei

setquota -u zhangfei 15M 25M 0 0 /backuprepquota -v /backup

Disk quota settings under Linux

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.