Linux學習實例,請各位知道---對用戶的管理配額

對用戶的磁盤配額

使用虛擬機 添加一塊20G硬盤

[root@localhost ~]# fdisk -l

[root@localhost ~]# fdisk /dev/sdb (創建一個主分區sdb1,ext3)

[root@localhost ~]# partprobe /dev/sdb

[root@localhost ~]# mkfs.ext3 /dev/sdb1

[root@localhost ~]# mkdir /mail //建立掛載點


[root@localhost ~]# echo '/dev/sdb1 /mail ext3 defaults,usrquota 0 0' >> /etc/fstab //配置分區/dev/sdb1支持配額

[root@localhost ~]# mount -a // 掛載/etc/fstab 中默認的掛載項或reboot

[root@localhost ~]# mount | grep sdb1

/dev/sdb1 on /mail type ext3 (rw,usrquota)


[root@localhost ~]# ls /mail/

lost+found

[root@localhost ~]# quotacheck -uc /dev/sdb1 //生成配額文件

[root@localhost ~]# ls /mailbox/

aquota.user lost+found


[root@localhost ~]# edquota -u tom //配置對tom的配額信息


Disk quotas for user tom (uid 500):

Filesystem blocks soft hard inodes soft hard

/dev/sdb1 0 80000 100000 0 4 6

[root@localhost ~]# ls -ld /mail/

drwxr-xr-x 3 root root 4096 10-16 22:24 /mail/

[root@localhost ~]# quota -u /dev/sdb1

[root@localhost ~]# chown tom /mail/ //將tom改爲/mail/目錄的所有者

[root@localhost ~]# ls -ld /mail/

drwxr-xr-x 3 tom root 4096 10-16 22:24 /mail/

[root@localhost ~]# su - tom //切換到tom驗證

[tom@localhost ~]$ dd if=/dev/zero of=/mail/test.db bs=1M count=60

60+0 records in

60+0 records out

62914560 bytes (63 MB) copied, 0.367778 seconds, 171 MB/s

[tom@localhost ~]$ dd if=/dev/zero of=/mail/test.db bs=1M count=90

sdb1: warning, user block quota exceeded.

90+0 records in

90+0 records out

94371840 bytes (94 MB) copied, 0.298712 seconds, 316 MB/s

[tom@localhost ~]$ dd if=/dev/zero of=/mail/test.db bs=1M count=120

sdb1: warning, user block quota exceeded.

sdb1: write failed, user block limit reached.

dd: 寫入 “/mail/test.db”: 超出磁盤限額

98+0 records in

97+0 records out

102289408 bytes (102 MB) copied, 0.267445 seconds, 382 MB/s

[tom@localhost ~]$ touch /mail/test.txt

[tom@localhost ~]$ touch /mail/test1.txt

[tom@localhost ~]$ touch /mail/test2.txt

sdb1: warning, user file quota exceeded.

[tom@localhost ~]$ touch /mail/test3.txt

[tom@localhost ~]$ touch /mail/test4.txt

sdb1: write failed, user file limit reached.

touch: 無法觸碰 “/mail/test4.txt”: 超出磁盤限額

[tom@localhost ~]$ ls /mail/

aquota.user lost+found test1.txt test2.txt test3.txt test.db test.txt

[tom@localhost ~]$ ls -l /mail/

總計 100020

-rw------- 1 root root 7168 10-16 22:34 aquota.user

drwx------ 2 root root 16384 10-16 22:12 lost+found

-rw-rw-r-- 1 tom tom 0 10-16 22:37 test1.txt

-rw-rw-r-- 1 tom tom 0 10-16 22:37 test2.txt

-rw-rw-r-- 1 tom tom 0 10-16 22:37 test3.txt

-rw-rw-r-- 1 tom tom 102289408 10-16 22:35 test.db

-rw-rw-r-- 1 tom tom 0 10-16 22:37 test.txt


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章