Disk quotas per user and per folder

The file disk of John Smith Ltd's appliance is filling up: Jack Green keeps in his home folder copies of all the projects, the share \\atlas\common has become the place where everything gets…

Situation

The file disk of John Smith Ltd’s appliance is filling up: Jack Green keeps in his home folder copies of all the projects, the share \\atlas\common has become the place where everything gets dumped, and one evening a PC downloading an 80 GB archive nearly used up the space for everybody, mail included.

Laura White (lwhite, IT) wants hard limits, enforced by the disk and not just displayed: every employee a quota for their home folder, every share a ceiling. Whoever exceeds the limit must get “disk full” as on a real disk, and a warning must arrive before the limit. In this scenario you check that quotas are on (the delicate part: it requires a reboot), set the default value, correct the exceptions, put a ceiling on the shares and learn to read the warnings.

Warning Quotas are turned on at the appliance’s next reboot, and that reboot lasts longer than usual, once only: the complete filesystem check (e2fsck -f) and the accounting of the space used take minutes, on a large disk even more than ten. Plan it outside working hours, when the backups are finished and nobody is working. During the reboot mail, files, VPN and phones are down.

What you need

  • Administrator access (lwhite).
  • A shared-files filesystem on ext4. On XFS, btrfs or anything else quotas are not offered and the console says so («Quotas not available: the shares’ filesystem (…) is not ext4.»).
  • A quiet moment for the reboot: choose the time carefully, and warn the users.
  • A recent backup (see backup): quotas do not touch files, but every reboot with a disk check deserves a backup behind it.
  • The Active Directory domain (quotas concern the domain’s home folders and shares).

How they work, in brief

A quota here does not look at who owns the files, but where they are: every home folder is a “project” with its own limit, and every share has one too. Therefore:

  • the limit is hard: no soft threshold, no grace period. Beyond the limit you get “disk full” from Windows, from Edon Client and from Tools → Folders;
  • moving a file between your own home folder and a share, or between two shares, becomes a copy followed by a delete: it works, but it is slower on large files;
  • the recycle bin counts against the quota: past the warning threshold Atlas empties it, starting from the files deleted longest ago;
  • there is no quota “per group”: the limits are only for each user’s home folder and for each share.

Steps

Check whether quotas are on

  1. Open System → Settings and choose the File sharing block. Scroll to the «Disk quotas» section.
  2. Read the status:
    • «Quotas not on, on path.»: the filesystem is ext4 but quotas are not yet turned on. Continue from step 3.
    • «Activation requested: quotas turn on at the server’s next reboot, the nightly one of the automatic updates or an earlier one from here.»: the request is already recorded; skip to step 5.
    • «Quotas did not turn on.» with a reason: read it in the table at the bottom.
    • «Quotas not available: the shares’ filesystem (…) is not ext4.» or «…was not found.»: the function is not offered on this appliance; stop here.
    • If the fields «Default home quota (MB)», «Warning threshold (%)» and «Overwrite on every user» are visible, quotas are already on: skip to step 9.
File sharing: disk quotas not yet onFile sharing: disk quotas not yet on
File sharing: disk quotas not yet on

Request activation

  1. Press «Turn on at the next reboot». «Activation requested: quotas turn on at the next reboot.» appears. If you read «The activation was not requested.» instead, the request was not recorded: try again, then look at the logs.
  2. In the meantime the limits you set stay recorded but not enforced: wherever there are quota fields, below appears «Quotas come on at the server’s next restart (Settings › File sharing): until then the limit is recorded, not enforced.»
  3. Choose when to reboot:
    • at night, by itself: if automatic updates are on with «Automatic reboot» (System → Settings → Updates), the appliance reboots at the end of the update window (with 04:30, at 04:30); the activation request marks the reboot as necessary. If «Automatic reboot» is off, the reboot is up to you;
    • now: press «Reboot now» (it appears when activation is requested) and confirm. The console stops, and the «Restarting the system» page reloads by itself when the appliance is back. If «Automatic reboot» is off, the nightly reboot does not happen by itself: use «Reboot now».
  4. Before the reboot warn the users and check in Backup → In progress that no backup is running.
  5. After the reboot, wait: the first boot is long. When the console is back, open the bell: «Disk quotas on» appears. If «Disk quotas not turned on at reboot» appears instead, go back to the «File sharing» block and read the reason (table at the bottom).
  6. At the first boot with quotas on, Atlas assigns the limit to the existing folders: for a large share it takes time. Until it has finished, Status may show partial numbers.

For the technician The mechanism is ext4’s project quotas (prjquota), written in the superblock: nothing to add to fstab. If the shares are on a filesystem of their own or on /srv with the services, a systemd unit (edon-quota-enable) runs before the mount, after its fsck; if they are on the system partition, the same operation runs in the initramfs. The script never makes the boot fail: if e2fsck finds errors the filesystem is mounted without quotas and Atlas notifies it. The procedure was tried in the lab on the three configurations and with a Windows client; the design note is info/done/QUOTA.md.

The default value for everyone

  1. Still in System → Settings → File sharing, «Disk quotas»:
    • «Default home quota (MB)»: 10240 (10 GB). It is the space every new user receives; 0 = no limit.
    • «Warning threshold (%)»: 90. Past this threshold the user receives an email about their home folder and the administrators a notification, once per crossing.
  2. If you want to apply the quota to already existing users too, turn on «Overwrite on every user». The page says to how many it will be written («It will be written on the home of 4 users.») and how many would end up over the limit («n would be over the limit: no file is lost, but they cannot save until they free space.»).
  3. Press «Apply». «File sharing settings saved.» appears and, with the box on, «Default quota written on the home of 4 users.» The page goes back to the list of blocks; reopening «File sharing», the «Overwrite on every user» switch has gone back off by itself.

If the number is not valid: «A whole number of MB, 0 for no limit.» For the threshold: «A whole number from 1 to 100.»

Exceptions: a different quota for one user

  1. Julia Brown fills her folder with scans: open Active Directory → Users and select jbrown.
  2. Scroll to the features and write in «Home quota (MB)» 5120. Under the field a bar says how much is used («2 GB of 5 GB (40 %)»): yellow from 75 %, red from 90 %.
  3. Press «Save». If the limit is lower than the space already used the console warns («The limit is below the space already used (…): no file is lost, but writes will fail until space is freed.»): Julia loses nothing, but cannot save any more until she frees space.
  4. For Jack Green, who really needs space, write 51200 (50 GB).

If the limit was not saved: «User saved, home quota not: try again shortly.»

The ceiling on shares

  1. Open Active Directory → Shares and select common.
  2. In the «Space» section write in «Quota (MB)» 51200 (50 GB). 0 = no limit. A bar under the field shows the space used.
  3. Press «Save». «Share updated.» appears.
  4. Repeat for production: «Quota (MB)» 204800 (200 GB), and for administration: 102400 (100 GB).

The «Space» section appears only if quotas are supported. If the limit was not saved: «Share saved, quota not: try again shortly.» If you wrote it but quotas are not yet on, under the field you read why («Quotas are not on on this server: the limit is recorded and holds once they are (Settings › File sharing).»).

The common share with the quota and the usage barThe common share with the quota and the usage bar
The common share with the quota and the usage bar

What happens when a folder fills up

Julia copies a 12 GB archive to her folder, which has a 5 GB limit.

  1. Windows writes up to the limit and then answers “disk full” (or “Not enough disk space”). Where there is a limit, PCs do not keep writes in cache: this way a program receives the error instead of losing data without noticing.
  2. Tools → Folders answers «There is no space left on the share.» and does not write: the original file, if it was being overwritten, stays intact.
  3. Edon Client (the Edon folder on the PC) waits five minutes before retrying and warns the user once per share, until a write there succeeds. On Android there is no write queue, and on the Mac Edon Client does not show the folders as drives.
  4. To free space, deleting is not enough if the recycle bin is on: the files end up in the recycle bin folder (Cestino, or the name chosen in File sharing) inside the same folder and still count. Atlas empties a folder’s recycle bin past the warning threshold, every minute, starting from the files deleted longest ago, down to just under the threshold. With the quota full, in the home folder Samba may not even manage to create the recycle bin and deletes directly.

The warnings

  1. When a home folder crosses the threshold (90 %), the user receives an email with subject «Spazio della cartella personale quasi esaurito / Personal folder almost full», in Italian and English. The email leaves from the appliance’s mail server and only if the user has a mail address and mail is installed.
  2. Administrators see in the bell a notification of type «Warning»: «Home almost full» or «Share almost full», with the detail jbrown — 92 % (4.6 GB / 5 GB). A click leads to the right page.
  3. The warning is one per crossing: if the folder stays above the threshold you do not get one a day; a new one arrives only after it has gone below and risen again.
  4. For an administrator, Status shows the «User homes» cards (space per home) and «Shares» (space per share), with the space used read from the quotas and a bar against the limit. «Homes not measured: n. The total is partial.» says the figure is not complete.

Check

  • System → Settings → File sharing shows the quota fields (not the «Quotas not on» status), and in the bell there was «Disk quotas on».
  • In Active Directory → Users jbrown shows the «Home quota (MB)» bar; in Active Directory → Shares common shows the bar under «Quota (MB)».
  • From a domain PC, copying into a folder with a small limit (for a test, a 100 MB test share) Windows answers “disk full” at the limit.
  • Status shows «User homes» and «Shares» with the bars.
  • After crossing the threshold: «Home almost full» notification and an email to the user.

If something goes wrong

Message or symptom Cause What to do
«Quotas did not turn on.» + «The filesystem check (e2fsck) found errors: it was mounted as always, without quotas.» the disk has errors fix the errors (from a shell, with the filesystem unmounted) and press «Turn on at the next reboot» again
«…The filesystem did not take the quota feature (tune2fs).» the filesystem is not suitable ask for support; the appliance stays without quotas
«…At boot the filesystem’s device was not found.» the disk changed name or did not appear check the disk, then request activation again
«…At boot the device held no readable ext4 filesystem: it was left alone.» unreadable superblock do not force; ask for support
«…At the reboot the activation did not run.» the reboot did not run the script press «Turn on at the next reboot» again and reboot
«…The filesystem has the quota feature, but the limits are not enforced.» feature on, mount option not reboot again; if it persists, support
«…The filesystem’s mount is not managed by systemd: the activation is not possible.» special mount configuration cannot be solved from the console
«…The shares are on the system partition and initramfs-tools is missing: the activation is not possible.» missing package install initramfs-tools and try again
«…The activation request was not recorded.» writing the request failed try again
«Quotas not available: the shares’ filesystem … is not ext4.» unsupported filesystem not offered
The bar does not appear, the «Space» section is missing quotas not supported same
The limit has no effect quotas not yet on read the text under the field; turn on and reboot
“Disk full” but the folder looks empty the recycle bin counts against the quota wait for the automatic emptying past the threshold, or empty the recycle bin folder
A file moved between two shares is slow moving is copy + delete this is the expected behaviour
«Share saved, quota not: try again shortly.» the service that applies the limits did not answer try again later
No email to the user at 90 % quota their account has no mail address, or mail is not there check in Active Directory → Users

Tip If a home folder’s quota has to be raised once and for all, change it from the user’s page. If you want it to apply to everyone, change the default value and turn on «Overwrite on every user».

Things this function does not do: it does not limit mail (which has its own «Mail storage» per user), it does not limit the Seafile Drive, it has no per-group ceiling, it is not provided in coexistence mode with a Windows domain controller. For the fields of users and shares see users and shares; for the settings system.

LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer