前期准备:

  1. root账户,alice账户
  2. 划出一块磁盘空间c0t0d0s7

实验目标:使用root账户为alice账户在/export/home/下,设定磁盘配额。

实验步骤:

  1. 编辑/etc/vfstab文件,把之前划出的磁盘,挂载到/export/home/下,挂载选项为rq
    1. -bash-3.00# more /etc/vfstab  
    2. #device         device          mount           FS      fsck    mount   mount  
    3. #to mount       to fsck         point           type    pass    at boot options  
    4. #  
    5. fd      -       /dev/fd fd      -       no      -  
    6. /proc   -       /proc   proc    -       no      -  
    7. /dev/dsk/c0t0d0s1       -       -       swap    -       no      -  
    8. /dev/dsk/c0t0d0s0       /dev/rdsk/c0t0d0s0      /       ufs     1       no      -  
    9. /dev/dsk/c0t0d0s7       /dev/rdsk/c0t0d0s7      /export/home    ufs     2       yes rq   
    10. /devices        -       /devices        devfs   -       no      -  
    11. sharefs -       /etc/dfs/sharetab       sharefs -       no      -  
    12. ctfs    -       /system/contract        ctfs    -       no      -  
    13. objfs   -       /system/object  objfs   -       no      -  
    14. swap    -       /tmp    tmpfs   -       yes     - 
  2. 重新挂载文件系统
    1. -bash-3.00# mount -o remount /export/home 
  3. 在/export/home/下创建quotas文件,设定只有root可以访问。是为了其他用户修改!
    1. -bash-3.00# touch quotas  
    2. -bash-3.00# chmod 600 quotas   
    3. -bash-3.00# ls -l  
    4. 总数 18  
    5. drwxr-xr-x  15 alice    other       1024  7月 18日 10:34 alice  
    6. drwx------   2 root     root        8192  7月 12日 15:40 lost+found  
    7. -rw-------   1 root     root           0  7月 21日 01:01 quotas 
  4. 编辑alice用户配额项
    1. -bash-3.00# edquota alice  
    2. "/tmp/EdP.a6JayDc" 1行,72个字符   
    3. fs /export/home blocks (soft = 500hard = 300) inodes (soft = 3hard = 5
  5. 查看alice配额项
    1. -bash-3.00# quota -v alice  
    2. Disk quotas for alice (uid 100):  
    3. Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft  
    4. /export/home       0    500    300                  0      3      5        
  6. 对文件系统开启配额
    1. -bash-3.00# quotaon -av      
    2. /export/home: quotas turned on 
  7. 用alice用户登录查看效果
    1. -bash-3.00$ mkfile 100m file1  
    2. quota_ufs: Warning: over disk limit (pid 1321, uid 100, inum 234, fs /export/home)  
    3. -bash-3.00$ mkfile 100m file2  
    4. -bash-3.00$ mkfile 100m file3  
    5. quota_ufs: Warning: too many files (pid 1331, uid 100, fs /export/home)  
    6. -bash-3.00$ mkfile 100m file4  
    7. -bash-3.00$ mkfile 100m file5  
    8. quota_ufs: over file hard limit (pid 1335, uid 100, fs /export/home)  
    9. Could not open file5: Disc quota exceeded  
    10. -bash-3.00$ ls -l  
    11. 总数 819722  
    12. drwxr-xr-x   2 alice    other        512  7月 18日 06:35 Desktop  
    13. drwxr-xr-x   2 alice    other        512  7月 18日 06:35 Documents  
    14. -rw-------   1 alice    other    104857600  7月 21日 01:12 file1  
    15. -rw-------   1 alice    other    104857600  7月 21日 01:13 file2  
    16. -rw-------   1 alice    other    104857600  7月 21日 01:13 file3  
    17. -rw-------   1 alice    other    104857600  7月 21日 01:13 file4  
    18. -rw-r--r--   1 alice    other        136  7月 17日 15:14 local.cshrc  
    19. -rw-r--r--   1 alice    other        157  7月 17日 15:14 local.login  
    20. -rw-r--r--   1 alice    other        174  7月 17日 15:14 local.profile 

软限制可以暂时超过,硬限额不可超过!

  1. -bash-3.00# quota -v alice
    Disk quotas for alice (uid 100):
    Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft
    /export/home  409856    300 5555500                  4      3      5  
  2.