Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1100663
  • 博文数量: 414
  • 博客积分: 10030
  • 博客等级: 上将
  • 技术积分: 4440
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-05 21:42
文章分类

全部博文(414)

文章存档

2011年(1)

2009年(1)

2008年(412)

我的朋友

分类: LINUX

2008-10-12 10:23:05

磁盘配额
n 功能
使用磁盘配额,系统管理员可以对磁盘空间进行管理,对不同
用户在文件和磁盘容量上加以限制,这样就能有效的利用磁盘
有限的容量。
n 磁盘配额的两种磁盘管理方式
1.基于文件inode的磁盘管理
2.基于磁盘存储块的磁盘管理
n 特点
磁盘配额是在每个用户,每个文件系统的基础上被处理的
磁盘配额的配置步骤
  1、修改/etc/fstab文件,在对应的分区上加用户配额(usrquota)或组配额(grpquota)。
  2、重新挂载分区,使其配额参数生效。
  3、创建配额数据库文件。aquota.user,aquota.group
  4、设置用户配额。edquota -u username
     设置组配额。  edquota -g groupname
  5、激活配额。    quotaon -a
     禁用配额。    quotaoff -a
  6、测试配额。 
[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: 没有那个文件或目录
quotacheck: Cannot stat old group quota file: 没有那个文件或目录
quotacheck: Cannot stat old user quota file: 没有那个文件或目录
quotacheck: Cannot stat old group quota file: 没有那个文件或目录
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 个块
输出了 1+0 个块
[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 ,
[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

阅读(798) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~