[Linux] -- Advanced file system management, linux System Management

Source: Internet
Author: User

[Linux] -- Advanced file system management, linux System Management
 This is my first blog. If there is anything wrong or wrong, please kindly advise me !!!

 

I. Concept of Disk Quota

 

Because Linux is a multi-user-managed operating system, by default, Linux does not limit the disk space used by each user. If a user is negligent or maliciously occupying the disk space, this will cause the system disk to fail to be written to or even crash. To ensure sufficient space on the system disk, We need to restrict the disk space usage of users and groups.

 

Disk quota limit type:

1. Restrict the disk space used by users and groups

2. restrict the number of files created by users and groups on the disk

 

Disk quota limit level:

 

Note: The disk quota is set for partitions, "A user can only use 50 MB of disk space in the system" cannot be implemented. Only a user can use 30 mb of disk space in the/home partition. Remember: the disk quota is for partitions!

 

Ii. Disk Quota enabling conditions

 

Does the Kernel support disk quotas?

# Grep "CONFIG_QUOTA"/boot/config-2.6.32-431.el6.x86_64

 

Is the disk quota command installed?

# Rpm-q quota

 

Iii. Disk Quota experiment plan

 

Prepare sufficient partitions, which is much larger than the required experiment space.

Create lab users and groups

Users: cj, bd, xz,

GROUP: thot

Disk Quota Planning

Thot: Hard: 500 M soft: 450 M no limit on the number of files

Cj: Hard: 50 M soft: 40 M hard: 10 soft: 8

Bd: Hard: 250 M soft: 200 M no limit on the number of files

Xz: Hard: 250 M soft: no limit on the number of 200 M Files

Change the number of days to 8

 

Iv. Disk Quota experiment process

# Grep "CONFIG_QUOTA"/boot/config-2.6.32-431.el6.x86_64

 

2. Check whether the Mount attribute of the partition meets the requirements.

Dumpe2fs-h/dev/sdb1 | grep "Default mount options"

Check whether the Mount attributes usrquota and kgquota are included in the result?

If there are no two Mount attributes, you need to re-mount and add two attributes, and write them to the automatic Mount

 

3. Create partitions, users, and user groups

The partition size is much larger than the size required by the experiment to avoid affecting the experiment results.

Users: cj, bd, and xz

GROUP: thot

Note: When creating a user, specify thot as the initial group.

 

4. generate configuration files for users and groups

Partition name of the quotacheck Option

-A scans all partitions in the/etc/mtab file that enable the disk quota function. If this parameter is added, you do not need to add the partition name after the command.

-U: create a user quota configuration file, that is, generate aquota. user

-G: the configuration file for creating the group quota, that is, aquota. group.

-V shows the scanning process

-C. Clear the original configuration file and create a new configuration file.

Note: if an error is reported and you do not have the permission to generate a file, disable SELinux.

 

5. Edit the configuration file and set the specified size limit.

Edquota option user name or group name

-U User Name

-G group name

-T: Set the grace period.

-P: copy the disk quota rule, which does not need to be set manually by every user or group.

# Edquota-p template user-u target user

Note: The default size written in the configuration file is KB.

 

6. Disk Quota for startup and Shutdown

Start:

Quotaon option partition name

-A starts the disk quota of all partitions Based on the/etc/mtab file (No partition name is written)

-U disk quota for the user to start

-G disk quota of the Startup Group

-V: displays the startup process information.

Close:

Quotaoff option partition name

-A: Disable the disk quota of all partitions Based on the/etc/mtab file (No partition name is written)

-U: Disable the user's disk quota.

-G disk quota of the close group

-V: displays the startup process information.

 

7. view disk quota Information

Query the quota of a specified user and group:

Quota option user or group name

-U User Name

-G group name

-V: Show Details

-S shows the size in common units

8. query the disk quota of a specified partition:

Repquota option partition name

-U: Query user quota

-G: Query group quota

-V: display details

-S is displayed in common units

 

9. Verify that the disk quota takes effect

Switch to the execution user to create a file (su) as the preset user identity)

Test tool:

Dd generates a file of the specified size (for details about the dd command, see the attachment)

Dd if =/dev/zero of =/partition name/testfile bs = 1 M count = 60

Note: The user's test needs to switch to the specified user identity, while the Group Disk Quota needs to be verified?

 

10. non-interactive Disk Quota settings

Setquota-u user name soft (volume) Hard (volume) soft (number) Hard (number) Partition name

Note: Similarly, such non-interactive commands are more suitable for writing scripts. If many users share the same disk quota configuration, they can also be copied.

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.