在 CentOS 中如果已經加裝好一棵切為 ext3 格式的硬碟後要如何在這棵硬碟上啟動 Quota 功能?我新增加的硬蝶編號為 hdc 是掛在主機版的 Second IDE2 介面,硬碟的 Jump 是調 Master 所以編號是 hdc,若是裝在主機版的 Primery IDE1 硬碟的編號就會是 Master -> hda、Slave -> hdb。
# df # 可先查看我已經掛載的硬碟 Partition
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
11712616 1317836 9790212 12% /
/dev/hda1 101086 18120 77747 19% /boot
tmpfs 257140 0 257140 0% /dev/shm
/dev/hdc1 28389472 40076 26883868 1% /rhome
# vi /etc/fstab # 調整 fstab 針對這個獨立切出來的 Partition 加上 usrquota 及 grpquota
/dev/hdc1 /rhome ext3 defaults,usrquota,grpquota 1 2
# mount -o remount /rhome # 重新 mount 讓新的設定值生效
# mount # 查看 /rhome 這個 Partition 是否已經有 usrquota 及 grpquota
/dev/hdc1 on /rhome type ext3 (rw,usrquota,grpquota)
# quotacheck -cug /rhome # 初始化 quota 會比較久要等一下
# ls -l /rhome # rhome 目錄下會多出兩個檔
total 68
-rw------- 1 root root 7168 Oct 3 12:41 aquota.group
-rw------- 1 root root 7168 Oct 3 12:36 aquota.user
# quotaon -ug /rhome # 啟動 quota
# edquota -u justin # 針對 justin 這個 User 做 Quota 設定 ( 設定 Qouta 時權限要 root 才能生效 )
Disk quotas for user justin (uid 30000):
Filesystem blocks soft hard inodes soft hard
/dev/hdc1 7200 0 0 6 0 0
# edquota -g 30000 # 針對 Group 30000 做 Quota 設定
Disk quotas for group 30000 (gid 30000):
Filesystem blocks soft hard inodes soft hard
/dev/hdc1 24 8192 10240 6 50 60
# su - justin # 切換到 justin 這個 User
$ quota -g 30000 # 查看 Group 30000 原本所使用的容量 bloks 為 24
Disk quotas for group Justin Lin (gid 30000):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdc1 24 8192 10240 6 50 60
$ dd if=/dev/zero of=test bs=1M count=7 # 手動建立一個 7 M 大的 test 檔案
7+0 records in
7+0 records out
7340032 bytes (7.3 MB) copied,0.0581825 秒,126 MB/s
$ quota -g 30000 # 查看 Group 30000 所使用的容量 bloks 已經增加到 7204
Disk quotas for group Justin Lin (gid 30000):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdc1 7204 8192 10240 7 50 60
$ dd if=/dev/zero of=test2 bs=1M count=4 # 再建個 test2 的檔大小為 4M , 因為超出 10M 空間所以系統告知滿了
hdc1: warning, group block quota exceeded.
hdc1: write failed, group block limit reached.
dd: 寫入 ‘test2’: 硬碟 quota 滿了
3+0 records in
2+0 records out
3104768 bytes (3.1 MB) copied,0.0264653 秒,117 MB/s
$ quota -g 30000 # 查看 Group 30000 滿了 blocks 會多個 * 號
Disk quotas for group Justin Lin (gid 30000):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdc1 10240* 8192 10240 8 50 60
Reference:
http://ms.ntcb.edu.tw/~steven/article/quota.htm
2008/10/03
[ LOS ] CentOS Enable Hard Disk Quota
訂閱:
張貼意見 (Atom)


0 意見:
張貼意見