Implementing disk quota in Linux

Quota can be implemnted in two ways.

On inode

On Block

Here I am mentioning the quota implentation in Block. A block usually represents one least size on a disk, usually one block equal to 1kb.

Soft limit : This is the disk limit where the user gets just a warning message saying that your disk quota is going to expire. This is just a warning, no restriction on data creation will occur at this point.

Hard limit : This is the disk limit where user gets error message, I repeat user gets error message stating that unable to create data.

Implementing QUOTA :

Step1 : Select/prepare the partition for quota, most of the time disk quota is implemented for restricting users not to create unwanted data on servers, so we will implement disk quota on /home mount point.

#vi /etc/fstab

Edit the /home mount point as follows

Before editing

/dev/hda2 /home ext3 defaults 0 0

after editing

/dev/hda2 /home ext3 defaults,usrquota 0 0

Step2 : Remounting the partition(this is done because the mount table should be updated to kernel). Other wise you can reboot the system too for updating of mount table, which is not preferred for live servers.

#mount -o remount,rw /home

Here -o specifies options, with remounting /home partition with read and write options.

Step3 : Creating quota database

#quotacheck -cu /home

The option -c for creating disk quota DB and u for user

Check for user database is created or not when you give ls /home you have to see auota.user file in /home directory,which contains user database.

Step4 : Switching on quota

#quotaon /home

Now get the report for default quota values for user surendra

#repquoata -a | grep surendra

surendra_anne — 4 0 0 1 0 0

surendra_a — 4 0 0 1 0 0

surendra_test — 16 0 0 4 0 0

Step5 : Now implementing disk quota for a user on /home mount point(/dev/hda2)

#setquota -u surendra_anne 100 110 0 0 /dev/hda2

Step6 : Checking quota is implemented or not login to user surendra_anne and execute this command

#repquota -a



Here if 100MB is reached user will get an warning message saying, and when he reaches 110MB he can not create any more data.

Removing quota :

To do this one, all the users should log out from the system so better do it in runlevel one.

Step8 : Stop the disk quota

#quotaoff /home

Step9 : Removing quota database which is located /home

#rm /home/aquota.user

Step10 : Edit fstab file and remove usrdata from /home line

#vi /etc/fstab

Before editing

/dev/hda2 /home ext3 defaults,usrquota 0 0

After editing

/dev/hda2 /home ext3 defaults 0 0

Step11 : Remount the /home partition

#mount -o remount,rw /home

That’s it you are done with Disk Quota Implementation in Linux. Now test your self in creating Linux user disk quota on your own.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s