Solved Disks Quota does not work

Hello everyone,

How to configure the quota service so that everything works fine ?
I followed the procedure from FreeBSD Handbook given at the link https://www.freebsd.org/doc/en/books/handbook/quotas.html but it does not work.

System :
Code:
uname -a
FreeBSD panoramix 12.1-STABLE FreeBSD 12.1-STABLE r360207 GENERIC amd64

Here is what I did for configuration :
- I checked if the kernel supports quotas well
Code:
sysctl kern.features.ufs_quota
kern.features.ufs_quota: 1

- I configured the quota service at boot
Code:
cat /etc/rc.conf
quota_enable="YES"
check_quotas="NO"

- I configured fstab file
Code:
cat /etc/fstab
/dev/ada5a /nfs4 ufs rw,userquota,groupquota 1 1
I then restarted the system.


After reboot command :
- I check if the quota is supported on the partition
Code:
quota -v
Disk quotas for user root (uid 0):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4             33036        0       0             61       0      0
I have a quota on /dev/ada5a /nfs4 :)

- I set a limit for user (nuxbsd)
Code:
edquota -u nuxbsd
Quotas for user nuxbsd:
/nfs4: in use: 1912344k, limits (soft = 10240k, hard = 10250k)
        inodes in use: 1771, limits (soft = 0, hard = 0)

- I check the limit for user (nuxbsd)
Code:
quota -v nuxbsd
Disk quotas for user nuxbsd (uid 1010):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4           1912344        0       0           1771       0      0
It does not work :confused:

Why is the limit not supported ?
What did I miss?

Thank you very much if you can help me.
 
Thanks olli@,

The UFS file system is local. It is an nfs resource.
The quota.user and quota.group files do exist in /nfs4.
The quotacheck -a command returns nothing.

Thank you
 
Try
- delete quota.user and quota.group
- service quota restart
- give the user quota
- service quota restart again
- check user quota
- dd random data into a file, exceeding quota

If all is good, "disc quota exceeded" message should appear.
 
The UFS file system is local. It is an nfs resource.
I don’t understand. If it is an NFS mount, then it is not a local UFS file system. It doesn’t matter if NFS server and client run on the same machine – From the kernel’s point of view it’s a remote file system, and this does make a difference regarding quotas. In particular, the rpc.rquotad(8) service must be enabled.
 
Thank you,

cat /etc/fstab
/dev/ada5a /nfs4 ufs rw,userquota,groupquota 1 1
cat /etc/exports
/nfs4 -alldirs -network=192.168.1 -mask=255.255.255.0

This is why I need the quota service.

- Users (nologin) will connect by ssh FTP to the partition with the mount point /nfs4.
- Each user therefore has his own personal directory for remote access by ssh FTP chrooted in /nfs4.

- The nfs resource doesn't even need to exist.
- I remove the nfs resource from the exports file.
cat /etc/exports
#/nfs4 -alldirs -network=192.168.1 -mask=255.255.255.0

Does the quota service work for users (nologin) ?
 
Ok, thanks for clarification. Calling the directory “/nfs4” is probably not a good idea, because such a name implies that it is an NFS mount, not a local mount.
- I remove the nfs resource from the exports file.
cat /etc/exports
#/nfs4 -alldirs -network=192.168.1 -mask=255.255.255.0
Note that you should send a SIGHUP signal to the mountd(8) process for the changes to take effect.
Does the quota service work for users (nologin) ?
File system quotas work for all users, based on their numerical UID. It does not matter whether they can actually login; they do not have to have a valid login shell. Actually, file system quotas even work for UIDs that don’t have a passwd entry at all.
 
Thanks for your help,

I tested T-Deamon's solution.

User delbadog is just for testing.

This is what i did (I try to be as complete as possible in my explanations)
- cd /nfs4
- service quota stop
- rm quota.user quota.group
- service quota start
Enabling quotas: done.

- edquota -u delbadog
Code:
Quotas for user delbadog:
/nfs4: in use: 4k, limits (soft = 1024k, hard = 1030k)
        inodes in use: 1, limits (soft = 0, hard = 0)
~
~
:wq
/tmp/EdP.avW0DE: 3 lines, 128 characters.
The quota.user file is created in the /nfs4 directory.

- service quota restart

- repquota /nfs4
Code:
                                           Block  limits                    File  limits
User                                  used   soft   hard  grace     used    soft    hard  grace

- quota -v delbadog
Code:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 0        0       0              0       0      0

If i run the command :
- quotacheck -cum /nfs4
he creates the file quota.group

