需求:給U盤進行磁盤配額,不同用戶不同的使用容量第一步:安裝quota命令
sudo apt-get install quota

第二步:為U盤進行分區,全部容量分為一個分區
sudo fdisk /dev/sdb
n->p->Enter->Enter->Enter->w

第三步:格式化分區(ext3)
sudo mkfs.ext3 /dev/sdb1

要求輸入信息,Enter(回車)就行
第四步:掛載分區/dev/sdb1
sudo mkdir /mnt/quotadir
sudo mount /dev/sdb1 /mnt/quotadir/
mount | grep sdb1

第五步:為此目錄進行配額的權限
sudo mount -o remount,usrquota,grpquota /mnt/quotadir/
mount | grep sdb1

第六步:建立quota記錄文件,quotacheck掃描就行啦
sudo quotacheck -avug


第七步:quota服務的開啟和關閉
開啟:sudo quotaon -vug /mnt/quotadir/
關閉: sudo quotaoff -vug /mnt/quotadir/

第八步:創建兩個用戶同群組進行,後續為這兩個用戶進行空間配額
sudo groupadd quotagroup
cat /etc/group | grep quotagroup
sudo useradd -g quotagroup quotauser1
sudo useradd -g quotagroup quotauser2
cat /etc/passwd | grep quota

第九步:為指定用戶或群組分配限額
為quotauser1分配250M限額,不能超過300M:sudo edquota -u quotauser1
為quotauser2分配250M限額,不能超過300M:sudo edquota -u quotauser2


第二個用戶同理,自行編寫
為quotagroup群組分配500M限額,不能超過600M:sudo edquota -g quotagroup


設置寬限時間14天:sudo edquota -t


第十步:顯示用戶或者群組的限額現象
顯示用戶配額:sudo quota -uvs quotauser1 quotauser2

顯示群組配額:sudo quota -gvs quotagroup

第十一步:顯示文件系統的配額信息
顯示用戶:sudo repquota -auvs

顯示群組:sudo repquota -agvs

第十二步:測試是否有效
切換用戶:sudo su quotauser1
創建一個大文件:dd if=/dev/zero of=bigfile bs=1M count=270

切換回主用戶查看:sudo repquota -auvs

當再次寫入時,會報錯,只能寫入上限值大小的容量

完畢。