Linux Disk quota Application

Source: Internet
Author: User
Tags disk usage

    1. Disk quotas
      1. The site service will generally set quota limits for the site service domain name space;

      2. The Mail service sets the disk quota limit for each mailbox user in the mail service;

      3. The file service sets a quota limit for each user for the file server;

      4. Home directory Set disk quota limits for home directories

      5. Other services such as NFS and FTP;

      6. Quota Introduction

        What is quota? What is disk quotas? In the Linux operating system, because it is a multi-person working environment, multiple users use a partition, in the quota-free system, occupy more storage users will encroach on other users ' storage rights, causing other users to inconvenience, and disk quotas to solve this problem, Set disk quotas in the root environment via the quota command;

      7. Quota main application Environment

    2. Quota related directives

2.1. Quota directive

Quota--Display disk usage and restrictions

Parameters:

-G Displays the group quota limit for the group in which the user resides

-U Displays the current user's quota limit by default, and the specified user displays the user quota limit;

-V displays quota limits on the file system, even if no space is occupied

-Q Displays only file systems that exceed the quota

Only root can use the-u parameter, and a normal user can use the-G parameter to view the quota limits of the user's group;


2.2, Quotacheck scan file system, create, detect, repair quota files;

Parameters:

-D enters the debug state. This produces a lot of information for debugging programs. The output information is very detailed and the scanning speed slows down;

-A If you replace any file system name with it, Quotacheck will detect all the quotas listed in/etc/mtab as a writable file system. By default, only file systems that are listed as quotas in/etc/mtab are detected.

-U detects only the user quotas in the file system listed or specified in/etc/mtab. This is the action taken by default

-R when used with-a, detects all other file systems outside the root (root) file system.

-I interactive mode. In the default state, Quotacheck exits when an error is found. In interactive mode, the user is asked for advice. Reference option-N.

-N Sometimes multiple results are found for the same ID. This is usually the case when Quotacheck is terminated. This option enforces the first result (which is also valid in interactive mode).

2.3. Edquota-Edit User quotas

Parameters:

-U edit the user quota. This is the default option.

-G Edit Group quotas.

-P doubles the original quota for each specified user/group. This is a common method used to initialize quotas for a set of users/groups.

Files (related documents)

The Aquota.user or Aquota.group quota file located under the root of the file system.

/etc/mtab Mounted File system tables

2.4. Quotaon---Turn off file system quotas

Parameters:

-e Opens the specified file system quota. This option is the default when the program name is Quotaon.

-D closes the specified file system quota. This option is the default when the program name is Quotaoff.

-A when used in any file system name, Quotaon/quotaoff will allow/disallow all file systems specified in/etc/mtab to be read-write with disk quotas. This option is typically used to turn on quotas when the system starts.

-V displays a message for each file system that has quotas turned on or off.

-U handles user quotas. This is the default option.

-G processing Group quotas.

Related Documents (Files)

Aquota.user user quota file under the root directory of the file system

Aquota.group the group quota file under the root directory of the file system

/etc/mtab Mounted File system tables

Quotaoff Shutdown File System quotas

Parameters:

Same as in Quotaon

Third, the home partition to disk quota limit

3.1, because the quota for the partition, in order to experience account management and authority management, mount a new partition, for home migration;

1)/home partition migration

2) disk quota limit for home partition;

3) Set the user quota;

4) Edit the quota available for the group;

5) Set boot quota;

6) Requota Display quota information

3.2./home Partition Migration

1) Back up the home partition;

[Email protected]/]# Mkdir/homebak

[Email protected]/]# cp-a/home/*/homebak/


2) format SDB for EXT4;

[Email protected] ~]# fdisk l

disk/dev/sdb:53.7 GB, 53687091200 bytes

255 heads, Sectors/track, 6527 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x00000000


[Email protected]/]# ls-la/dev/sdb*

BRW-RW----. 1 root disk 8, 16 February 20:19/dev/sdb

BRW-RW----. 1 root disk 8, 17 February 20:19/DEV/SDB1