- repquota /nfs4
Code:
                                           Block  limits                    File  limits
User                                  used   soft   hard  grace     used    soft    hard  grace
root                             --  33168      0      0      -       64       0       0      -
delbadog                         --      4      0      0      -        1       0       0      -

I don't understand why when I run the quota -v delbadog command I don't have a soft and hard limit !
 
Note that the quota files are initialized by quotacheck(8), so you have to run this first. It is run automatically during boot if you set check_quotas="YES" in /etc/rc.conf. Without running quotacheck first, commands like edquota and other quota-related commands do not work correctly might leave the quota files with undefined contents. So, I recommend to enable check_quotas in rc.conf and reboot.

If it still doesn’t work for you, then I don’t know what else could be wrong on your system. I would probably start by looking at a hexdump of the quota.user file, verifying that it really looks like a 64bit quota file, with correct header (*) and so on, and check if the changes from edquota(8) really end up in the quota.user file.

―――
(*) The command head -c8 quota.user should print “QUOTA64”.
 
I can't reproduce the error you are experiencing on 12.1-RELEASE and 12.2-BETA2 (fresh installation). Configuration applied exactly as described in the handbook (with check_quotas="NO" set, without running quotacheck(8)) . That what is affecting your system it's your system only (or eventually that particular STABLE revision).
 
Thanks,
this is what I have done since your advice.

Thanks, this is what I have done since your advice.

cat /etc/rc.conf
quota_enable = "YES"
check_quotas = "YES"

head -c8 quota.user
QUOTA64 :)

service quota restart
Checking quotas: done.
Enabling quotas: done.

I set the limits.
edquota -u delbadog

I check the limits.
quota -v delbadog
Code:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 4        0       0              1       0      0

:confused:
 
When I do the same, it works for me. I have no idea what’s wrong with your system.

Does the mtime of the quota.user file change when you run edquota? If it doesn’t, the edquota doesn’t update the quota.user file for some reason. if it does, something else must be wrong.

By the way, did you check dmesg, /var/log/messages, /var/log/console or other log files for anything suspicious?
 
I have checked the mtime of the quota.user file and it does not change when edquota is applied.
The edquota command is not taken into account. :(
When using quotas should you set <pass> to 2 in fstab to check the filesystem?
Does this have an influence or not on the quota service?
 
olli@,

this is what the dmesg command returns:

Code:
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)
fsync: giving up on dirty (error = 35) 0xfffff80005b7f960: tag devfs, type VCHR
    usecount 1, writecount 0, refcount 5 rdev 0xfffff80005c8bc00
    flags (VI_ACTIVE)
    v_object 0xfffff80005e69600 ref 0 pages 727 cleanbuf 2 dirtybuf 1
    lock type devfs: EXCL by thread 0xfffff80057f24000 (pid 19000, quotaoff, tid 100378)
    dev ada5a
fsync: giving up on dirty (error = 35) 0xfffff80005b7f960: tag devfs, type VCHR
    usecount 1, writecount 0, refcount 5 rdev 0xfffff80005c8bc00
    flags (VI_ACTIVE)
    v_object 0xfffff80005e69600 ref 0 pages 727 cleanbuf 2 dirtybuf 1
    lock type devfs: EXCL by thread 0xfffff80057f24000 (pid 19000, quotaoff, tid 100378)
    dev ada5a

I find the same error in the messages file.

I saved the data, formatted the disk and I have no more errors with the dmesg command !
 
Last edited:
Summury,
- In the dmesg error I can understand that the quota is not supported because of quotaff in the error.
- I no longer have this error and I don't understand why edquota doesn't change the mtime to quota.user.

If I start from the beginning of my post, the rc.conf file containing :
- file rc.conf
quota_enable="YES"
check_quotas="YES"

- head -c8 quota.user
QUOTA64

- quota -v
Code:
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4               276        0       0             70       0      0

- The mtime of the quota.user file only changes when I do service quota restart.

By working by elimination, I ask myself these questions :
- Am I missing something with the edquota command ?
- In the rc.conf file are the boot options correct ?
- In the fstab file are the options, dump and pass columns correct ?
- Is there a bug with version FreeBSD 12.1 ?
 
It works !

What I have done.
  • I checked my configuration and it is ok.
  • Then every time I used the edquota command and checked with the quota command, I didn't see the quotas I had just set for a user.
  • So I went through Webmin, I added soft and hard quotas for a user, I checked with the quota and repquota command, it worked !
  • I then tested the soft and hard limits and it works well.

