- 論壇徽章:
- 0
|
磁盤配額
n 功能
使用磁盤配額,系統(tǒng)管理員可以對(duì)磁盤空間進(jìn)行管理,對(duì)不同
用戶在文件和磁盤容量上加以限制,這樣就能有效的利用磁盤
有限的容量。
n 磁盤配額的兩種磁盤管理方式
1.基于文件inode的磁盤管理
2.基于磁盤存儲(chǔ)塊的磁盤管理
n 特點(diǎn)
磁盤配額是在每個(gè)用戶,每個(gè)文件系統(tǒng)的基礎(chǔ)上被處理的
磁盤配額的配置步驟
1、修改/etc/fstab文件,在對(duì)應(yīng)的分區(qū)上加用戶配額(usrquota)或組配額(grpquota)。
2、重新掛載分區(qū),使其配額參數(shù)生效。
3、創(chuàng)建配額數(shù)據(jù)庫(kù)文件。aquota.user,aquota.group
4、設(shè)置用戶配額。edquota -u username
設(shè)置組配額。 edquota -g groupname
5、激活配額。 quotaon -a
禁用配額。 quotaoff -a
6、測(cè)試配額。
[root@client67 ~]# vi /etc/fstab
[root@client67 ~]# head /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/1 / ext3 defaults,usrquota,grpquo 1 1
LABEL=/boot1 /boot ext3 defaults 1 2
LABEL=/data /data ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/u01 /u01 ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0
[root@client67 ~]# mount
/dev/sda5 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /boot type ext3 (rw)
/dev/sda3 on /data type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda2 on /u01 type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/proc on /var/named/chroot/proc type none (rw,bind)
/dev/sda7 on /media/sda7 type ext3 (rw)
[root@client67 ~]# mount -o remount /
[root@client67 ~]# mount |grep sda5
/dev/sda5 on / type ext3 (rw,usrquota,grpquota)
[root@client67 ~]# quotacheck -mcvugf /
quotacheck: Scanning /dev/sda5 [/] quotacheck: Cannot stat old user quota file: 沒(méi)有那個(gè)文件或目錄
quotacheck: Cannot stat old group quota file: 沒(méi)有那個(gè)文件或目錄
quotacheck: Cannot stat old user quota file: 沒(méi)有那個(gè)文件或目錄
quotacheck: Cannot stat old group quota file: 沒(méi)有那個(gè)文件或目錄
done
quotacheck: Checked 15796 directories and 118640 files
quotacheck: Old file not found.
quotacheck: Old file not found.
[root@client67 ~]# ls /
aquota.group boot etc lib misc proc selinux tftpboot usr
aquota.user data home lost+found mnt root srv tmp var
bin dev initrd media opt sbin sys u01
[root@client67 ~]# useradd abc
useradd: user abc exists
[root@client67 ~]# useradd xyz
[root@client67 ~]# edquota -u xyz
[root@client67 ~]#
[root@client67 ~]# quotaon /
[root@client67 ~]# quotastats
Kernel quota version: 6.5.1
Number of dquot lookups: 81
Number of dquot drops: 1
Number of dquot reads: 6
Number of dquot writes: 0
Number of quotafile syncs: 20
Number of dquot cache hits: 75
Number of allocated dquots: 6
Number of free dquots: 0
Number of in use dquot entries (user/group): 6
[root@client67 ~]# su - xyz
[xyz@client67 ~]$ whoami
xyz
[xyz@client67 ~]$ dd if=/dev/zero of=file1 bs=1024k count=1
sda5: warning, user block quota exceeded.
讀入了 1+0 個(gè)塊
輸出了 1+0 個(gè)塊
[xyz@client67 ~]$ quota
Disk quotas for user xyz (uid 8893):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda5 1032* 1000 1500 7days 1 5 8
[xyz@client67 ~]$ touch a b c d e
sda5: warning, user file quota exceeded.
[xyz@client67 ~]$
[xyz@client67 ~]$ quota
Disk quotas for user xyz (uid 8893):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda5 1052* 1000 1500 6days 6* 5 8 7days
[xyz@client67 ~]$ touch f g h i
sda5: write failed, user file limit reached.
touch: cannot touch ‘h’: 超出磁盤限額
touch: cannot touch ‘i’: 超出磁盤限額
[xyz@client67 ~]$ quota
Disk quotas for user xyz (uid 8893):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda5 1060* 1000 1500 6days 8* 5 8
[xyz@client67 ~]$ ls
a b c d e f file1 g
[xyz@client67 ~]$ exit
logout
[root@client67 ~]# repquota
Bad number of arguments.
repquota: Utility for reporting quotas.
Usage:
repquota [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint)
Bugs to
mvw@planets.elm.net
,
jack@suse.cz
[root@client67 ~]# repquota -a
*** Report for user quotas on device /dev/sda5
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 3225436 0 0 134168 0 0
daemon -- 20 0 0 3 0 0
lp -- 8 0 0 1 0 0
rpm -- 42940 0 0 111 0 0
netdump -- 16 0 0 2 0 0
rpcuser -- 8 0 0 1 0 0
smmsp -- 16 0 0 2 0 0
apache -- 24 0 0 3 0 0
squid -- 16 0 0 2 0 0
webalizer -- 32 0 0 4 0 0
xfs -- 4 0 0 1 0 0
ntp -- 16 0 0 2 0 0
htt -- 28 0 0 4 0 0
quagga -- 40 0 0 5 0 0
amanda -- 1096 0 0 58 0 0
named -- 112 0 0 14 0 0
ldap -- 8 0 0 1 0 0
gdlc -- 104 0 0 13 0 0
hesx -- 12 0 0 2 0 0
test -- 96 0 0 12 0 0
test2 -- 96 0 0 12 0 0
xyz ++ 1060 1000 1500 6days 8 5 8 6days
#500 -- 476 0 0 14 0 0
[root@client67 ~]#
本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u/23204/showart_692925.html |
|