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