This is exactly what I do with the edquota command !
Code:
edquota -u delbadog
Quotas for user delbadog:
/nfs4: in use: 4k, limits (soft = 9437184k, hard = 10485760k)
        inodes in use: 1, limits (soft = 0, hard = 0)
~
~
:wq

Why was it not working ?
  • If I use the edquota -u delbadog command and change soft = 9437184k to soft = 8437184k that I exit the vi editor with :wq and then check with the quota -v delbadog command I see that edquota did not support the modification !
  • That's why when I put quotas on a user and I checked afterwards, I did not see any quota rules because everything remained at 0k !
When I go through webmin, it works !
  • The mtime of the quota.user file is updated.
  • So what does the edqota -u delbadog command run by webmin do than this same command without webmin ?
  • Why are the parameters not taken into account when saving with the parameter :w then when closing with the parameter q ?

In the future, I would like it to work without having to go through Webmin !
Before closing this post, there are still gray areas with the edquota command.

Thank you all for your help.
 
Ok, so you have narrowed it down to the edquota(8) command not actually updating the quota.user file on your system.
A few things to check:
  • Do you execute edquota(8) with root privileges?
  • Are you 100 % sure that you did not make any changes to the template except for the quota limit numbers? The parsing code seems to be rather strict.
  • What locale settings are you using? If in doubt, try running edquota(8) with LC_ALL=C. (But I don’t think that the locale could cause the problem.)
  • While you run edquota(8) and the editor is still open, please open a second terminal window and check the temporary editor file in /tmp. It should begin with “EdP.a”, i.e. /tmp/EdP.a*. It is removed automatically when edquota(8) exits, so create a hardlink in order to save its contents:
    ln /tmp/EdP.a* /tmp/foo
    Afterwards check the contents onf /tmp/foo. Have the new values that you entered really been saved to the file? If not, then something is wrong with the execution of your editor (vi).
  • Please try using edquota(8) non-interactively. For example: edquota -e /nfs4:8437184:10485760 delbadog
    Does that work?
 
Thanks olli@,

This is what i did

Execute edquota
whoami
root

Regional parameters
Belgium
cat /etc/rc.conf
keymap="be.acc.kbd"

locale -a | more
C
C.UTF-8
POSIX
af_ZA.ISO8859-1
af_ZA.ISO8859-15
af_ZA.UTF-8
am_ET.UTF-8
ar_AE.UTF-8
ar_EG.UTF-8
ar_JO.UTF-8
ar_MA.UTF-8
ar_QA.UTF-8
ar_SA.UTF-8
be_BY.CP1131
be_BY.CP1251
be_BY.ISO8859-5
be_BY.UTF-8
bg_BG.CP1251
bg_BG.UTF-8
ca_AD.ISO8859-1
ca_AD.ISO8859-15
ca_AD.UTF-8
ca_ES.ISO8859-1
ca_ES.ISO8859-15
ca_ES.UTF-8
ca_FR.ISO8859-1
ca_FR.ISO8859-15
ca_FR.UTF-8
ca_IT.ISO8859-1
ca_IT.ISO8859-15
ca_IT.UTF-8
cs_CZ.ISO8859-2
cs_CZ.UTF-8
da_DK.ISO8859-1
da_DK.ISO8859-15
da_DK.UTF-8
de_AT.ISO8859-1
de_AT.ISO8859-15

Check file EdP.a*

Terminal 1
edquota -u delbadog
Code:
Quotas for user delbadog:
/nfs4: in use: 4k, limits (soft = 9437184k, hard = 10485760k)
        inodes in use: 1, limits (soft = 0, hard = 0)
To

Code:
/nfs4: in use: 4k, limits (soft = 9437184k, hard = 20485760k)
        inodes in use: 1, limits (soft = 0, hard = 0)
:w
Step: I do link in Terminal 2
:q

Terminal 2
ln /tmp/EdP.aVDuYF /tmp/foo

cat /tmp/foo
Code:
Quotas for user delbadog:
/nfs4: in use: 4k, limits (soft = 9437184k, hard = 20485760k)
    inodes in use: 1, limits (soft = 0, hard = 0)

I see that after closing vi the file still exists!
ls -lh /tmp/EdP.aVDuYF
-rw------- 2 root wheel 135B Oct 7 21:10 /tmp/EdP.aVDuYF
I have a lot of files of this type into /tmp !


edquota(8) non-interactively
edquota -e / nfs4: 8437184: 10485760 delbadog
quota -u delbadog
Code:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 4  8437184 10485760              1       0      0

