Bright:Setup user quotas

From Define Wiki
Revision as of 10:58, 19 December 2014 by David (talk | contribs)
Jump to navigation Jump to search

Setup quotas within /etc/fstab

  • Need to add usrquota,grpquota to the /etc/fstab file for the home dir mount point
  • Lets check the home mount point (in this instance its just / for bright)
[root@trainning ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/md126      426G   14G  392G   4% /
tmpfs            16G   84K   16G   1% /dev/shm
/dev/md125      496M   24M  447M   6% /boot
  • Lets update the /etc/fstab file with the parameters usrquota,grpquota for user mount points.
[root@trainning ~]# cat /etc/fstab 
UUID=9586a511-9b87-48e1-8749-f5fa0ebabd01 /                              ext3       defaults,noatime,nodiratime,usrquota,grpquota              0 1
UUID=6b542d80-a228-47bc-9e39-831f37bc074c /boot                          ext2       defaults,noatime,nodiratime              0 2
UUID=5e9078a4-9975-4659-839f-9749ceb8ab02 swap                           swap       defaults                                 0 0
proc		/proc	proc	defaults,nosuid	0 0
sysfs		/sys	sysfs	noauto	0 0
devpts		/dev/pts	devpts	mode=0620,gid=5	0 0
tmpfs		/dev/shm	tmpfs	defaults	0 0

# This section of this file was automatically generated by cmd. Do not edit manually!
# BEGIN AUTOGENERATED SECTION -- DO NOT REMOVE
# END AUTOGENERATED SECTION   -- DO NOT REMOVE
  • Remount the filesystem and verify the args in mtab
[root@trainning ~]# mount -o remount /
[root@trainning ~]# cat /etc/mtab
/dev/md126 / ext3 rw,noatime,nodiratime,usrquota,grpquota 0 0
proc /proc proc rw,nosuid 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
tmpfs /dev/shm tmpfs rw 0 0
/dev/md125 /boot ext2 rw,noatime,nodiratime 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
nfsd /proc/fs/nfsd nfsd rw 0 0
gvfs-fuse-daemon /root/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev 0 0

Create the Quota Database

  • Note: For Bright because the / folder is used and cannot be mounted read-only, we needed for force the initial check
  • Note: This took a few mins to run


  • Perform an initial check of the system
[root@trainning ~]# quotacheck -cug /
quotacheck: Cannot remount filesystem mounted on / read-only so counted values might not be right.
Please stop all programs writing to filesystem or use -m flag to force checking.
[root@trainning ~]# quotacheck -cugm /
  • After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled:
[root@trainning ~]# quotacheck -avugm
quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
quotacheck: Scanning /dev/md126 [/] done
quotacheck: Checked 24615 directories and 249780 files

Set a user quota

  • Use the edquota command. We'll need to set soft and hard limits here. The number are based on KB so scale up for GB
  • E.g. 5GB limit
[david@hairybacon-2 ~]$ echo "5 * 1024 * 1024" | bc 
5242880
  • Set the limit using 5242880
[root@trainning ~]# edquota david
# which will provide you with a vi screen with the following, edit numbers as below
Disk quotas for user david (uid 1003):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/md126                       60    5242880    5242880         15        0        0
  • Turn quotas on
$ quotaon -a

Verify the user quota

  • check using the quota command
[root@trainning ~]# edquota -u david -f / 
[root@trainning ~]# quota -u david
Disk quotas for user david (uid 1003): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
     /dev/md126      60  5242880 5242880              15       0       0
      • TBC created file, met limits, removed files, says limit exceeded!?