顯示具有 TMLDP 標籤的文章。 顯示所有文章
顯示具有 TMLDP 標籤的文章。 顯示所有文章

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

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

  • LAB B :
    4. 建立 檔案系統/dev/hda5(容量100MB)
    5. /dev/hda5的檔案系統格式為 ext3
    6. /dev/hda5 掛載到 /media/hda5
  • 操作步驟 :
         STEP 1. 確認硬碟裝置檔檔名
[root@lab-2 ~]# fdisk -l

Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 778 6144862+ 83 Linux
/dev/hdb3 779 909 1052257+ 82 Linux swap / Solaris

STEP 2. 執行 fdisk 劃分檔案系統
[root@lab-2 ~]# fdisk /dev/hdb

STEP 3. 執行 fdisk 劃分檔案系統
[root@lab-2 ~]# fdisk /dev/hdb

STEP 4. 新增延伸分割區 /dev/hdb4
Command (m for help): p

Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 778 6144862+ 83 Linux
/dev/hdb3 779 909 1052257+ 82 Linux swap / Solaris

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (910-1044, default 910):
Using default value 910
Last cylinder or +size or +sizeM or +sizeK (910-1044, default 1044):
Using default value 1044

Command (m for help): p

Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 778 6144862+ 83 Linux
/dev/hdb3 779 909 1052257+ 82 Linux swap / Solaris
/dev/hdb4 910 1044 1084387+ 5 Extended

STEP 5. 新增邏輯分割區 /dev/hdb5(容量 100MB)
Command (m for help): n
First cylinder (910-1044, default 910):
Using default value 910
Last cylinder or +size or +sizeM or +sizeK (910-1044, default 1044): +100M

Command (m for help): p

Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 778 6144862+ 83 Linux
/dev/hdb3 779 909 1052257+ 82 Linux swap / Solaris
/dev/hdb4 910 1044 1084387+ 5 Extended
/dev/hdb5 910 922 104391 83 Linux
STEP 6. 儲存變更後的Partition Table並使用 partprobe 進行同步作業使New Partition Table 生效
(或重啟系統使New Partition Table 生效)
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
You have new mail in /var/spool/mail/root
[root@lab-2 ~]# partprobe

STEP 7. /dev/hdb5 格式化為 ext3 檔案系統
[root@lab-2 ~]# mkfs -t ext3 /dev/hdb5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
26104 inodes, 104388 blocks
5219 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@lab-2 ~]# dumpe2fs /dev/hdb5 | grep 'Filesystem features:'
dumpe2fs 1.39 (29-May-2006)
Filesystem features: has_journal resize_inode dir_index filetype sparse_super
[root@lab-2 ~]#

STEP 8. 建立掛載點 /media/hdb5
[root@lab-2 ~]# ls -ld /media/hdb5
ls: /media/jdb5: No such file or directory
[root@lab-2 ~]# mkdir /media/hdb5
[root@lab-2 ~]# ls -ld /media/hdb5
drwxr-xr-x 2 root root 4096 Dec 6 15:21 /media/hdb5

STEP 9. /dev/hdb5 掛載到 /media/hdb5 並確認掛載選項正確
[root@lab-2 ~]# mount -t ext3 -o usrquota,grpquota /dev/hdb5 /media/hdb5/
[root@lab-2 ~]# mount | grep hdb5
/dev/hdb5 on /media/hdb5 type ext3 (rw,usrquota,grpquota)

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

  •   LAB A :
    1. 新增使用者帳號 user1~user50
    2. 使用者所屬群組均為 labuser
    3. usrer1 user2 的密碼均為 PassWord
  • 操作步驟 :
    STEP 1. 確認 labuser 群組帳號是否已存在
[root@lab-2 ~]# cat /etc/group | grep labuser
[root@lab-2 ~]#
STEP 2. 新增 labuser 群組帳號
[root@lab-2 ~]# groupadd labuser
[root@lab-2 ~]# cat /etc/group | grep labuser
labuser:x:506:
[root@lab-2 ~]#

STEP 3. 新增使用者帳號 user1~user50,其所屬群組均為 labuser
[root@lab-2 ~]# for i in {1..50};do useradd -g labuser user$i; done
[root@lab-2 ~]# for i in $(seq 1 50);do useradd -g labuser user$i; done

           ※ 若要同時為所有使用者設定密碼(密碼為 PassWord)可使用下列命令
1. 新增帳號並同時建立密碼檔
# for i in {1..50};do useradd -g labuser user$i; touch passwd.txt; echo “user$i:PassW”>> passed.txt; done
2.使用chpassed 為使用者變更密碼
# cat passwd.txt | chpasswd
3.驗證
#cat /etc/shadow | grep user*
user1:$1$Rg32g/ok$VsPXkKi2wiKKyF.HHCFT9/:14949:0:99999:7:::
user2:$1$Rg32g/ok$VsPXkKi2wiKKyF.HHCFT9/:14949:0:99999:7:::
.
user50:$1$Rg32g/ok$VsPXkKi2wiKKyF.HHCFT9/:14949:0:99999:7:::
[root@lab-2 ~]# su - user1
[user1@lab-2 ~]$ su - user2
Password:
[user2@lab-2 ~]$

STEP 4. 設定 user1user2 的密碼為 PassWord
[root@lab-2 ~]# passwd user1
Changing password for user user1.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@lab-2 ~]# passwd user2
Changing password for user user2.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@lab-2 ~]#

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

  • 類別 : [TMLDP] [System Administrator] [LAB]
  • 主題 : 同時新增多組帳號及Disk Quota limit 的實驗

  • 適用發行版 : RedHat 系列發行版 ( RHELCentOSFedora...)
    ※其他發行版尚未實測
  • LAB 環境 : RHEL 5.5

  • 要進行這個測試你需要知道,
  1. 如何新增帳號及設定使用者密碼
  2. 如何同時新增多組帳號
  3. 了解 Disk Quota 的設定程序
  4. 了解檔案系統的建立、格式化及掛載
  • 相關主題 : [帳號管理] [Bash Shell Script] [Disk Quota Mangement] [Maintaining Linux Filesystem]                
  • 實驗要求 :

  1. 新增使用者帳號 user1~user50
  2. 使用者所屬群組均為 labuser
  3. usrer1 user2 的密碼均為 PassWord
  4. 建立 檔案系統/dev/hda5(容量 100MB)
  5. /dev/hda5的檔案系統格式為 ext3
  6. /dev/hda5 掛載到 /media/hda5
  7. /dev/hda5 啟動 Disk Quota limit
  8. 實施Disk Quota limit usrer1 user2 兩個使用者帳號。
  9. /dev/hda5 soft limit 20MBhard limit 30 MB



Powered By Blogger