What I don't understand is that before going through webmin the edquota command never changed the quota.user file.
When I checked the quotas with the command quota -u delbadog I always had a return Disk quotas for user delbadog (uid 1007): none
Now when I use the edquota command it works.

Which I don't understand since I'm using the exact same syntax as before I went through Webmin.

Because if I set up quotas on another FreeBSD machine and I end up with the same problem, I will not have to go through Webmin each time to solve the problem.

What I'm going to do is install a new FreeBSD for testing on another machine and see if I have the same problem because it must be coming from somewhere.
As you are a developer you like to get to the bottom of things to find out what really happens when there is something that does not go well and that we call "Bug" which is a generic word often masking the real cause of the problem.

So if my problem can help get things done then that's fine.
The solution is good, understanding it is better.

.
 
I see that after closing vi the file still exists!
ls -lh /tmp/EdP.aVDuYF
-rw------- 2 root wheel 135B Oct 7 21:10 /tmp/EdP.aVDuYF
I have a lot of files of this type into /tmp !
The edquota(8) command always removes the temporary file after updating the quotas.
The fact that it does not remove the files on your machine means that the edquota(8) command terminates prematurely (after calling the editor), which also explains why it doesn’t update the quotas properly.

edquota(8) non-interactively
edquota -e / nfs4: 8437184: 10485760 delbadog
quota -u delbadog
Code:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 4  8437184 10485760              1       0      0
Ok, so using edquota(8) non-interactively works. Also, Webmin works for you, which also calls edquota(8) non-interactively.

That means that your editor must be the problem. If it exits with a non-zero return code, that would explain the symptoms you’re seeing. What is the value of your EDITOR environment variable (if any)? And what is the output of ls -l /usr/bin/vi?
 
Yes, I have a lot of EdP.a* files in /tmp .

I also use the Vim editor, can this influence ?
vim-8.2.1558

ls /tmp/EdP.a* | wc -l
61

ls -l /usr/bin/vi
-r-xr-xr-x 6 root wheel 459792 Apr 23 05:10 /usr/bin/vi


- Then, I changed the editor variable to ee
env
SHELL=/usr/local/bin/bash
EDITOR=vi

export EDITOR="/usr/bin/ee"

env
SHELL=/usr/local/bin/bash
EDITOR=/usr/bin/ee


- I restarted the edquota command with a monitoring terminal
Terminal 1
edquota -u delbadog
Code:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 4  8437184 10485760              1       0      0
to
/nfs4                 4  8437184 20485760              1       0      0

Terminal 2
ln EdP.aHUnH3 foo2
cat foo2
Code:
Quotas for user delbadog:
/nfs4: in use: 4k, limits (soft = 8437184k, hard = 30485760k)
    inodes in use: 1, limits (soft = 0, hard = 0)

ls -lh EdP.aHUnH3
ls: EdP.aHUnH3: No such file or directory
The temporary file EdP.aHUnH3 is successfully deleted.
You are right, there is a problem with vi editor. 👍


ls /tmp/EdP.a* | wc -l
61


- Then I did:
reboot

Is it normal that after a rebbot I still have this?
ls /tmp/EdP.a* | wc -l
61
What should I do with all these files?

env
SHELL=/usr/local/bin/bash
EDITOR=vi

Why is the EDITOR variable returned to vi instead of ee ?

Thank you
 
You are right, there is a problem with vi editor. 👍

Ok, so vi exits with non-zero return code, which causes edquota to terminate. The question is what the problem is with vi on your machine. It could be caused by a setting in a file (e.g. ~/.exrc), or something in your environment, like $EXINIT. See the vi(1) manual page for a full list of environment variables and files that are read by vi.

Is it normal that after a rebbot I still have this?
ls /tmp/EdP.a* | wc -l
61
What should I do with all these files?

Remove them. They are just temporary files. Normally edquota should have removed them automatically.

The /tmp directory is not cleared by default upon reboot. Personally I mount a tmpfs(5) on /tmp (i.e. a memory file system), so it’s cleared automatically when FreeBSD unmounts it during shutdown.

env
SHELL=/usr/local/bin/bash
EDITOR=vi

Why is the EDITOR variable returned to vi instead of ee ?

Well, you rebooted the machine, right? When you change the value of an environment variable inside a shell session (with the export command), then that change is only in effect for the duration of that shell session. If you want to change the value permamently, you have to do that in the profile of your shell. Apparently you are using bash as your login shell – in that case it’s ~/.bashrc or ~/.bash_profile, I think.
 
Thanks,
yes for the default editor I have not modified the .profile
I did:
rm EdP.a*

