RHCE6 Preperation (11) – Quota

来源:互联网 发布:天猫 淘宝商城男休闲鞋 编辑:程序博客网 时间:2024/05/05 06:12

Create quota for user alice and /home/alice, least/soft limit is 40K, when exceeding 80K, the system will display the exceeded the user quota.

1, check the kernel support the quota function,

[root@server4 home]# grep CONFIG_QUOTA /boot/config-2.6.32-358.6.1.el6.x86_64 CONFIG_QUOTA=yCONFIG_QUOTA_NETLINK_INTERFACE=y# CONFIG_QUOTA_DEBUG is not setCONFIG_QUOTA_TREE=yCONFIG_QUOTACTL=y[root@server4 home]# 

2, modify the /etc/fstab to activate the quota support for the /home folder,

[root@server4 home]# vim /etc/fstab 
add 'usrquota' and 'grpquota'

/dev/mapper/vgsrv-home  /home                   ext4    defaults,usrquota,grpquota        1 2
3, remount the file system, make the quota effective,

mount -o remount,usrquota,grpquota /home

4, use quotacheck command to generate the basic quota configuration file,

quotacheck -cugmv /home

5, activate the quota limitation,

quotaon /home

 6, use edquota command to configure the quota limit to specific user,

[root@server4 home]# edquota -u alice

modify the content to:

Disk quotas for user alice (uid 1004):  Filesystem                   blocks       soft       hard     inodes     soft     hard  /dev/mapper/vgsrv-home           80         40         80         12        0        0
here 40K as soft limit, 80K as hard limit.

7, use repquota to check the quota status,

[root@server4 home]# repquota /home*** Report for user quotas on device /dev/mapper/vgsrv-homeBlock grace time: 7days; Inode grace time: 7days                        Block limits                File limitsUser            used    soft    hard  grace    used  soft  hard  grace----------------------------------------------------------------------root      --   37945       0       0              5     0     0       lucy      --      16       0       0              8     0     0       student   --   38337       0       0            226     0     0       mary      --      20       0       0             10     0     0       alice     +-      80      40      80  7days      12     0     0       bobby     --      16       0       0              8     0     0       aclan     --      16       0       0              8     0     0 

8, test the result,

[root@server4 home]# su - alice[alice@server4 ~]$ dd if=/dev/zero of=file1 bs=1k count=50dm-3: warning, user block quota exceeded.50+0 records in50+0 records out51200 bytes (51 kB) copied, 0.00173795 s, 29.5 MB/s

here the file1 created successful, however there is a warning, if continue to create file, it will fail,

[alice@server4 ~]$ dd if=/dev/zero of=file2 bs=1k count=30dm-3: write failed, user block limit reached.dd: writing `file2': Disk quota exceeded9+0 records in8+0 records out8192 bytes (8.2 kB) copied, 0.00401174 s, 2.0 MB/s

file2 still created successful, but already reached 80K, if create another 1K file file3,

[alice@server4 ~]$ dd if=/dev/zero of=file3 bs=1k count=1dd: opening `file3': Disk quota exceeded





0 0
原创粉丝点击