How to control disk usage with Quota
What is Quota? Explanation of the basic settings and usage methods
Quota is a feature that limits the number or capacity of files that a user or group can have.For example, if you want to limit the usage of a user named B to 100GB on a file system named A, you can use Quota.
Quota allows you to manage disk space efficiently and prevent disk waste by users or groups.
Types of Quota
There are two types of Quota.- User Quota: Quota that limits disk usage by user. It is also called usrquota.
- Group Quota: Quota that limits disk usage by group. It is also called grpquota.
Terms of Quota
When setting or checking Quota, you need to know the following terms.- Block: The block unit of the disk. Usually calculated as 1KB.
- Inode: A structure that stores the metadata of a file. It represents the number of files.
- Soft Limit: The limit that gives a warning. If this limit is exceeded, a grace period is given and the usage must be reduced within this period.
- Hard Limit: The absolute limit. If this limit is exceeded, no more files can be created or written.
- Grace Period: The grace period given when the Soft Limit is exceeded. Usually set to 7 days.
How to set Quota
The method of setting Quota is as follows.1. Add the Quota option of the file system to the fstab file.
For example, to apply User Quota and Group Quota to the /data001 file system, modify it as follows.
1 | /dev/mapper/F3170_786_vg001-data001 /data001 ext3 defaults,usrquota,grpquota 0 0 | cs |
1 | mount -o remount /dev/mapper/F3170_786_vg001-data001 | cs |
3. Create Quota information for the file system with the quotacheck command.
1 | quotacheck -cug /data001 | cs |
The -c option is an option to create Quota information, and the -u and -g options are options to create both User Quota and Group Quota.
When this command is executed, files named aquota.user and aquota.group are created in the /data001 folder.
4. Set the Quota limit for the file system with the setquota or edquota command.
The setquota command is used in the following format.
The setquota command is used in the following format.
1 | setquota user name soft capacity hard capacity soft number hard number target file system | cs |
1 | setquota user1 51200000 51200000 1000 1000 /data001 | cs |
The edquota command uses the vi editor to set the Quota limit.
1 | edquota user1 | cs |
When this command is executed, the following screen appears.
1 2 3 4 | Disk quotas for user user1 (uid 1001): Filesystem blocks soft hard inodes soft hard /dev/mapper/F3170_786_vg001-data001 1024 51200000 51200000 4 1000 1000 | cs |
The edquota command can copy another user’s Quota settings with the -p option. For example, to copy user1’s Quota settings to user2, enter as follows.
1 | quotaon -a | cs |
The -a option is an option that turns on the Quota function for all file systems. If you want to turn on only a specific file system, enter the name of the file system.
How to check Quota
The method of checking Quota is as follows.- Show Quota information for the file system with the repquota command.
1 | repquota /data001 | cs |
When this command is executed, the following screen appears.
1 2 3 4 5 6 7 8 | *** Report for user quotas on device /dev/mapper/F3170_786_vg001-data001 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 1024 0 0 4 0 0 user1 -- 1024 51200000 51200000 4 1000 1000 user2 -- 1024 51200000 51200000 4 1000 1000 | cs |
Here, used is the usage, soft and hard are the limits, and grace is the grace period.
Show the current user’s Quota information with the quota command.
1 | quota -s | cs |
The -s option is an option that shows the capacity in MB or GB instead of KB. When this command is executed, the following screen appears.
1 2 3 4 | Disk quotas for user user1 (uid 1001): Filesystem blocks quota limit grace files quota limit grace /dev/mapper/F3170_786_vg001-data001 1024M* 50G 50G 4* 1000 1000 | cs |
The * mark means that the Soft Limit has been exceeded.
Conclusion of Quota
Quota is a useful feature that limits disk usage.By setting and managing Quota properly, you can improve the performance and stability of the system.
I think there are many situations where Quota is needed.
I think there are many situations where Quota is needed.
For example, when multiple users create or modify files on a shared server, if there is no Quota, disk space may be insufficient or overhead may occur.
I think Quota is a great tool to help control disk usage.
This concludes the post.
This concludes the post.
Thank you.
댓글
댓글 쓰기