2010年12月9日 星期四

同時新增多組帳號及Disk Quota limit的實驗 (四)

  • LAB C :


    7. 在 /dev/hda5 啟動 Disk Quota limit
    8. 實施Disk Quota limit usrer1 user2 兩個使用者帳號。
    9. /dev/hda5 soft limit 20MBhard limit 30 MB。
    10. usrer1 user2 兩個使用者帳號的家目錄Disk Quota limit 如下,soft limit 10MBhard limit 20 MB。
  • 操作步驟 :


    STEP 1. 於/home 所在檔案系統加上usrquota、grpquota 掛載選項  
    [root@lab-2 /]# mount -o remount,usrquota,grpquota /
    [root@lab-2 /]# mount | grep hdb2
    /dev/hdb2 on / type ext3 (rw,usrquota,grpquota)

STEP 2. 建立配額資料庫
[root@lab-2 ~]# quotacheck -ugvm /
quotacheck: Scanning /dev/hdb2 [/] done
quotacheck: Checked 15168 directories and 137285 files
[root@lab-2 ~]# quotacheck -ugvm /media/hdb5/
quotacheck: Scanning /dev/hdb5 [/media/hdb5] done
quotacheck: Checked 3 directories and 4 files
[root@lab-2 ~]#

          ※  第一次執行時因為 / /media/hdb5 目錄中均無配額資料庫檔 aquota.user
                 aquota.group 所以會出現錯誤訊息,然後系統會自動產生配額資料庫檔
[root@lab-2 ~]# quotacheck -ugvm /
quotacheck: Scanning /dev/hdb2 [/] done
quotacheck: Checked 15168 directories and 137285 files
[root@lab-2 ~]# quotacheck -ugvm /
quotacheck: Scanning /dev/hdb2 [/] quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
done
quotacheck: Checked 15168 directories and 137283 files
quotacheck: Old file not found.
quotacheck: Old file not found.
[root@lab-2 ~]# quotacheck -ugvm /media/hdb5/
quotacheck: Scanning /dev/hdb5 [/media/hdb5] quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
done
quotacheck: Checked 3 directories and 2 files
quotacheck: Old file not found.
quotacheck: Old file not found.
[root@lab-2 ~]# ls -l /aquota.* /media/hdb5/aquota.*
-rw------- 1 root root 8192 Dec 9 01:39 /aquota.group
-rw------- 1 root root 11264 Dec 9 01:39 /aquota.user
-rw------- 1 root root 6144 Dec 9 01:39 /media/hdb5/aquota.group
-rw------- 1 root root 6144 Dec 9 01:39 /media/hdb5/aquota.user

STEP 3. 啟動Disk Quota

[root@lab-2 ~]# quotaon / /media/hdb5

STEP 4. 設定 user1 user2 Disk Quota limit
[root@lab-2 /]# edquota -u user1
Disk quotas for user user1 (uid 506):
Filesystem blocks soft hard inodes soft hard
/dev/hdb2 76 10240 20480 10 0 0
/dev/hdb5 0 30720 40960 0 0 0
[root@lab-2 /]# edquota -u user2
Disk quotas for user user2 (uid 507):
Filesystem blocks soft hard inodes soft hard
/dev/hdb2 76 10240 20480 10 0 0
/dev/hdb5 0 30720 40960 0 0 0


STEP 5. 變更 /media/hdb5 的目錄權限,使 user1 user2具檔案新增權限,並確認user1
user2 的家目錄權限
[root@lab-2 ~]# ls -ld /media/hdb5/
drwxr-xr-x 3 root root 1024 Dec 9 01:39 /media/hdb5/
[root@lab-2 ~]# chmod o+w /media/hdb5/
[root@lab-2 ~]# ls -ld /media/hdb5/
drwxr-xrwx 3 root root 1024 Dec 9 01:39 /media/hdb5/
[root@lab-2 /]# ls -ld /home/user1
drwx------ 3 user1 labuser 4096 Dec 6 14:40 /home/user1
[root@lab-2 /]# ls -ld /home/user2
drwx------ 3 user2 labuser 4096 Dec 6 14:39 /home/user2

STEP 6. 測試 user1 Disk Quota limit 是否生效
[user1@lab-2 ~]$ dd if=/dev/zero of=file-1 bs=1M count=11
hdb2: warning, user block quota exceeded.
11+0 records in
11+0 records out
11534336 bytes (12 MB) copied, 0.0448105 seconds, 257 MB/s
[user1@lab-2 ~]$ dd if=/dev/zero of=file-2 bs=1M count=11
hdb2: write failed, user block limit reached.
dd: writing `file-2': Disk quota exceeded
9+0 records in
8+0 records out
9318400 bytes (9.3 MB) copied, 0.0372815 seconds, 250 MB/s

[user1@lab-2 ~]$ dd if=/dev/zero of=/media/hdb5/file-user1-1 bs=1M count=21
21+0 records in
21+0 records out
22020096 bytes (22 MB) copied, 0.156971 seconds, 140 MB/s
[user1@lab-2 ~]$ dd if=/dev/zero of=/media/hdb5/file-user1-2 bs=1M count=11
hdb5: warning, user block quota exceeded.
11+0 records in
11+0 records out
11534336 bytes (12 MB) copied, 0.0659443 seconds, 175 MB/s
[user1@lab-2 ~]$ quota
Disk quotas for user user1 (uid 506):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdb2 20480* 10240 20480 12 0 0
/dev/hdb5 32900* 30720 40960 7days 2 0 0

STEP 7. 測試 user2 Disk Quota limit 是否生效
[user2@lab-2 ~]$ dd if=/dev/zero of=file-1 bs=1M count=11
hdb2: warning, user block quota exceeded.
11+0 records in
11+0 records out
11534336 bytes (12 MB) copied, 0.0328104 seconds, 352 MB/s
[user2@lab-2 ~]$ dd if=/dev/zero of=file-2 bs=1M count=11
hdb2: write failed, user block limit reached.
dd: writing `file-2': Disk quota exceeded
9+0 records in
8+0 records out
9318400 bytes (9.3 MB) copied, 0.0291954 seconds, 319 MB/s
[user2@lab-2 ~]$ dd if=/dev/zero of=/media/hdb5/file-user2-1 bs=1M count=21
21+0 records in
21+0 records out
22020096 bytes (22 MB) copied, 0.101413 seconds, 217 MB/s
[user2@lab-2 ~]$ dd if=/dev/zero of=/media/hdb5/file-user2-2 bs=1M count=11
hdb5: warning, user block quota exceeded.
11+0 records in
11+0 records out
11534336 bytes (12 MB) copied, 0.0535639 seconds, 215 MB/s
[user2@lab-2 ~]$ dd if=/dev/zero of=/media/hdb5/file-user2-3 bs=1M count=11
hdb5: write failed, user block limit reached.
hdb5: write failed, user block limit reached.
dd: writing `/media/hdb5/file-user2-3': Disk quota exceeded
8+0 records in
7+0 records out
8216576 bytes (8.2 MB) copied, 0.0546072 seconds, 150 MB/s
[user2@lab-2 ~]$ quota
Disk quotas for user user2 (uid 507):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdb2 20480* 10240 20480 12 0 0
/dev/hdb5 40958* 30720 40960 6days 3 0 0

沒有留言:

張貼留言