If you are on a Linux machine and have a file system with activated user-quota, you can check via the following commands that quotacheck
counts files multiple times if they can be reached via bind-mounts (if source & target of these bind-mounts both reside on the file system that quotacheck
visits):
# we assume /home has active user-quota
repquota /home # check used quota before changes
mkdir /home/test_user/dir
mkdir /home/other_dir
mount -o bind /home/test_user/dir /home/other_dir
head -c1000000 /dev/urandom > /home/test_user/dir/test
chown test_user /home/test_user/dir/test
repquota /home # repquota now reports 1000000 bytes more for test_user
# umount /home/test_user/dir # possible solution
quotaoff -a
quotacheck -vuam
quotaon -a
# mount -o bind /home/test_user/dir /home/other_dir # possible solution
repquota /home # repquota now reports 2000000 bytes more for test_user
The only solution I can think of is to umount
all bind-mounted directories before executing the quotacheck
and remount them afterwards. Are there any other solutions? Removing the usrquota
-option from the bind-mounted directories does not seem to work (not surprised, don't bother explaining it). And excluding some directories from being visited by quotacheck
does not seem to be possible (man page does not mention any relevant option). By the way, I tested this on Debian 8 (Kernel 3.16.0, quota 4.01).
Clarification: Apart from the bind-mounts, everything under /home
belongs to a single file system.