[Email protected]/]# MKFS.EXT4/DEV/SDB1

3) Establish/DEV/SDB1 quota support;

[Email protected]/]# Vi/etc/fstab

Add to

/dev/sdb1/home ext4 Defaults,userquota,grpquota 0 0

4) mount the SDB1 under/home

[email protected]/] #rm rf/home/*

[email protected]/] #mount/dev/sb1/home

[email protected]/] #cp a/homebak/*/home/

[email protected]/] #mount a

[[email protected] ~]# DF H

Filesystem Size used Avail use% mounted on

/dev/mapper/vg_woon-lv_root 8.3G 4.0G 4.0G 51%/

Tmpfs 504M 72K 504M 1%/DEV/SHM

/DEV/SDA1 477M 27M 426M 6%/boot

/dev/sde1 459G 70M 435G 1%/opt/gpt1

/DEV/SDB1 50G 52M 47G 1%/Home


Note: If the partition is already mounted, you can use Mount O remount/dev/sdb1

[Email protected] ~reboot

The kung fu of smoking a bag of cigarettes ...

5) Generate Quota file

Because SELinux affects quota, the SELinux is turned off first

[Email protected] ~]# Setenforce 0

[Email protected] ~]# Getenforce

[Email protected] ~]# Quotacheck

See if quota files are generated;

[Email protected] home]# Ll/home

Total Dosage 48

-RW-------. 1 root root 7168 February 21:03 aquota.group

-RW-------. 1 root root 7168 February 21:03 aquota.user

DRWX------. 4 hchen hchen 4096 February 21:02 Hchen

DRWX------. 2 root root 16384 February 20:23 lost+found

DRWX------. 4 Woon woon 4096 February 9 17:52 Woon

DRWX------. 4 Woonli Woonli 4096 February 20:39 Woonli

DRWX------. 4 Zwen zwen 4096 February 21:02 Zwen

6) Start Quota

[Email protected] home]# Quotaon-avug

/DEV/SDB1 [Home]: Group quotas turned on

/DEV/SDB1 [Home]: User quotas turned on

    1. Edit quotas

    2. Set user Woon, Zwen, and Hchen disk mates soft to 50m,hard to 55M

[Email protected] home]# Edquota-u Woon

Disk quotas for User Woon (UID 500):

Filesystem blocks soft hard inodes soft hard

/DEV/SDB1 40 51200 61440 10 0 0

[Email protected] home]# Edquota p woon hchen

[[email protected] home] #edquota p Woon Zwen

#复制账户woon的quota给账户zwen和hchen;

8) Set grace time to 3 days

[Email protected] home]# 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 3days 7days

9) set up group quotas

[Email protected] home]# Edquota–g Woon

^^^^^^^^^^^^^^^^^^^^^^^^

View quota set result record

[Email protected] ~]# Repquota-av

Report for user quotas on DEVICE/DEV/SDB1

Block Grace Time:3days; Inode Grace Time:7days

Block Limits Filelimits

User used soft hard grace used soft hard grace

----------------------------------------------------------------------

Root--50500 0 0 10975 0 0

Woon--8552 51200 61440 218 0 0

Woonli--36 0 0 9 0 0

Hchen--32 51200 61440 8 0 0

Zwen--32 51200 61440 8 0 0

#1000--2224 0 0 59 0 0

Statistics:

Total Blocks:8

Data blocks:1

Entries:6

Used average:6.000000

iv. Verification ofquota

[Email protected] woon]# Su–woon

[[email protected] ~]$ DD If=/dev/zero of=/home/woon/fileddbs=1m count=100

sdb1:warning, user block quota exceeded.

Sdb1:write failed, user block limit reached.

DD: is writing "/home/woon/filedd": disk limit exceeded

recorded the 59+0 the read- in

recorded the 58+0 the Writing

61665280 bytes (MB) has been copied, 0.0753227 seconds, 819 MB / seconds

Disk quota exceeded

[Email protected] ~]$ du-h Filedd

59M Filedd

[Email protected] ~]$ du-h |tail-1

60M


Linux Disk quota Application

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.