How To Enable User and Group Quotas - DigitalOcean

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

8/20/2019 How To Enable User and Group Quotas | DigitalOcean

NEW DigitalOcean Kubernetes is now Generally Available. Learn more ❯

 Contents 

How To Enable User and Group Quotas


Posted January 15, 2014  125.2k LINUX BASICS

By Jan Stevens
Become an author

Status: Deprecated
This article is deprecated and no longer maintained.

Reason:
The information in this article is out of date and untested. More recent information
about quotas is listed below.

See Instead:
How To Set Filesystem Quotas on Ubuntu 18.04 or Debian 9.

Introduction
This guide assumes that a droplet with user accounts has already been created. Most
of the time, user quotas are applied to FTP or SFTP users, but it's possible to apply this
to any system user. Notice that it's not possible to use VSFTP's virtual user feature with
quotas – the users should exist on the system!

Quotas are used to limit the amount of disk space a user or group can use on the VPS.
There are generally two different methods of managing quotas: first, an empty file
system can be created and mounted for a specific user. An advantage of this method is
Sign
thatupno
foradditional
our newsletter. Get the latest
package tutorials on
is required. SysAdmin
Second, theand open source
quota topics.
tool can be used to ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 1/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

dynamically manage the disk quota of a user or a group. A big advantage is the
possibility to change quotas on the fly without any complicated disk resizing.

This guide mainly focuses on the creation of user specific quotas; however, all the
commands are exactly the same for group quotas. Instead of a user name, a group
name can be used in the described commands.

Installing Quota
This guide starts by installing the quota program using the following command:

apt-get install quota

The mount options of the file system need to be edited before user specific quotas
can be used. The mount file fstab needs to be opened for editing using the following
command:

sudo nano /etc/fstab

The quotas are enabled by adding a usrquota and/or grpquota to the mounting
options of the main hard disk. When using ursquota, the quotas are only enabled on
specific users. The grpquota option allows for quotas on user groups.

Both options can be independently added depending on the desired result. The fstab
file should be edited as follows for enabling user quotas (for group quotas add
grpquota ).

LABEL=DOROOT / ext4 errors=remount-ro,usrquota 0 1

Save the file and enable the new mount options by remounting the file system as
follows:

mount -o remount /

Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 2/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

The following command will create a new quotas file in the root directory of the file
system. This is an index file used by the quota tool for keeping track of the user's disk
size. It also contains the user limits and configured options.

quotacheck -cum /

The command consists of the following three parameters:

1. The c parameter indicates the creation of a new file, overwriting any previous files.

2. The u parameter indicates that a new user index file should be created. To also create
a group index file, add the g command in the previous command.

3. The m parameter indicates that no read-only mount of the complete file system is
required to generate the different index files.

Because the m parameter is used, it's possible that a small mismatch happens in the
actual specific user disk size and the calculated disk size by the quota program. Make
sure that no user is currently uploading files to the server when running the previous
command to minimize a possible mismatch.

The following command announces to the system that disk quotas should be enabled
on the desired file system.

quotaon /

A similar command can be used to turn off disk quota checking, thus disabling the
quotas for the different users and groups.

quotaoff

Configuring Quotas For Different Users


The user quotas are configured using the edquota command, followed by the desired
user name or group name. The command will open the default configured text editor.
Sign up for
In this our newsletter.
guide, we assume Get thethat
latest
thetutorials
user on SysAdmin
ftpuser and open
should source
receive a topics.
quota of 10Mb. The ×
Enter your email address
command used is as follows: Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 3/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

edquota ftpuser

Which opens the quota file for editing

Disk quotas for user ftpuser (uid 1001):


Filesystem blocks soft hard inodes soft hard
/dev/disk/by-label/DOROOT 8 10000 10240 2 0 0

The text editor shows 7 different columns:

1. Indicates the name of the file system that has a quota enabled

2. Indicates the amount of blocks currently used by the user

3. Indicates the soft block limit for the user on the file system

4. Indicates the hard block limit for the user on the file system

5. Indicates the amount of inodes currently used by the user

6. Indicates the soft inode limit for the user on the file system

7. Indicates the hard inode limit for the user on the file system

The blocks refer to the amount of disk space, while the inodes refer to the number of
files/folders that can be used. Most of the time the block amount will be used in the
quota.

