Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux limits the use of disk space by users or groups

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Experimental environment: centos7.3, a disk SDB is divided into a partition sdb1. Install the disk quota support software yum install quota to create a file system, and mount the file system mkfs.ext4 / dev/sdb1mount / dev/sdb1 / tmpmount-o remount,usrquota,grpquota / dev/sdb1 to check whether disk quota technology is enabled during disk mount. Mount if you want to mount permanently (need to be in the configuration file Add these two parameters to usrquota,grpquota) vim / etc/fstab/dev/sdb1 / tmp ext4 defaults,usrquota,grpquota 0 detects disk quotas and generates quota files (if there is an error, close se linux) quotacheck-cugv / tmp # this command generates two files under / tmp # explain:-c create quota files,-u (- g) scan disk space Calculate the number of directories and files occupied by each user (group) identification code,-a scan in the / etc/fstab file, there are partitions set by quota,-d shows the instruction execution process in detail, easy to debug. -R excludes the quota setting for users and group accounts in the partition where the root directory is located. Useradd wsfnk # create a user first. If there is any, you do not need to create edquota-u wsfnk #-g to represent the wsfnk group. In an interface similar to vim, edit the limit size. Disk quotas for user wsfnk (uid 1000): Filesystem blocks soft hard inodes soft hard / dev/sdb1 0 20 50 100 # explain the fields as follows: # Filesystem shows the partitions that achieve disk quota # blocks is the currently used size and does not need to be modified; # soft is a soft limit, and a warning is given after the limit is exceeded, and the excess is saved for 7 days by default; # hard is a hard limit and an insurmountable limit (the default unit for both soft and hard limits is KB); # the following two identical soft and hard represent the soft and hard limits on the number of files that this user can create in the partition, respectively # in this example, qingsword can use the soft limit size 10KB of the / dev/sdb1 partition and the hard limit 20KB. The soft limit of the number of files that can be created is 3, and the hard limit is 5 Edquota parameter-u: set the user's quta, which is the default parameter-g: set the quota-p source user name of the group: apply the source user's quota settings to other users or groups-t: set grace period activation disk quota quotaon-ugv / tmp

Note: the blocks in disk quota is not the blocks seen in fdisk, but represents 1k

Test whether the limit will take effect mkdir / tmp/testchmod 777 / tmp/test switch user wsfnksu wsfnkcd / tmp/testdd if=/dev/zero of=wss.test bs=1k count=500 turn off disk quotas # turn off disk quotas for a single disk quotaoff / sdb1# turn off all disk quotas quotaoff-a # conversely, turn on all disk quotas quotaon-a # if disk quotas are no longer used You can also delete the configuration file rm-rf / sdb1/aquota.*# and finally delete the auto-mount in / etc/fstab.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report