技术活动
CUUG学员就业信息
学员感言、就业资讯
报名热线
文档
当前您的位置:首页 > 技术活动 > 技术中心 > 文档
AIX 磁盘限额的配置-CUUG

  操作系统版本:

  testterm1:/#oslevel -r

  5300-00

  磁盘限额系统,它基于Berkeley磁盘限额系统,提供了控制使用磁盘空间的有效方式。为个人用户或组定 义限额系统,并且为每一类文件系统维护限额系统。

  磁盘限额系统基于下列参数建立限额,可使用eduqota命令更改这些参数:

  . 用户或组的软限额

  . 用户或组的硬限额

  . 限额宽延时间

  1、为某个文件系统启用用户和组限额,使用chfs命令。(本文以/home文件系统为例)

  testterm1:/#chfs -a "quota=userquota,groupquota" /home

  上述命令实质是在/etc/filesystems文件中/home文件系统定义节中增加了quota字段,如下红色部分:

  /home:

  dev = /dev/hd1

  vfs = jfs

  log = /dev/hd8

  mount = true

  check = true

  vol = /home

  free = false

  quota = userquota,groupquota

  2、指定磁盘限额文件名称

  quota.user和quota.group文件名称是缺省名称,位于已应用磁盘限额文件系统的根目录下。

  testterm1:/#chfs -a "userquota=/home/myquota.user" -a "groupquota=/home/myquota.group" /home

  上述命令实质是在/etc/filesystems文件中/home文件系统定义节中增加了userquota和groupquota字段, 如下红色部分:

  /home:

  dev = /dev/hd1

  vfs = jfs

  log = /dev/hd8

  mount = true

  check = true

  vol = /home

  free = false

  quota = userquota

  userquota = /home/myquota.user

  groupquota = /home/myquota.group

  3、产生磁盘限额文件

  testterm1:/home#quotacheck -a -v

  *** Checking user and group quotas for /dev/hd1 (/home)

  Creating quota file /home/myquota.user

  /home: root fixed: inodes 0 -> 784 blocks 0 -> 2100834

  /home: bin fixed: inodes 0 -> 1 blocks 0 -> 1

  /home: guest fixed: inodes 0 -> 1 blocks 0 -> 1

  /home: netinst fixed: inodes 0 -> 20 blocks 0 -> 57

  /home: hlrterm fixed: inodes 0 -> 493 blocks 0 -> 42386

  /home: quan fixed: inodes 0 -> 2 blocks 0 -> 2

  /home: 1000 fixed: inodes 0 -> 111 blocks 0 -> 1234

  /home: 4050-109 User id 4294967294 (nobody) is too large, quotas are not maintained

  Creating quota file /home/myquota.group

  /home: system fixed: inodes 0 -> 787 blocks 0 -> 2100853

  /home: staff fixed: inodes 0 -> 22 blocks 0 -> 58

  /home: bin fixed: inodes 0 -> 1 blocks 0 -> 1

  /home: usr fixed: inodes 0 -> 1 blocks 0 -> 1

  /home: hlrterm fixed: inodes 0 -> 490 blocks 0 -> 42368

  /home: 513 fixed: inodes 0 -> 111 blocks 0 -> 1234

  /home: 4050-109 User id 4294967294 (nobody) is too large, quotas are not maintained

  此时会在/home文件系统根目录下产生myquota.user和myquota.group两个文件:

  testterm1:/home#ls -l /home/myquota*

  -rw-r----- 1 root system 16448 Aug 15 22:15 /home/myquota.group

  -rw-r----- 1 root system 32032 Aug 15 22:15 /home/myquota.user

  每次修改限额配置之后,一定要执行quotacheck -a -v 命令。

  4、设置磁盘限额对某个用户生效(本文以quan用户为例)

  testterm1:/#edquota -u quan

  修改相应的值,保存退出。

  注:组可用-g参数。

  5、查看某个文件系统中对用户磁盘限额情况(本文以/home文件系统为例)

  testterm1:/#repquota -u /home

  Block limits File limits

  User used soft hard grace used soft hard grace

  root -- 2100834 0 0 784 0 0

  bin -- 1 0 0 1 0 0

  guest -- 1 0 0 1 0 0

  netinst -- 57 0 0 20 0 0

  hlrterm -- 42386 0 0 493 0 0

  quan -- 2 10240 10290 2 5 55

  1000 -- 1234 0 0 111 0 0

  上述结果可知,quan用户磁盘限额为10240KB(即10M),最大可建立5个文件。

  注:组可用-g参数。

  6、在系统启动后自动检测并打开磁盘限额

  修改/etc/rc 文件,在结尾增加以下行:

  echo "Starting Disk Quota Service…"

  /usr/sbin/quotacheck -a

  /usr/sbin/quotaon -a

  echo "Disk Quota started! "

  7、用户磁盘限额配置复制

  要为用户test建立限额,用已经为用户quan建立好的限额作为原型,可输入:

  testterm1:/#edquota -u -p quan test

  检查是否成功复制:

  testterm1:/#repquota -u /home

  Block limits File limits

  User used soft hard grace used soft hard grace

  root -- 2100834 0 0 784 0 0

  bin -- 1 0 0 1 0 0

  guest -- 1 0 0 1 0 0

  netinst -- 57 0 0 20 0 0

  hlrterm -- 42386 0 0 493 0 0

  test -- 2 10240 10290 2 5 55

  quan -- 2 10240 10290 2 5 55

  1000 -- 1234 0 0 111 0 0

  由红分部分可知,磁盘限额已成功复制。

  8、使quota生效

  quotaon /home