The hard block limit is the absolute maximum amount of disk space that a user or
group can use. Once this limit is reached, no further disk space can be used. The soft
block limit defines the maximum amount of disk space that can be used. However,
unlike the hard limit, the soft limit can be exceeded for a certain amount of time. This
time is known as the grace period. More information about the grace period later in the
guide.

In the example above, a soft limit off 9,785Mb and hard limit of 10Mb are used. To see
the quota in action an FTP/SFTP transfer can be started, where multiple files will be
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics.
uploaded with a total size of 12 Mb for example (as long as its larger than the hard limit).
×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 4/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

The FTP/SFTP client will indicate a transfer error, meaning that the user will be unable
to upload any files. Of course, 10Mb isn't a meaningful quota. In this guide every user
will get a soft limit of 976 Mb and a hard limit of 1Gb. The configuration looks as
follows:

Disk quotas for user ftpuser (uid 1001):


Filesystem blocks soft hard inodes soft hard
/dev/disk/by-label/DOROOT 8 1000000 1048576 2 0 0

For checking the quota of a specific user, the quota command can be used followed by
the user or group

quota ftpuser

Which gives the following output

Disk quotas for user ftpuser (uid 1001):


Filesystem blocks soft hard inodes soft hard
/dev/disk/by-label/DOROOT 8 1000000 1048576 2 0 0

Generating Reports
It is possible to generate a report from the different quotas. The following command is
used:

repquota -a

Which produces the following output

*** Report for user quotas on device /dev/disk/by-label/DOROOT


Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
------------------------------------------------------------------------------------
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics.
rootyour email address
-- 1118708 0 0
×0
Enter Sign37093
Up 0
daemon 68 0 0 4 0 0
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 5/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean
daemon -- 68 0 0 4 0 0
man -- 9568 0 0 139 0 0
www-data -- 2908 0 0 15 0 0
nobody -- 0 0 0 1 0 0
libuuid -- 24 0 0 2 0 0
Debian-exim -- 44 0 0 10 0 0
mysql -- 30116 0 0 141 0 0
ftpuser -- 8 1000000 1048576 2 0 0

Optional: Specify A Grace Period


To give current users some time to reduce their files on the droplet, a grace period can
be configured. This is the allowed time a user can exceed their soft limit, while still
staying under the hard limit. The grace time is configured using the following
command [notice that this is system wide; no user specific configuration is possible].
The grace period can be expressed in seconds, minutes, hours, days, weeks or months.

edquota -t

The command gives the following output and specifies the different time unites that
could be used. For this guide, a grace period of 7 days is used.

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/disk/by-label/DOROOT 7days 7days

Conclusion
The quotas will be automatically updated and enforced when a user
transfers/creates/moves/deletes a file/folder. Remember that the quota program works
by looking at the owner or group of a specific file/folder. SSH users could escape the
quotas by changing the owner or group of their files.

Article Submitted by: Jan Stevens

By Jan Stevens
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 6/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

Upvote (7)  Subscribe  Share

Related Tutorials
How to Add and Delete Users on Ubuntu 16.04
How To Download Software and Content onto your Linux VPS
An Introduction to Useful Bash Aliases and Functions

An Introduction To Regular Expressions


How To Use Bash History Commands and Expansions on a Linux VPS

15 Comments

Leave a comment...

Log In to Comment

gparent February 4, 2014

0 This tutorial has many typing mistakes, and doesn't work as-is.

Please revise and actually test? There shouldn't be spaces in the middle of mounting
options.
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 7/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

etel February 4, 2014

0 Thanks, I've updated the piece

joaoaamarques February 5, 2014

1 Can you please give me a hand?

I'm getting the following error:


# quotaon /
quotaon: using //quota.group on /dev/disk/by-label/DOROOT [/]: No such process
quotaon: Quota format not supported in kernel.
quotaon: using //quota.user on /dev/disk/by-label/DOROOT [/]: No such process
quotaon: Quota format not supported in kernel.

danielleandro February 10, 2018

0 I have the same problem here using CentOS 7.

uname-a
vbolinsp01.domain 3.10.0-693.el7.x8664 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x8664 x8664
x8664 GNU/Linux

@joaoaamarques did you solve that? Can someone help me, please?

Thanks.

kamaln7 MOD February 8, 2014

0 @Joao: What's the output of uname -a and what OS are you using?

arajparaj July 10, 2014

0 What if I have to add quota imits to a large number of users?

kamaln7 MOD July 10, 2014

