X

Rate Us :



Share with Friends :

Menu

Disk Quotas in Linux :

Quotas are used to restrict the amount of hard disk space occupied by the user or a group.

Group level quota can only be applied to primary groups. Generally, quotas can only be applied on primary groups.

Quotas can only be applied on quota enabled partitions.


Quotas can be applied in two different ways :


  • Based on the number of inodes (number of files)




  • Based on the number of blocks (volume of hard disk space)




There are two types of Quota limits :


  • Soft - This quota limit will only warn the user that they have reached their quota limit.

  • Hard - This quota limit will not allow the user to create any more files and directories once the quota limit has reached.

Configure Disk Quota :


To create a partition - [root@localhost~]#fdisk /dev/sda Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +1GB Command (m for help): p [lets say we already have 9 partition available so, the new partition will be /dev/sda10] Command (m for help): w To update new partition table without restarting the OS - [root@localhost~]#partprobe /dev/sda [for CentOS 7 or RHEL 7] [root@localhost~]#partx -a /dev/sda [for CentOS 6 or RHEL 6] Format the partition to create file system - [root@localhost~]#mkfs.ext4 /dev/sda10 [ext4 is a file system] Create a directory - [root@localhost~]#mkdir /dir1 Mount with quota enable permission - [root@localhost~]#mount -o usrquota , grpquota /dev/sda10 /dir1 Create quota database file - [root@localhost~]#quotacheck -cug /dir1 [c => create, u => user, g => group] Enable the disk quota - [root@localhost~]#quotaon /dir1 Give full permission to quota enabled partition - [root@localhost~]#chmod 777 /dir1 Create a user - [root@localhost~]#useradd algouser Apply quota limits for user - [root@localhost~]#edquota -u algouser The file will be opened, go to insert mode by pressing i/I/o/O/a/A (any one of them) then write : inode soft hard 0 5 7 Then go to Ex: mode by pressing Esc then Shift + : and type wq to save and exit. Login with algouser - [root@localhost~]#su - algouser Enter into quota enabled partition - [algouser@localhost~]$cd /dir1 Create files - [algouser@localhost~/dir1]$touch file{1..10} To logout - [algouser@localhost~/dir1]$exit