Disk quota for linux (quota) and linuxquota

Source: Internet
Author: User
Tags disk usage

Disk quota for linux (quota) and linuxquota

Disk quota management

1. What is quota?

Disk quota

Simply put, it limits the amount of disk space used by users.

Because Linux is a multi-user and multi-task operating system, many people share disk space. In order to reasonably allocate disk space, quota emerged.

Windows disk quota

2. Usage of quota
Display disk usage and quota

3. General objects of quota
(1) for WWW server
(2) For mail server
(3) For file server

Disk quota in redhat linux
4. quota Restrictions
(1) only applicable to the entire file system
(2) kernel support is required.
(3) only valid for general users

5. Use of quota

Test Environment

RHEL6.6 (the default kernel already supports the quota function)

/Dev/sdb1 file system for testing

User Group myquota

User quota1, quota2

 Samba disk quota

The procedure is as follows: windows 10 disk quota

(1) re-mount the/dev/sdb1 file system, and add the usrquota and kgquota parameters.

[Root @ localhost ~] # Mount-o remount, usrquota, kgquota/dev/sdb1

After the disk is remounted, the/dev/sdb1 partition supports the quota function.

[Root @ localhost ~] # Mount | grep/dev/sdb1
/Dev/sdb1 on/mnt/test type ext4 (rw, usrquota, kgquota)

(2) Add User Groups and users

[Root @ localhost ~] # Groupadd myquota
[Root @ localhost ~] # Useradd-g myquota quota1
[Root @ localhost ~] # Useradd-g myquota quota2

(3) generate the quota configuration file

[Root @ localhost ~] # Cd/mnt/test/

[Root @ localhost test] # quotacheck-ug.

[Root @ localhost test] # ls
Aquota. group aquota. user lost + found generate the quota configuration file
(4) Start the quota Function

[Root @ localhost test] # quotaon/dev/sdb1
To disable the quotaoff command

(5) modify the quota configuration file

   
The configuration file is as follows:
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 0 0 0 0 0 0

The soft/hard value must be modified. Unit: KB. soft indicates the warning value and hard indicates the maximum value. When the disk usage is between soft-hard, A warning will be issued (default countdown 7 days). If the warning time is exceeded and the disk usage is still between soft-hard, the disk space is forbidden.

If you modify the soft/hard value of blocks, specify the size of the disk space that can be used by the user (generally, the disk usage is specified)

If the soft/hard value of inodes is modified, it indicates the number of files that can be created by the user.


[Root @ localhost test] # edquota-u quota1 --> modify the configuration for quota1 users

Disk quotas for user quota1 (uid 500 ):
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 0 100000 200000 0 0 0

[Root @ localhost test] # edquota-u quota2 --> modify the configuration for quota2 users

Disk quotas for user quota2 (uid 501 ):
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 0 100000 200000 0 0 0

[Root @ localhost test] # edquota-g myquota --> modify the configuration for the myquota Group

Disk quotas for group myquota (gid 500 ):
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 251200 100000 300000 3 0 0

In this way, quota1 and quota2 users can use up to MB of disk space. If they exceed MB, a warning is issued and a countdown is triggered. The myquota group can use up to MB of disk space.

That is to say, although quota1 and quota2 both have 300 MB of maximum disk space available, they all belong to the myquota group and their total volume cannot exceed MB.



Modify permissions

[Root @ localhost test] # chmod 777.
[Root @ localhost test] # ll-d
Drwxrwxrwx. 3 root 4096 August 23 09:36.
Switch quota1 user to test

[Root @ localhost test] # su quota1
[Quota1 @ localhost test] $ dd if =/dev/zero of = bigfile1 bs = 1 M count = 150
Sdb1: warning, user block quota exceeded. --> warning
Recorded 150 + 0 reads
Records 150 + 0 writes
157286400 bytes (157 MB) Copied, 1.02545 seconds, 153 MB/second

Write a large file.

[Quota1 @ localhost test] $ dd if =/dev/zero of = bigfile2 bs = 1 M count = 150
Sdb1: write failed, user block limit reached.
Dd: Writing "bigfile2": the disk quota is exceeded. --> If the disk quota is exceeded MB, data cannot be written.
Records 46 + 0 reads
Records 45 + 0 writes
47513600 bytes (48 MB) Copied, 0.381467 seconds, 125 MB/second

Switch quota2 user

[Root @ localhost test] # su quota2
[Quota2 @ localhost test] $ ls
Aquota. group aquota. user bigfile1 bigfile2 lost + found
[Quota2 @ localhost test] $ dd if =/dev/zero of = bigfile3 bs = 1 M count 50

Read records of 50 + 0
Records the write records of 50 + 0
52428800 bytes (52 MB) Copied, 0.410838 seconds, 128 MB/second

Modify warning time

[Root @ localhost test] $ edquota-t

Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/Dev/sdb1 7 days 7 days


View quota information of quota1

[Quota1 @ localhost test] $ quota-u quota1
Disk quotas for user quota1 (uid 500 ):
Filesystem blocks quota limit grace files quota limit grace
/Dev/sdb1 200000*100000 200000 6 days 2 0 0 --> the warning countdown has started.

Query the quota information of quota2

[Root @ localhost test] # quota-u quota2
Disk quotas for user quota2 (uid 501 ):
Filesystem blocks quota limit grace files quota limit grace
/Dev/sdb1 51200 100000 200000 1 0 0

Query the quota information of the myquota group.
[Root @ localhost test] # quota-g myquota
Disk quotas for group myquota (gid 500 ):
Filesystem blocks quota limit grace files quota limit grace
/Dev/sdb1 251200*100000 300000 6 days 3 0 0

 

 

Summary:

Quotacheck [-gubcfinvdMmR] [-F quota-format]-a | filesystem

-A: Check all the file systems attached to the/etc/mtab.

-U only checks the user's quota

-G: Only checks the quota of the user group.

Quota

Query the quota information of the current user without using any parameters

-U username: query the quota information of a user.

-G groupname: queries the quota information of a user group.

Edquota

-U username: edit the quota configuration of a user

-G groupname: edit the quota configuration of a user group

-T edit the warning time Configuration


Another comprehensive query command is

Repquota

-A reports all file systems supporting quota

-U reports user-specific quota Information

-G Package's quota information for the group

Generally, three parameters are used together.

[Root @ localhost test] # repquota-aug
* ** Report for user quotas on device/dev/sdb1
Block grace time: 7 days; Inode grace time: 7 days
Block limits File limits
User used soft hard grace
----------------------------------------------------------------------
Root -- 20 0 0 2 0 0
Quota1 +-200000 100000 200000 6 days 2 0 0
Quota2 -- 51200 0 0 1 0 0


* ** Report for group quotas on device/dev/sdb1
Block grace time: 7 days; Inode grace time: 7 days
Block limits File limits
Group used soft hard grace
----------------------------------------------------------------------
Root -- 20 0 0 2 0 0
Myquota +-251200 100000 300000 7 days 3 0 0

 

 

 

 

 


 


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.