0 @arajparaj: Simply run edquota username for each user that you want to set a quota limit to.

Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 8/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

nurmanhabib October 23, 2015

0 I've added a new user:

useradd -d /home/habib -s /sbin/nologin habib

I already gave further limit the user habib:

edquota habib

Editor:

Disk quotas for user habib (uid 1002):


Filesystem blocks soft hard inodes soft hard
/dev/disk/by-uuid/e1f7df1f-..... 0 10000 10240 0 0

but after I try to save and check the quota Habib, the results are:

Disk quotas for user habib (uid 1002): none

There is an error where? Thank you.

manyk October 11, 2016

1 It looks the Ubuntu 16.04 LTS image (at least the 32bit) from DO mirrors is missing the quota
module even if the config have the options for quota active.

manyk October 12, 2016

0 The only solution to this issue is to reinstall another image of the kernel who has Quota
modules.

Try this way:


apt-get remove linux-image-*
apt-get
Sign up forinstall linux-image-extra-virtual
our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 9/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

Reboot (preferrably from the DO console - use 'Power Off' followed by 'Power On' to allow the
hypervisor to pickup the status changes).

Then run modprobe quotav2 and modprobe quotav1 in order to get ready to run quotas and
continue with the rest of the configuration to have the quotas up and running.

allonhadaya October 13, 2016

0 @manyk

Your instructions helped me in a similar situation, thanks!

I needed to tweak this step: modprobe quota_v2 and modprove quota_v1 -- notice the
underscore

manyk October 14, 2016

0 @allonhadaya

You are right. The correct form of those commands includes underline between quota and
v1/2.
Thanks for pointing that out.

lukasoppermann December 12, 2016

0 Sadly this does not work for me, no error, but while the quota is shown, I is not enforced.

I am guessing all things like LABEL=DOROOT need to be replaced by something? If so, with
what do I need to replace it?

When I open edquota I have this listed: /dev/vda1 instead of /dev/disk/by-label/DOROOT ,


what do I do here?

jtittle1 January 22, 2017

1 @etel

Needs updating as this does not work on Ubuntu 16.04 or 16.10, even with the extra commands
noted
Sign byour
up for other users.Get the latest tutorials on SysAdmin and open source topics.
newsletter. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 10/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

leanazar June 20, 2018

0 hi i have a problem to enable quota

root@panel:/usr/sbin# quotaon /
quotaon: using //quota.group on /dev/vda1 [/]: No such process
quotaon: Quota format not supported in kernel.
quotaon: using //quota.user on /dev/vda1 [/]: No such process
quotaon: Quota format not supported in kernel.

Thanks

This work is licensed under a Creative


Commons Attribution-NonCommercial-
ShareAlike 4.0 International License.

BECOME A CONTRIBUTOR

You get paid; we donate to tech


nonprofits.
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 11/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

CONNECT WITH OTHER DEVELOPERS

Find a DigitalOcean Meetup


near you.

GET OUR BIWEEKLY NEWSLETTER

Sign up for Infrastructure as a


Newsletter.

Featured on Community Intro to Kubernetes Learn Python 3 Machine Learning in Python


Getting started with Go Migrate Node.js to Kubernetes

DigitalOcean Products Droplets Managed Databases Managed Kubernetes


Spaces Object Storage Marketplace

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the


cloudGet
Sign up for our newsletter. and
thescale up as
latest tutorials onyou grow
SysAdmin and– whether
open you’re
source topics. ×
running
Enter your email address one virtual machine or tenSign
thousand.
Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 12/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

Learn More

Company Products

About Products Overview


Leadership Pricing
© 2019 DigitalOcean, LLC. All rights reserved.
Blog Droplets
Careers Kubernetes
Partners Managed Databases
Referral Program Spaces
Press Marketplace
Legal & Security Load Balancers
Block Storage
Tools & Integrations
API
Documentation

Release Notes

Community Contact

Tutorials Support
Q&A Sales
Projects and Integrations Report Abuse
Tags System Status
Product Ideas
Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics.
Meetups ×
Enter your email address Write for DOnations Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 13/14
8/20/2019 How To Enable User and Group Quotas | DigitalOcean

Droplets for Demos


Hatch Startup Program
Shop Swag
Research Program
Currents Research

Open Source

Sign up for our newsletter. Get the latest tutorials on SysAdmin and open source topics. ×
Enter your email address Sign Up
https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas 14/14

You might also like