-- MikeGore - 19 Jan 2011

Quotas

Note: recommend using the quotaset script below - it is way easier to use

Resources

Verify system Quota options available

  • Run quotacheck I see we have jurnalled quotas
    • quotacheck -vagum
   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: Quota for users is enabled on mountpoint / so quotacheck might
   damage the file.
   Please turn quotas off or use -f to force checking.
  • Verify kernel config options for jurnalled quotas * grep QUOTA /boot/config-`uname -r`
   CONFIG_NETFILTER_XT_MATCH_QUOTA=m
   CONFIG_PRINT_QUOTA_WARNING=y
   CONFIG_QUOTA=y
   CONFIG_QUOTACTL=y
   CONFIG_QUOTA_NETLINK_INTERFACE=y
   CONFIG_XFS_QUOTA=y

Manual remount with quotas turned on

Notes: /home /usb /usb_backup
   mount /dev/sdd1 /home -o
   remount,rw,relatime,errors=remount-ro,usrjquota=aquota.user,jqfmt=vfsv0
   mount /dev/sdc1 /usb1 -o
   remount,rw,relatime,errors=remount-ro,usrjquota=aquota.user,jqfmt=vfsv0
   mount /dev/sdd1 /usb1_backup -o
   remount,rw,relatime,errors=remount-ro,usrjquota=aquota.user,jqfmt=vfsv0

How to assign quota inodes

*Notes: setquota want to know the number of inodes to assign a user - directory entries
  • Syntax: setquota -u userid blocks_soft blocks_hard files_soft files_hard /mount_pount
  • /home
    • dumpe2fs /dev/sdb1 | more
   Filesystem volume name:   home
   Inode count:              4481024
   Block count:              17920499
   Free blocks:              16009141
   Free inodes:              4397275
   Block size:               4096
Notes
   We have 1 inode for every 4 blocks so with quotas we will give the user blocks/4 inodes
   So for a 1G quota we have 1G/4096 blocks = 244140.625 and inodes would be 61035

Quota Example

Example:
  • setquota -u userid 1000000 1500000 61035 75000 -a /home
    • Set 1G quota on normal users. See Quota section below for description of arguments
    • Quick summary: 1000000 = 1G in 1K blocks,1500000 = 1.5G grace
      • 61035 = 1G / 4096 / 4
      • 4 is the number of blocks per inode as determined from dumpe2fs
      • 4096 is the block size as determined from e2fs
    • -a /home is the mounted home file system - not the users home directory

Quota script

Simplifies the calulations once they are known for a filesystem

  • usage: ./script user size_in_K file_system_mount_point
#!/bin/bash
#
# 3 Dec 2012 Mike Gore

if (($# < 3))
then
   echo Usage: $0 user size_in_K file_system_mount_point
   exit 1
fi

user=$1
mysize=$2
fs=$3
mygrace=$(($mysize * 3 /2 ))
echo Grace: $mygrace

myinodes=$(($mysize / 4 / 4))
myinodes_grace=$(($myinodes * 3 / 2))

echo setquota -u $user $mysize $mygrace $myinodes $myinodes_grace -a $fs
setquota -u $user $mysize $mygrace $myinodes $myinodes_grace -a $fs

Initializing quotas

  • quotaoff -a
  • 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/sda1 [/] done
   quotacheck: Checked 25324 directories and 240273 files
   quotacheck: Scanning /dev/sdb1 [/home] done
   quotacheck: Old group file not found. Usage will not be substracted.
   quotacheck: Checked 3998 directories and 79760 files
   quotacheck: Scanning /dev/sdc1 [/usb1] done
   quotacheck: Cannot stat old user quota file: No such file or directory
   quotacheck: Old group file not found. Usage will not be substracted.
   quotacheck: Checked 29309 directories and 320418 files
   quotacheck: Old file not found.
   quotacheck: Scanning /dev/sdd1 [/usb1_backup] done
   quotacheck: Cannot stat old user quota file: No such file or directory
   quotacheck: Old group file not found. Usage will not be substracted.
   quotacheck: Checked 29311 directories and 320418 files
   quotacheck: Old file not found.
  • quotaon -a

Setting default user quotas example for elora.cs

  • Settings: 1G on /home 10G on /usb1 and usb1_backup
  • cat /cscf-adm/scripts/update_quota
   #!/bin/bash
   #
   # Mike Gore
   # Apr 28, 2009

   NOLIMIT="glabahn jorchard jwlwan paforsyt rbsimpso jageorge kvetzal yuying"

   USERS="acbelang amemarto aramotar b39wang csbmorle gxshen j27wang jwlwan l8xu lost+found momanovi myakhave nmhelsai polsar t2dravia tbian wjxiao ynzhang yq
   huang z4chen"

   NOLIMIT="glabahn jorchard jwlwan paforsyt rbsimpso jageorge kvetzal yuying"

   USERS="acbelang amemarto aramotar b39wang csbmorle gxshen j27wang jwlwan l8xu lost+found momanovi myakhave nmhelsai polsar t2dravia tbian wjxiao ynzhang yq
   huang z4chen"

   #turn off quotas
   quotaoff -a

   #setquota -u userid blocks_1k_max blocks_1k max_grace inodes_max inodes_max_grace
   # inodes = files, we have 4096 bytes per inode so we just assign that number
   # grace is the ammount they can go over for the grace period

   # 1G on /home
   for i in $USERS
   do
      echo $i
      setquota -u $i 1000000 1500000 61035 75000 -a /home
   done
   # 10G on /usb1
   for i in $USERS
   do
      echo $i
      setquota -u $i 10000000 15000000 61035 75000 -a /usb1
   done
   # 10G on /usb1_backup
   for i in $USERS
   do
      echo $i
      setquota -u $i 10000000 15000000 61035 75000 -a /usb1_backup
   done

   #turn on quotas
   quotaon -a
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2012-12-03 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback