What is Quota-
Quota allows you to specify limits on two aspects of disk storage: the number of inodes a user or a group of users may possess; and the number of disk blocks that may be allocated to a user or a group of users.
OR
Quota is use to define a space limitation for http or ftp users over the network.
Features-
1. Limit storage consumption per group/user.
2. Base on : disk block usage or inode usage
Quota Types-
1. Soft Quota- For example, if you specify 1GB as soft limit, user will get a warning message “disk quota exceeded”, once they reach 1GB limit. But, they’ll still be able to create new files until they reach the hard limit
2- Hard Quota- For example, if you specify 2GB as hard limit, user will not be able to create new files after 2GB
Quota Implemination in linux-
1. Block Wise- Disk quota
2. Indoe wise- File quota or Contain quota
Note-
Inode-
In Linux every object is consider as file, every file will be having an inode number associated and this is very much easy for computer to recognise where the file is located.
Inode stands for Index Node, and is the focus of all file activities in the UNIX file-system.
Each file has one inode that defines the file’s type (regular, directory, device etc),The location on disk, The size of the file, Access permissions, Access times.
Note that the file’s name is not stored in the inode.
How to know what is your file Inode number-
Its just simple execute ls -i on your file.
# ls -i xmls.txt
13662 xmls.txt
I think now you got what is INODE? Lets move on to BLOCK.
A block usually represents one least size on a disk, usually one block equal to 1kb. Some terms in Disk quota.
Quota Profile-
Name- userquota,grpquota
Package- quota-3.17-20.el6.i686 or quota*
Commands- quotaon, quotaoff, quotacheck, repquota, edquota
Configure quota in linux-
1- Create a partition
# fdisk /dev/sda
# partx -a /dev/sda
2- Format partition and mount in folder.
# mkfs.ext4 /dev/sad5
# mkdir /quota
# mount /dev/sda5 /quota
# mount
# df -h
3- Now mount permanently in /etc/fstab file
# vim /etc/fstab
_________________________________________________________
/dev/sda5 /quota ext4 defaults 0 0
_________________________________________________________
4- Create a user account-
# adduser quota-1
# adduser quota-2
# passwd quota-1
# passwd quota-2
5- Change permission
# chmod 777 /quota
6- Just enable quota on disk-
# vim /etc/fstab
____________________________________________________________________________
/dev/sda5 /quota ext4 defaults,usrquota,grpquota 0 0
____________________________________________________________________________
wq:
7- Just refresh the disk labels-
# mount -o remount,usrquota,grpquota,rw /quota
8- To check quota enable on disk or not
# mount | grep /quota
/dev/sda7 on /quota type ext4 (rw,usrquota,grpquota,usrquota,grpquota)
9- Now Create quota database file and generate disk usage table- define baseline-
'quotacheck -mcug /home' -applies user and group quota
# quotacheck --help
# quotacheck -mcug /quota
# cd /quota
# ls
Note-
-m do not remount filesystem read-only
-c create new quota files
-u check user files
-g check group files
Note- 'quotacheck' Should be run in: Single-user mode OR when the system reboots to facilitate:
read-only remount of target file system
10- Check defined quota database or Now on quota fetures-
'quotacheck -amvug' -check quotas
# quotacheck -amvug
# du -ch /home (Check no. of directory or file)
Note-
-a check all filesystems
-m do not remount filesystem read-only
-v display version information and exit
-u check user files
-g check group files
11- Assign quota polcies per user and/or group-
# edquota quota-1 (quota-1 ia a user name)
__________________________________________________________________________________________
Disk quotas for user quota-1 (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 0 10240 20480 0 0 0
__________________________________________________________________________________________
Note-
1 Block is equal to 1 KB.
soft- 10240 = 10MB
hard- 20480 = 20MB
OR
# setquota -u quota-1 10240 20480 0 0 /dev/sda7
now refresh--
# mount -o remount,usrquota,grpquota,rw /quota
12- Checking quota is implemented or not login to user quota-1 and execute this command-
# repquota -a
OR
# repquota -vug -a
OR
# quota
13- Keep creating data, once 10MB is reached user will get an warning message saying, and when he reaches 20MB he can not create any more data.
Hint- To create a data file you can use seq command as below
# seq 1 10000 > test.txt
this command will create a file with 10000 lines with numbers in it.
14- Indoe wise-
# edquota quota-2 (quota-1 ia a user name)
_________________________________________________________________________________________
Disk quotas for user quota-2 (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 0 0 0 0 5 8
_________________________________________________________________________________________
OR
# setquota -u quota-1 0 0 5 8 /dev/sda7
now refresh--
# mount -o remount,usrquota,grpquota,rw /quota
Check--
# repquota -a
or
# repquota -vug -a
OR
# quota
15- How to change or up/down grace period-
-> Grace Period- For example, if you specify 10 days as a grace period, after user reach their hard limit, they would be allowed additional 10 days to create new files. In that time period, they should try to get back to the quota limit.
# eduquota -T quota-1
_____________________________________________________________________________
Times to enforce softlimit for user quota-1 (uid 503):
Time units may be: days, hours, minutes, or seconds
Filesystem block grace inode grace
/dev/sda7 unset unset
_____________________________________________________________________________
=============================================================
How to Removing quota -
To do this one, all the users should log out from the system so better do it in runlevel one.
1- Stop the disk quota
# quotaoff /quota
2- Removing quota database which is located /quota
# rm -rvf /home/aquota.user
3- Edit fstab file and remove usrdata from /quota line
# vim /etc/fstab
4- Remount the /quota partition
# mount -o remount,rw /quota
============================================================
Note-
1- repquota
repquota prints a summary of the disc usage and quotas for the specified
file systems
2- setquota
setquota is a command line quota editor. The filesystem, user/group name
and new quotas for this filesystem can be specified on the command line.
3- Quotacheck
Quotacheck examines each filesystem, builds a table of current disk usage,
and compares this table against that recorded in the disk quota file for
the filesystem (this step is ommitted if option -c is specified).
4- edquota
Edquota is a quota editor. One or more users or groups may be specified
on the command line.
Q. What command should you use to check the number of files and disk space used and each user’s defined quotas?
repquota
I hope you like it.
So Enjoy............................!
_____________________________________________________________________________________________
Quota allows you to specify limits on two aspects of disk storage: the number of inodes a user or a group of users may possess; and the number of disk blocks that may be allocated to a user or a group of users.
OR
Quota is use to define a space limitation for http or ftp users over the network.
Features-
1. Limit storage consumption per group/user.
2. Base on : disk block usage or inode usage
Quota Types-
1. Soft Quota- For example, if you specify 1GB as soft limit, user will get a warning message “disk quota exceeded”, once they reach 1GB limit. But, they’ll still be able to create new files until they reach the hard limit
2- Hard Quota- For example, if you specify 2GB as hard limit, user will not be able to create new files after 2GB
Quota Implemination in linux-
1. Block Wise- Disk quota
2. Indoe wise- File quota or Contain quota
Note-
Inode-
In Linux every object is consider as file, every file will be having an inode number associated and this is very much easy for computer to recognise where the file is located.
Inode stands for Index Node, and is the focus of all file activities in the UNIX file-system.
Each file has one inode that defines the file’s type (regular, directory, device etc),The location on disk, The size of the file, Access permissions, Access times.
Note that the file’s name is not stored in the inode.
How to know what is your file Inode number-
Its just simple execute ls -i on your file.
# ls -i xmls.txt
13662 xmls.txt
I think now you got what is INODE? Lets move on to BLOCK.
A block usually represents one least size on a disk, usually one block equal to 1kb. Some terms in Disk quota.
Quota Profile-
Name- userquota,grpquota
Package- quota-3.17-20.el6.i686 or quota*
Commands- quotaon, quotaoff, quotacheck, repquota, edquota
Configure quota in linux-
1- Create a partition
# fdisk /dev/sda
# partx -a /dev/sda
2- Format partition and mount in folder.
# mkfs.ext4 /dev/sad5
# mkdir /quota
# mount /dev/sda5 /quota
# mount
# df -h
3- Now mount permanently in /etc/fstab file
# vim /etc/fstab
_________________________________________________________
/dev/sda5 /quota ext4 defaults 0 0
_________________________________________________________
4- Create a user account-
# adduser quota-1
# adduser quota-2
# passwd quota-1
# passwd quota-2
5- Change permission
# chmod 777 /quota
6- Just enable quota on disk-
# vim /etc/fstab
____________________________________________________________________________
/dev/sda5 /quota ext4 defaults,usrquota,grpquota 0 0
____________________________________________________________________________
wq:
7- Just refresh the disk labels-
# mount -o remount,usrquota,grpquota,rw /quota
8- To check quota enable on disk or not
# mount | grep /quota
/dev/sda7 on /quota type ext4 (rw,usrquota,grpquota,usrquota,grpquota)
9- Now Create quota database file and generate disk usage table- define baseline-
'quotacheck -mcug /home' -applies user and group quota
# quotacheck --help
# quotacheck -mcug /quota
# cd /quota
# ls
Note-
-m do not remount filesystem read-only
-c create new quota files
-u check user files
-g check group files
Note- 'quotacheck' Should be run in: Single-user mode OR when the system reboots to facilitate:
read-only remount of target file system
10- Check defined quota database or Now on quota fetures-
'quotacheck -amvug' -check quotas
# quotacheck -amvug
# du -ch /home (Check no. of directory or file)
Note-
-a check all filesystems
-m do not remount filesystem read-only
-v display version information and exit
-u check user files
-g check group files
11- Assign quota polcies per user and/or group-
# edquota quota-1 (quota-1 ia a user name)
__________________________________________________________________________________________
Disk quotas for user quota-1 (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 0 10240 20480 0 0 0
__________________________________________________________________________________________
Note-
1 Block is equal to 1 KB.
soft- 10240 = 10MB
hard- 20480 = 20MB
OR
# setquota -u quota-1 10240 20480 0 0 /dev/sda7
now refresh--
# mount -o remount,usrquota,grpquota,rw /quota
12- Checking quota is implemented or not login to user quota-1 and execute this command-
# repquota -a
OR
# repquota -vug -a
OR
# quota
13- Keep creating data, once 10MB is reached user will get an warning message saying, and when he reaches 20MB he can not create any more data.
Hint- To create a data file you can use seq command as below
# seq 1 10000 > test.txt
this command will create a file with 10000 lines with numbers in it.
14- Indoe wise-
# edquota quota-2 (quota-1 ia a user name)
_________________________________________________________________________________________
Disk quotas for user quota-2 (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 0 0 0 0 5 8
_________________________________________________________________________________________
OR
# setquota -u quota-1 0 0 5 8 /dev/sda7
now refresh--
# mount -o remount,usrquota,grpquota,rw /quota
Check--
# repquota -a
or
# repquota -vug -a
OR
# quota
15- How to change or up/down grace period-
-> Grace Period- For example, if you specify 10 days as a grace period, after user reach their hard limit, they would be allowed additional 10 days to create new files. In that time period, they should try to get back to the quota limit.
# eduquota -T quota-1
_____________________________________________________________________________
Times to enforce softlimit for user quota-1 (uid 503):
Time units may be: days, hours, minutes, or seconds
Filesystem block grace inode grace
/dev/sda7 unset unset
_____________________________________________________________________________
=============================================================
How to Removing quota -
To do this one, all the users should log out from the system so better do it in runlevel one.
1- Stop the disk quota
# quotaoff /quota
2- Removing quota database which is located /quota
# rm -rvf /home/aquota.user
3- Edit fstab file and remove usrdata from /quota line
# vim /etc/fstab
4- Remount the /quota partition
# mount -o remount,rw /quota
============================================================
Note-
1- repquota
repquota prints a summary of the disc usage and quotas for the specified
file systems
2- setquota
setquota is a command line quota editor. The filesystem, user/group name
and new quotas for this filesystem can be specified on the command line.
3- Quotacheck
Quotacheck examines each filesystem, builds a table of current disk usage,
and compares this table against that recorded in the disk quota file for
the filesystem (this step is ommitted if option -c is specified).
4- edquota
Edquota is a quota editor. One or more users or groups may be specified
on the command line.
Q. What command should you use to check the number of files and disk space used and each user’s defined quotas?
repquota
I hope you like it.
So Enjoy............................!
_____________________________________________________________________________________________