Advanced file System Management for Linux

Source: Internet
Author: User
Tags uuid

Because Linux is a multi-user managed operating system, Linux by default does not limit the size of disk space per user, if a user inadvertently or maliciously occupied disk space, will cause the system disk can not write or even crash, in order to ensure that the system disk has enough space, We need to restrict the use of disk space to users and groups.

Disk quota limit Type:

    • Limit the amount of disk space users and groups use
    • Limit the number of files that users and groups create within a disk

Disk quota limit level:

    • Soft limit: Low limit, this limit can be broken, the breakthrough will be warned, the excess will have a grace days, the grace period expires after the part is emptied, soft limit can not exceed the hard limit
    • Hard limit: Absolute limit, this limit will not be breached, no more space can be used after the specified limit is reached
    • Grace Days: When there is more data than soft limit, the excess will be timed, the grace period expires after the partial data will be emptied, the grace days default is 7 days

Let's start with a detailed look at the detailed commands for the user's disk space settings, first you need to turn on quota, and then set up quota.

Quota of the EXT series file system

1. Open Quota (ext, XFS)

Write the following line in the/etc/fstab file, and then save the exit

uuid=e060a9c0-c9d3-4632-ae17-70ffee835d6f   /app   ext4 defaults,usrquota,grpquota        1 0

Then re-mount, and then grep to see if the mount was successful

[[Email protected] ~] # Mount-o Remount/dev/sdb [[Email protected] ~] # Mount |grep Quota/dev/sdb on/app type EXT4 (Rw,usrquota,grpquota)

2. Generate Quota Database

[[Email protected] ~] #  [[email protected] ~]#  cd/app[[email protected] app]#< C11/>aquota.user  Lost+found

3. Open Quota

  [[email protected] app] # Quotaon/app

So far, the quota of the EXT4 type file system has been successfully opened, and the relevant usage and settings are shown below

4, quota
-V Displays the current user's own quota limit

[[email protected] app] # quota-v  for user root (uid 0): Filesystem  blocks   quota   limit   Grace   files   Quota   limit   Grace       /dev/sdb       0       0               2       0       0

-V username Displays the quota limit for the specified user at this point, you need to be aware that this command is root only
Repquota-v/app Displays the quota limit for all users (only files that the user belongs to in this directory) root only

5, configuration quota The following commands are directly open the corresponding script file and then directly inside the corresponding block or inode of the soft and hard device

   edquota-u/g username/groupname     -u caocao     -G Weiguo

Non-interactive individuals feel that if they know what the file requirements are, it is better to use the following method directly

  setquota-u[default] |-g  username|groupname 10M 20M 5/app    -u caocao 0 0 0 0/app   -g Weiguo 10M 20M/app  -P caocao Zhangfei copy liubei quota  settings to Zhangfei

Note: When setting quota for group, the additional group settings should be set, while the directory setting Sgid permissions makes sense

Ii. quota of the XFS file system
After defaults the quota file system Mount option is required, add Usrquota,grpquota as follows
Uuid=f5f95aff-f321-46b6-9a1b-14781387548d/backup XFS Defaults,usrquota,grpquota 1 0

Be sure to uninstall and reload before it takes effect

2. Configuration
Xfs_quota-x-C "Print" to view all XFS file systems in the current system which have quota enabled

[[email protected] bin] # xfs_quota-x-C "print" Filesystem          Pathname/                         /dev/mapper/centos-root/boot                 /dev/sda1/backup/dev/            md1 ( Uquota, Gquota)/app                 /dev/mapper/centos-app

Xfs_quota-x-C "report-ugibh" View quota settings

-U View the user's
-G View Group
-I view Inode
-B view block (default)
-H human-readable


Below is the app with the most applied –ugibh combination, where users and groups can display quota permissions

Xfs_quota-x-C "state"/backup View qutoa status, show Grace time

[[email protected] home]#Xfs_quota-x-C "state"/backup/User Quota State On/backup (/dev/md1) Accounting:on enforcement:on Inode:#(2 blocks, 2 extents)Group Quota State On/backup (/dev/md1) Accounting:on enforcement:on Inode:#(2 blocks, 2 extents)Project Quota State On/backup (/dev/md1) Accounting:off Enforcement:off Inode:#(2 blocks, 2 extents)Blocks Grace Time: [14days] is the time after the change, the default is 7 day inodes Grace Times: [7Days ] Realtime Blocks Grace Time: [7 days]

Xfs_quota-x-C "limit-u bsoft=30m bhard=40m User"/backup

3. Set quota to User
Xfs_quota-x-C "limit-g bsoft=50m bhard=100m Shuguo"/backup

[[email protected] home]#Xfs_quota-x-C "limit-u bsoft=40m bhard=50m Sunquan"/backup[[email protected] home]#repquota-v/backup/Report forUser quotas on device/dev/Md1block Grace Time:14days; Inode Grace Time:7days Block limits File limitsuser used soft har D Grace used soft hard grace----------------------------------------------------------------------Root--0 0 0 3 0 0Sunquan+-46080 40960 51200 7days 2 0 0 * * Status forUser quotas on device/dev/Md1accounting:on; Enforcement:oninode:#(2 blocks, 2 extents)

Set quota for a group

Xfs_quota-x-C "Timer-u-B 14days"/backup Set quota grace time

Get help
Xfs_quota-x-C "Help limit"
Xfs_quota-x-C "Help report"

Third, quota closed

Quotaoff option Partition Name

-a disk quota for all partitions is closed according to the/etc/mtab file (no partition name is written)

-U shuts down the user's disk quotas

-G disk quotas for closed groups

-V Displays startup process information

If you want to start the next time no longer boot, it is best to modify the/etc/fstab file in the better. These are the settings related to quota.

Advanced file System Management for Linux

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: 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.