I have configured my box to allow a certain user up to 2GB of storage thanks to quota
.
I think I have enabled it correctly. /etc/fstab
shows usrquota,grpquota
, quotaon
says everything is fine but I have been able to violate the quota today.
From SSH, I sudo-ed into that user and tried to create a 4GB file
# sudo -u targetuser bash ##the user cannot use SSH
targetuser@host:~> dd if=/dev/zero of=prova.bin count=4096 bs=1048536
sda1: warning, user block quota exceeded.
^C^C3592+0 records in
3592+0 records out
3766341312 bytes (3,8 GB) copied, 333,72 s, 11,3 MB/s
edquota -u targetuser
shows (after I deleted the file)
Disk quotas for user targetuser (uid 1006):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 181200 2097072 22097072 10230 0 0
I'lve also been able to write a new file before deleting the elephant.
The question is tremendously simple: why didn't Linux stop dd from writing more instead of just warning?
What can I do to raise an error when a user attempts to write more than he's allowed to?