Linux disk quota settings and usage

Source: Internet
Author: User

Concept

Limit the use of disk space for a user or a group

Conditions to implement disk quotas

Requires Linux kernel support

Installing the Quota Package

Features of Linux disk quotas

Scope: For the specified file system (partition)

Restricted objects: User accounts, group accounts

Restriction type:

Disk capacity (default is KB)

Number of files (node)

Restriction method:

Soft limit (out of range, can write, write will give warning)

Hard limit (out of range, cannot write)

Soft limit <= Hard limit

Experimental steps

⑴ Partitioning, formatting

[Email protected] ~]# Fdisk/dev/sdb
[Email protected] ~]# fdisk-l/DEV/SDB1


[Email protected] ~]# MKFS.EXT4/DEV/SDB1 #格式化分区


⑵ Close SELinux

[[email protected] ~]# Setenforce 0 #临时关闭seliux, otherwise quotacheck can not create the corresponding configuration file

⑶ writing automatic mount files

[[email protected] ~]# mkdir/mnt/sdb1# set up mount point
[Email protected] ~]# Vim/etc/fstab #编辑开机自动挂载配置文件

[[email protected] ~]# mount-a# automatically mount/etc/fstab file contents
[Email protected] ~]# df-h


[[email protected] ~]# chmod 777/mnt/sdb1/#修改挂载点目录 for easy testing

[Email protected] ~]# ll-d/mnt/sdb1/drwxrwxrwx. 3 root root 4096 June 05:59/mnt/sdb1/


⑷ detecting disk quotas and creating quota files

[Email protected] ~]# QUOTACHECK-CVUG/MNT/SDB1

-U,-G: Detect user, Group quotas

-C: Create a quota data file

-V: Displays execution process information

-A: detects all available partitions

[Email protected] ~]# ls/mnt/sdb1/#查看配置文件是否存在


⑸ Add users, edit quota settings for user or group accounts

[Email protected] ~]# useradd-u Lisi #添加lisi用户
[Email protected] ~]# passwd Lisi
[Email protected] ~]# edquota-u Lisi #针对lisi用户编辑配额设置


⑹ to turn on the file system quota function

[Email protected] ~]# quotaon-ugv/mnt/sdb1/

-A open in the/ect/fstab file, there is a space limit for the partition that joins the quota setting

-G Open Group disk space limit

-U open User's disk space limit

-V Show Instruction execution process

⑺ Switch User, write data test

[Email protected] ~]# Su-lisi #切换李四用户写入数据

① Test capacity limits

[[email protected] ~]$ dd If=/dev/zero of=/mnt/sdb1/myfile1.txt bs=10k count=40 #将无限制的产生0的数据写到myfile1. txt, simulation produces data



② Test node limits

[Email protected] ~]$ rm-rf/mnt/sdb1/my* #删除之前测试数据
[Email protected] ~]$ cd/mnt/sdb1/
[email protected] sdb1]$ touch A1 A2 A3 A4 A5
[email protected] sdb1]$ touch a6




Linux disk quota settings and usage

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.