man vi
the variables vi
CDPATH , TMPDIR , SHELL , TERM , LINES , NEXINIT

env
Bash:
SHELL=/usr/local/bin/bash
EDITOR=vi
ENV=/home/aiko/.shrc
PWD=/home/aiko
LOGNAME=aiko
HOME=/root
SSH_CONNECTION=192.168.1.32 49234 192.168.1.12 22
TERM=xterm-256color
USER=aiko
SHLVL=2
PAGER=less
SSH_CLIENT=192.168.1.32 49234 22
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/aiko/bin
BLOCKSIZE=K
MAIL=/var/mail/aiko
SSH_TTY=/dev/pts/1
_=/usr/bin/env

cat .shrc
Bash:
# $FreeBSD: stable/12/share/skel/dot.shrc 327420 2017-12-31 06:58:58Z eadler $
# .shrc - bourne shell startup file
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to this file.
# see also sh(1), environ(7).
# file permissions: rwxr-xr-x
# umask    022
# Uncomment this to enable the builtin vi(1) command line editor in sh(1),
# e.g. ESC to go into visual mode.
# set -o vi
# some useful aliases
alias h='fc -l'
alias j=jobs
alias m="$PAGER"
alias ll='ls -laFo'
alias l='ls -l'
alias g='egrep -i'
# # be paranoid
# alias cp='cp -ip'
# alias mv='mv -i'
# alias rm='rm -i'
# # set prompt: ``username@hostname$ ''
# PS1="`whoami`@`hostname | sed 's/\..*//'`"
# case `id -u` in
#     0) PS1="${PS1}# ";;
#     *) PS1="${PS1}$ ";;
# esac
# search path for cd(1)
# CDPATH=:$HOME

cat .profile
Bash:
# $FreeBSD: stable/12/bin/sh/dot.profile 338374 2018-08-29 16:59:19Z brd $
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
HOME=/root
export HOME
TERM=${TERM:-xterm}
export TERM
PAGER=less
export PAGER
# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
# Uncomment to display a random cookie on each login.
# if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune -s ; fi
# Autocompletion
[[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \
source /usr/local/share/bash-completion/bash_completion.sh

- I looked for the error code of vi and I tested the vi command alone then the edquota command
- I get the value of the variable $?

with vi only
vi test
bla bla bla bla
:wc
echo $?
0

with edquota
edquota -u delbadog
:wc
echo $?
130

edquota -e /nfs4:8437184:10485760 delbadog
echo $?
0

quota -u delbadog
Bash:
Disk quotas for user delbadog (uid 1007):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/nfs4                 4  8437184 10485760              1       0      0
echo $?
0
 
Hello everyone,

- Should we stop there and rule the post as resolved or should we explore what does not work with the edquota command through the editor vi ?
- If you have any ideas about the environment variables that the vi editor uses, they are welcome.

- I am using 2bsd-vi-050325_2.
- I removed 2bsd-vi-050325_2 and reinstalled with make and make install.
- Edquota in interactive mode still does not work.

pkg info 2bsd-vi
Bash:
2bsd-vi-050325_2
Name           : 2bsd-vi
Version        : 050325_2
Installed on   : Tue Oct 13 10:39:52 2020 CEST
Origin         : editors/2bsd-vi
Architecture   : FreeBSD:12:amd64
Prefix         : /usr/local
Categories     : editors
Licenses       : BSD4CLAUSE
Maintainer     : lx@FreeBSD.org
WWW            : http://ex-vi.sourceforge.net/
Comment        : The original vi editor, updated to run on modern OSes
Annotations    :
FreeBSD_version: 1201513
Flat size      : 311KiB

- Should we admit defeat and change the environment variable $EDITOR by ee ?
- Is this an isolated case or is it a bug between equota and vi ?

That's it, I changed the $SHELL bash to tcsh and the edquota command uses the ee editor directly.
- No more errors with ee.
- No more EdP.a * files in /tmp.

Thank you.
 
- I am using 2bsd-vi-050325_2.
- I removed 2bsd-vi-050325_2 and reinstalled with make and make install.
- Edquota in interactive mode still does not work.
Did you try without 2bsd-vi installed, i.e. with the version of vi that comes with FreeBSD’s base system?

The version of vi from the 2bsd-vi port is much older and feature-constrained. It only exists for historic purposes, or maybe for small embedded systems that have only tiny amounts of memory. I recommend not to use it for normal system administration.

By the way, in the preceding post you mentioned that the exit status was 130. This means that the process was terminated by SIGINT. That’s usually caused by pressing Ctrl-C.
 
Back
Top