歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux用戶磁盤配額Quota設置流程

Linux用戶磁盤配額Quota設置流程

日期:2017/2/28 15:48:43   编辑:Linux教程

第一步:創建用戶,用戶組

腳本:

  1. #!/bin/bash
  2. groupadd quotagrp
  3. for username in quota1 quota2 quota3 quota4 quota5
  4. do
  5. useradd -g quotagrp $username
  6. echo "password" |passwd --stdin $username
  7. done

第二步:由於quota只能針對文件系統進行配置,所以選擇支持的文件系統(ext2,ext3),編輯系統掛載配置文件/etc/fstab,在文件中對應的文件系統加入,usrquota,grpquota字樣,樣式如下:

Bash代碼

  1. LABEL=/home /home ext3
  2. defaults[color=red],usrquota,grpquota [/color] 1 2

第三步:重新掛載設置磁盤配額後的文件系統
Bash代碼

mount -o remount,usrquota,grpquota /home

第四步:新建quota配置文件,利用quotacheck檢查命令生成配置文件aquota.user,aquota.group,文件在文件系統根目錄下。

quotachck -avug -mf

第五步:設置用戶的磁盤限額,使用命令edquota -u username

  1. Block limits File limits
  2. User used soft hard grace used soft hard grace
  3. myquota1 -- 88 400000 500000 11 0 0

第六步:查看quota限制值報表,命令:rpquota -auvs,效果如下:

  1. *** Report for user quotas on device /dev/sda2
  2. Block grace time: 14days; Inode grace time: 7days
  3. Block limits File limits
  4. User used soft hard grace used soft hard grace
  5. ----------------------------------------------------------------------
  6. root -- 173M 0 0 4 0 0
  7. chenlixin -- 11832 0 0 481 0 0
  8. pro1 -- 168 0 0 21 0 0
  9. pro2 -- 160 0 0 20 0 0
  10. pro3 -- 80 0 0 10 0 0
  11. myquota1 -- 88 391M 489M 11 0 0
  12. myquota2 -- 80 391M 489M 10 0 0
  13. myquota3 -- 80 391M 489M 10 0 0
  14. myquota4 -- 80 391M 489M 10 0 0
  15. myquota5 -- 80 391M 489M 10 0 0
  16. quota1 -- 80 391M 489M 10 0 0
  17. quota2 -- 80 0 0 10 0 0
  18. quota3 -- 80 0 0 10 0 0
  19. quota4 -- 80 0 0 10 0 0
  20. quota5 -- 80 0 0 10 0 0
  21. Statistics:
  22. Total blocks: 8
  23. Data blocks: 1
  24. Entries: 15
  25. Used average: 15.000000
Copyright © Linux教程網 All Rights Reserved