Disk quota management
Linux Disk Quota
1. the disk quota is restricted only for the entire partition: When the disk quota is actually run, it is restricted for the entire partition. For example, if/dev/hda5 is loaded under/home, all directories under/home are restricted. The core must support the disk quota: the Linux system core must support the disk quota module. Disk Quota record file: the core version of the Kernel 2.6.XX used. This core version supports the new disk quota module and uses the default file (aquota. user, aquota. group) will be different from the old version of quota. user and quota. group. The old version of the disk quota can be converted to www.2cto.com through the convertquota program, which is only valid for general identity users: not all Linux accounts can set disk quotas, for example, root cannot set the disk quota because it owns all the data of the entire system.
Disk quota
2. The Disk Quota Program has the minimum hard disk quota limit (soft): This is the minimum disk quota. Disk quota in redhat linux.Within the grace period, the user's capacity can exceed the minimum limit, but the disk capacity must be reduced to the minimum limit within the grace period. Hard: This is the capacity that cannot be exceeded. Generally, the maximum limit is higher than the minimum limit. Grace period: when the user's space exceeds the minimum limit, but the maximum limit is not reached, within this "grace period, you must reduce the disk space used to the minimum limit. Samba disk quota ,Otherwise, data cannot be written. Otherwise, the grace period is canceled. the basic Disk Quota command first describes the commands used for disk quota before you start to practice Disk Quota.
Windows 10 disk quota
These commands are divided into two types, one is the query function (quota, quotacheck, quotastats, warnquota, requota), and the other is to edit the disk quota content (edquota, setquota ). Next we will discuss these basic commands. 3.1./etc/mtab www.2cto.com why should I mention the record file actually loaded by this file system? Note that when we use the disk quota, the system will search for "partitions with disk quota parameters on the system". Therefore, when we want to use the disk quota function, the system file must support the disk quota flag. In general, we edit/etc/fstab and reload the file system to enable the system's file system to support disk quotas. This concept is very important. 3.2. The quota command is only used to "display" the disk quota of a current user or group. # Quota-uvs // displays the current user's quota value-u: displays the user's quota-g: displays the group's quota-v: display the disk quota of each file system-s: you can choose to use Inode or disk capacity limit value to display # quota-gvs // display the quota value of the root user's group # quota-uvs test1 // display the quota value of test1 users 3.
Windows disk quota
3. the quotacheck command is mainly used to scan the quota space of a disk. It scans partitions and may increase the number of files during scanning because the disk continues to work, the disk quota scan is incorrect. Therefore, when quotacheck is used, the disk is "automatically set as read-only sector". After scanning, the results of the disk space scanned will be written to the top of the area (aquota. user and aquota. group) # quotacheck-cug // scan the partition and generate the quota information file-a: scan all files containing the supported Disk Quota in/etc/mtab File System. If this parameter is added, you can skip/mount_point-v: the scanning process is displayed-u: quota is created for the usage of files and directories scanned by the user. user-g: quota is created for the group scan files and directories. group-c: indicates the creation of Ps. If you are prompted that the quotacheck cannot be created, the permission is insufficient because SElinux can be disabled. 3. 4: edit the disk quota value of each "user" or "User Group" in the file edquota www.2cto.com. Generally, we use edquota-u username or edquota-g groupname to edit the disk quota values of individual and user groups. However, one allocation is slow. You can also directly copy a person's settings to another person. Use edquota-p user1-u user2. The following describes the values in the edit process. Filesystem: indicates which partition the disk is. Blocks: this is the number of disks consumed by the current user on the file system, that is, the space used by the current user. Unit: KB-u: Configure your disk quota-g: disk Quota of the Configuration Group-p: Disk Quota for copying, from one user to another-t: Modify the grace period, you can configure the disk quota of test1 for the partition # edquota-u test1 // # edquota-p test1-u test2 // modify the bandwidth of test2 # edquota-t // time can be used for each partition www.2cto.com 3.5. quotaon is the disk quota to be started. However, this command is used to start aquota. group and aquota. user, so you must first complete quotacheck, and then run quota-a to start-u: Disk quota for users-g: Disk quota for user groups-v: display information about the startup process-a: According to The file system sets the disk quota for startup. If-a is not added, then you need to add the specified file system # quota-avug // all disk quotas for starting # quota-uv/data // start/data, and set the user disk quota to 3.6. quotaoff-a: Disable the disk quota of all file systems-u: Disable the user's disk quota-g: disk Quota of the close group # quotaoff-a // close all # quotaoff-u/data // disable/data User disk quota setting value quota Disk Quota instance 1 Disk Quota is widely used, it has the following general purposes :. Limit the maximum disk quota that a user group can use. Limit the maximum disk quota of a user. Use the connection method to enable the mail to be used as the quota disk quota from the preparation of file system support, to the end of the entire setting the main steps are as follows: Step 1: step 2: Create a disk quota file Step 3: edit the disk quota limit value data Step 4: rescan and enable Disk Quota settings steps are as follows, the following example describes the entire process. In my linux host, I mainly set disk quotas for test1 and test2 users, both of which are in the test user group. Each user has a disk space limit of 50 MB, and the minimum limit is 45 MB .. The grace period is one day. That is to say, the disk space is no longer available after the minimum limit is 1 day. The maximum quota of the test user group, set to 90 MB 1: Prepare the test environment, create user and user group 1 # groupadd test2 # useradd test1-g test3 # useradd test2-g test4 # passwd test15 # passwd test22: the disk quota for file system creation supports 1 www.2cto.com [root @ yangcan ~] # Fdisk-l/dev/sda2 Device Boot Start End Blocks Id System3/dev/sda1 * 1 64 512000 83 Linux4Partition 1 does not end on cylinder boundary.5/dev/sda2 64 2611 20458496 8e linux LVM6/dev/sda4 2611 3916 10483750 5 Extended7/dev/sda5 2611 3916 10483718 + 83 Linux1 [root @ yangcan ~] # Mkdir/test2 [root @ yangcan/] # vi/etc/fstab3 [root @ yangcan/] # mount-a4 [root @ yangcan/] # mount | grep sda55/dev/ sda5 on/test type ext4 (rw, usrquota, kgquota) www.2cto.com 1 [root @ yangcan Desktop] # quotacheck-cug/test/2 [root @ yangcan Desktop] # cd/test/3 [root @ yangcan test] # ll4total 325-rw ------- 1 root root 6144 Aug 3 aquota. group6-rw ------- 1 root 6144 Aug 3 aquota. user7drwx ----- -2 root 16384 Aug 3 lost + found3. in this way, the disk format of the disk quota is added. However, since the actual Disk Quota reads the/etc/mtab file from time to time, the file must be restarted before new data of/etc/fstab can be used. Restart or 1 [root @ yangcan test] # mount-o remount/data so that/dev/sdb1 supports disk quota (quota) 4: disk quota limit 1 [root @ yangcan test] # quotaon-avug 5: edit the user's available space 01 www.2cto.com [root @ yangcan test] # edquota-u test1 // The format is as follows, in KB02Disk quotas for user test1 (uid 503 ): 03 Filesystem blocks soft hard inodes soft hard04/dev/sdb1 10256 45000 50000 1 0 005 [root @ yangcan test] # edquota-p test1-u test2 // copy the test1 Setting Value set the Grace period 07 Grace period before enforcing soft limits for users for test206 [root @ yangcan test] # edquota-t: 08 Time units may be: days, hours, minutes, or seconds09Filesystem Block grace period Inode grace period10/dev/sdb1 1 1 days 7days11
Now, the user settings are basically complete. Let's take a look at [root @ yangcan test] # quota-uv test1 test26: edit the available space of the user group [root @ yangcan test] # edquota-g test // the available space of the editing group Disk quotas for group test (gid 501 ): filesystem blocks soft hard inodes soft hard/dev/sdb1 0 80000 90000 0 0 0 Note: If you set the quota of the test group to 90 MB, when test1 is in use, if 50 MB of maximum space is used, the space reserved for test2 is only 40 MB. When test2 is written to 40 MB, a message indicating that the data cannot be written is displayed, whether its quota is set to 50 MB www.2cto.com 7: Set the disk quota for startup [root @ yangcan test] # vi/etc/rc. d /Rc. local/sbin/quotaon-avug8: use repquota to display more completed Disk Quota results report [root @ yangcan test] # repquota-a [-vug] [root @ yangcan test] # repquota-av // view all disks quota file system limit value [root @ yangcan test] # repquota-avu username // view the user's disk quota limit value 1.4 do not change the existing system disk quota instance because the disk quota "only overall restrictions on the entire partition, it is impossible to target a specific directory. Therefore, it is not difficult to find that "storing emails in a personal home directory is the same as storing emails in a shared directory under/home". Why? This is because the disk quota is correct. Therefore, you must first confirm that "your/home is an independent partition ". However, what should I do if I forget to separate/home into a partition when installing a linux host? Do I need to repartition and load/home? Also, what should I do if I forget to separate the directory in the/var/spool/mail mailbox? A simple example shows that all users are in/home and emails are under/var/spool/mail, but they are not independent partitions. What should I do? In fact, it is easy to do. Since the disk quota is restricted for a certain partition, I have configured the/data disk quota, so we only need :. Move the entire/home directory to/data ;. Use ln-s/data/home to establish connection data ;. Move/var/spool/mail to/data ;. Use ln-s/data/mail/var/spool/mail to establish the connection data. As long as this is done, the mail quota of the host is reached, you can also set disk quotas based on different users and user groups, and connect them using the above method. Then you can set different quotas for different users. Very convenient. Disk Quota instance 2 www.2cto.com setting rules: 1. Each user can store up to 20 mb of files, and can create up to 200 files. 2. warn users when creating files larger than 100 mb and more than files. 3. Because some users have exceeded the above restrictions, we must first notify the user via email to process unnecessary files as soon as possible. 2. Due to the sudden occurrence of the incident, in order to avoid strong user feedback, we should first give each user a 7-day period so that the user has the opportunity to back up files. However, after 7 days, the deadline will be automatically changed to 2 days. Solution: www.2cto.com 1. Set the disk quota for each user account. 2. Send a notification to all users who have exceeded the limit. 3. The period is automatically changed to 2 days after 7 days. Step: 1. Set the disk quota for each user account. Use edquota with the-p parameter to manually configure a user's disk quota using edquota, set it as a template, call it to other users, and run the following command: dequota [-u |-g]-p tempname names where TEMONAME is the name of the template user, and NAMES is the name of the user to be called. For example, dequota-p jacky allen bill cherry uses jacky as the template to call jacky's disk quota settings to allen bill cherry and other users. Another method is to use the setquota tool. With the Shell loop technique, set the disk quota for each user. For user in jacky allen bill cherry; do www.2cto.com setquota $ {user} 10240 20480 100 200/data done requires a large number of usernames. Here, we can use awk to extract common users whose UID is greater than or equal to 500. Awk-F: '{if ($3> = 500) print $1}'/etc/passwd and then hand over the above results to edquota for use. Awk-F: '{if ($3> = 500) print $1} '/etc/passwd | xargs edquota-p jacky www.2cto.com use setquota for user in (awk-F:' {if ($3> = 500) print $1} '/etc/passwd); do www.2cto.com setquota $ {user} 10240 20480 100 200/data done or # users = 'awk' BEGIN {FS = ": "} {if ($3> 500) print $1} '/etc/passwd' (the first and last symbols are the reversed marker, that is, the key under esc) show the above assignment: echo $ users edquota-p username $ users 2. Send a notification to all users who have exceeded the limit immediately after setting. We can send emails via warnquota to users who exceed the disk quota. However, warnquota uses/etc/warnquota. conf content generates an English email. Besides, we want to customize the email, although we can modify/etc/warnquota. conf, but only one email is required. It will not be sent in the future. After sending the email, you must restore it back. Therefore, we can generate a file in the same format as/etc/warnquota. conf. For example, in my ~ /Warnquota. conf www.2cto.com MAIL_CMD = "/usr/sbin/sendmail-t" FROM = SUBJECT = Note: you have exceeded the disk quota limit CC_TO = "root @ localhost" SUPPORT = "XXXXXX" PHONE = "XXXXX" MESSAGE = Hello, your disk quota has exceeded the warning value, | Delete unnecessary files. SIGNATURE = me@myhost.com and then execute the following command to make warnquota temporarily use our configuration file (~ /Warnquota. conf) sends all emails. [Root @ guo ~] # Warnquota-c ~ /Warnquota. conf 3. The period is automatically changed to 2 days after 7 days (the date is automatically modified ). You can use www.2cto.com to set the system duration of the disk quota. The first method is to run the preceding command through edquota: edquota-t, and edquota will enable the editing software for the $ EDITOR Environment variable definition, set the quota period for the disk. Then, use at for scheduled service. At 0 am + 7 days
Write Fu Sheng θ