Leserartikel Debian/Ubuntu: Quota via NFS

teufelernie

Commander
Registriert
Sep. 2004
Beiträge
2.393
Hi,

[English below] da ich in diesem Internet von dem man schon so viel gehört hat, keine vernünftige Anleitung fand wie man Quota UND NFS verheiratet hier mal meine Anleitung. Aufgrund Auffindbarkeit mache ich das mal in Englisch.

Guys, as I did not find a usable howto for using quota via nfs I just wrote this little howto:

1) - Setup NFS as written per dozens of howtos in the internet on the server and allow your your client ip
- On the client install nfs-common to allow nfs mounts.
2) On both machines install quota
3) - On the server setup a new partition and format it. (This is required as quota did not work very well with the root filesystem. Do NOT throw away this warning, its a shot in your leg in the later future)
- add usr and/or groupquota in your fstab entry from your new, dedicated nfs partition
- umount new_partitition, mount -a will remount the new partition with your new fstab quota parameter (or restart your server instead)
- on the client side nothing has to be done via quota
3) On the Server: Use JOURNALED quota to avoid long quota checks after an unclean server shutdown. In many articles you may find options like
/dev/mapper/userspace-nfshome /exports ext4 errors=remount-ro,usrquota 0 1
but this is a very deprecated way, but too many guys copyied'n'pasted it to the internet
better use journaled quota. To to this it looks like:
/dev/mapper/userspace-nfshome /exports ext4 errors=remount-ro,usrjquota=aquota.user,jqfmt=vfsv0 0 1
(in the examples I didn't use group quota, only users, if you want to use grpquota please add it)
use mount -o remount /your_quota_partition to apply the mount change
4) add your new partition as an export for nfs. do NOT forget to exportfs -ra or restart the nfs service to apply your changes to nfs.
5) - add your nfs mount on the clients fstab. You did NOT need any quota settings to make quotas apply to nfs. Your client will use a quota remote call to your server (via quotarpc).
(You may verify that on your server via
/etc/init.d/quotarpc status
● quotarpc.service - RPC Remote Quota Server
Loaded: loaded (/lib/systemd/system/quotarpc.service; enabled; vendor preset: enabled)
Active: active (running)
6) Server: ensure quotas are running by checking with repquota -a
7) Server or Client create a directory within your nfs export directory and assign this to a test user like
horst-ruediger@ubuntu16-server:/exports/nfshome: chown -R 12345:12345 testdir
8) Create some stuff within "testdir" (make sure that is owned by ur test user (in my case user/grp id 12345(my nfs-server did not need to lookup real users))
9) Test the quota RPC on the client by editing the quota of your user
edquota -r -u 12345
This is calling an interactive editor where you need to make changes and save
10) verify on the server that the quota for user 12345 has been changed via repquota as described at 6)
11) run some tests to get some experience with quota via nfs (like remote grace period setting is not supported, ...), adjust the grace period to nearly zero, exceed quota, know that you need some adjustments for quota rpc in your firewall (maybe you should set the ports for quota to custom ports like explained in some howtos from the internet)


known issues


1) by using edquota -r one the client you got an connection refused error
Check server log. If you got an error like
host 192.168.100.207 attempted to call setquota when disabled
Activate remote set of quotas on the server via
rpc.rquotad -S
(reboot persistent)


2) Only for non-native-English guys (Solved problems on Ubuntu 16.04 (not tested on other releases)):
I wasted a whole f*** forenoon by trying to change the default grace period at the server via

edquota -t
whatever I saved to this file was not readable for quota. Even if I tried to just open the file, save it without changing it.
Every time I got the error that the quotafile could not be parsed after writing:
edquota: Fehlerhafte Zeiteinheiten. Einheiten sind 'second', 'minute', 'hour' und 'day'.
edquota: Konnte Gnadenfristendatei nicht parsen.
The solution was nearly insane.

I am using german locales which mean that the output of the edquota -t was:
Gnadenfrist bevor die weichen Limits durchgesetzt werden für Benutzers:
Zeiteinheiten dürfen sein: days, hours, minutes, oder seconds
Dateisystem Blockgnadenfrist Inodegnadenfrist
/dev/mapper/ubuntu16--vg-root 7days 7days
I guess that this fucked up the parser as its just inserted to the file. The parser expects "filesystem" and got "Dateisystem".
Well, thank you SO MUCH for this bug.
Solved by adjusting the /etc/default/locale with the new line
LC_MESSAGES=POSIX
(which prints output in the default os language (en) on my testing system)
This changed the edquota -t to
Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/dev/mapper/ubuntu16--vg-root 7days 7days
saving works!

3) quotas will not work
quotaon: Cannot find quota file on /yourdir [/dev/mapper/yourdevice] to turn quotas on/off.

or

repquota: Cannot find any quota file to work on.

Solution:
Restart quota service, remount your device where u would like to run quotas on.
mount -o remount /yourdevice_mountpoint/

You don't need to touch / create the quota files manually...! Just restart quotas and then use quotaon on your mountpoint...

3) quotas will not be updated
quotaoff, repquota and then qutaon is needed to update the repquota output.
But thats not the way it should run. To enable a permanent update check the following:

In my case lsmod | grep quota is empty which means the quota kernel modul is not loaded.
In my case a modprobe quota_v1 and modprobe quota_v2 also failed - cus the modules are not available.
To fix this, I installed: apt-get install linux-image-extra-$(uname -r)
Then I can use modprobe and the modules are fine which enables quota working properly.
Do not forget to add the module names from mod probe in /etc/modules to make it reboot-persistent
 
Zuletzt bearbeitet:
  • Gefällt mir
Reaktionen: Sbibi, nospherato und konkretor
Zurück
Oben