對使用者的磁盤配額
使用虛拟機 添加一塊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/目錄的所有者
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: 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