QUOTA
Well… what is this quota system ?
Suppose I have a 73g HDD, in which I had
given 30g for /export/home, I have 40 users in system.
This is a fair amount I had given for users, but I have no control over
their uses, which users is consuming how much disk
Space is completely unknown to me until I run a scan, it might be
possible that a single user can use 25g alone, in that case what should I have
to do?
After listening so much complaint from other users I will run
#du –hk |sort –n
Then I came to know that … ohhh… this particular user is culprit, and
then shoot a mail to that user to remove his/her files
And warn to not do this again.
This level is might be acceptable … but what if this situation occurred
in every 2-3 days by different users ?
So better limit their uses rather than useless scan and warnings.
Fine… Now we understand the need for existence of quota
Well… now we understand to implement the quota
** Quota is implemented on Directories but enabled on File System
There are two consideration while implementing quota
1.) HARD LIMIT
2.) SOFT LIMIT
Well… Let’s consider an example of Digital TV recharge … what happen
when we have 6-7 days left for our renewal?
We are continuously started getting messages that
“Please recharge your digital TV within so & so date to avoid discontinuity,
after so & so date your connection will be terminated”
Well… due to some reason I had ignored this message and did not recharged…
and my digital TV connection has stopped working.
This example is just to understand better the concept of Hard &
Soft limit.
The reminder messages are example of soft limit & the service has
been stopped is Hard Limit
Let’s make it simpler,
Suppose HARD LIMIT is 200mb
SOFT
LIMIT is 175mb
Soft limit is bound with timer in days
[we will get continuous warnings
in those days about soft limit exceed]
By default soft limit timer is 7 days
I am the users and I had crossed the soft limit of 175mb, I will start
getting continuous warnings for limit exceed until the timer expires or I reach
the hard limit
There are 2 circumstances in this case,
Either I delete some file and let me under 175mb or I ignore the
warning and continue my uses
Well in first case the warning messages will stop and there is no
problem, but in second scenario where I had ignored the warnings and continue
my uses,
Suppose I reached to 187mb [still I am 13mb behind my Hard Limit] and 7
days timer expired, then what should happen ?
According to HARD/SOFT statement I am still at safe side … but no…
Because I did not let me myself under soft limit and I continue to
enjoy warnings and consumed 187mb … so this will be my new hard limit.
Well… I think this is fair enough explanation to understand the
concept.
Now move to Implementation
STEPS –
1.)
Make an entry of rq in mount option of
/etc/vfstab , so that on each reboot quotas will be in action
2.)
Create quotas file in the top level directory of
file system where quota is to be implemented
3.)
Use 1st quota as prototype to
configure other users quota
4.)
Set permission on quotas file ( rw for root only)
5.)
Apply quota on users
root@sol-test-2:>/# vi /etc/vfstab
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /export/home ufs
2 yes -
(this I got by default)
I need to change that like
/dev/dsk/c1t0d0s5
/dev/rdsk/c1t0d0s5
/export/home ufs 2
yes rq
Save & quit
root@sol-test-2:>/# cd /export/home/
root@sol-test-2:>/export/home# touch quotas
root@sol-test-2:>/export/home# chmod 600 quotas
root@sol-test-2:>/export/home# ls -l
total 30
drwxr-xr-x 2 root root 512 Sep 8 19:52 anurag
drwx------ 2 root root
8192 Aug 16 19:00 lost+found
-rw------- 1 root root 0 Sep 8 19:32 quotas
drwxr-xr-x 2 t2user1 other
512 Sep 8 19:55 t2user1
drwxr-xr-x 2 t2user2 other
512 Sep 8 19:55 t2user2
drwxr-xr-x 2 t2user3 other
512 Sep 8 19:56 t2user3
drwxr-xr-x 2 t2user4 other
512 Sep 8 19:56 t2user4
drwxr-xr-x 2 t2user5 other
512 Sep 8 19:56 t2user5
drwxr-xr-x 2 root root 512 Sep 8 19:55 vikash
NOW time to enable quota…
But wait… quota will understand kb… better to convert our mb in kb
30000/1024 =29mb
20000/1024 =19mb
root@sol-test-2:>/# edquota t2user1
"/tmp/EdP.a4waGc2" 1 line, 72 characters
fs /export/home blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)
what I did to enable quota ?, I used edquota <username> after that I got vi editor where I have to
put the HARD/SOFT limit…. Wait a minute
what is this inode limit ?
well … via inode limit we can restrict user by limiting the no of files
created , suppose we did 10 hard limit and 7 soft for inode… it means that user
can create 10 files of any size , rest of the concept of hard/soft is same
So better to stick with size limitation.
Let’s put the limit and see what happen…
root@sol-test-2:>/# edquota t2user1
"/tmp/EdP.a4waGc2" 1 line, 72 characters
fs /export/home blocks (soft = 20000, hard = 30000) inodes (soft = 0,
hard = 0) wq!
Now let’s check what happened,
root@sol-test-2:>/# quota -v t2user1
Disk quotas for t2user1 (uid 105):
Filesystem usage quota
limit timeleft files
quota limit timeleft
/export/home 29993 20000
30000 - -
- - -
Good…quota has been set for user t2user1… but we need to enable it on
File System
root@sol-test-2:>/# quotaon -v /export/home
/export/home: quotas turned on
*mind it using tab completion in bash… it will give u following error , B’coz
of an extra / in last of home
root@sol-test-2:>/# quotaon /export/home/
Cannot do /export/home/
Well… Now I want that the time limit should be 1 day … Fine
root@sol-test-2:>/# edquota -t t2user1
"/tmp/EdP.a6xaWc2" 1 line, 80 characters
fs /export/home blocks time limit = 1 (default), files time limit = 0
(default)
Now Lets check the quota status on entire file system
root@sol-test-2:>/# repquota -v /export/home
/dev/dsk/c1t0d0s5 (/export/home):
Block
limits File limits
User used soft
hard timeleft used
soft hard timeleft
anurag -- 0
20000 30000 0 0
0
t2user1 -- 0
20000 30000 0 0
0
only 2 users has quota set…we can see their details
Now check the quota is working or not ?
root@sol-test-2:>/# su - t2user1
Oracle Corporation SunOS 5.10 Generic Patch January 2005
-bash-3.2$ /usr/sbin/mkfile 10m file1
-bash-3.2$ du -sh
10M .
-bash-3.2$ ls -l
total 20502
-rw------- 1 t2user1 other
10485760 Sep 8 20:31 file1
-rw-r--r-- 1 t2user1 other
136 Sep 8 19:55 local.cshrc
-rw-r--r-- 1 t2user1 other
157 Sep 8 19:55 local.login
-rw-r--r-- 1 t2user1 other
174 Sep 8 19:55 local.profile
-bash-3.2$ /usr/sbin/mkfile 10m file2
quota_ufs: Warning: over disk limit (pid
27681, uid 105, inum 34, fs /export/home) SL warn
-bash-3.2$ du -sh
20M .
-bash-3.2$ /usr/sbin/mkfile 5m file3
-bash-3.2$ du -sh
25M .
-bash-3.2$ /usr/sbin/mkfile 10m file
quota_ufs: over hard disk limit (pid 27685, uid 105, inum 36, fs
/export/home) HL warn
file4: initialized 4456448 of
10485760 bytes: Disc quota exceeded
-bash-3.2$ exit
logout
NOW … my boss is very happy and told me to implement this on all
users….
THIS is called real shit like situation…. 2-4 users are okay… but what
if I have 70-80 users ?
Well… Unix has solution for this also
root@sol-test-2:>/# edquota -p t2user1 t2user2 t2user3 t2user4
t2user5 vikash
root@sol-test-2:>/# repquota -v /export/home
/dev/dsk/c1t0d0s5 (/export/home):
Block
limits File limits
User used soft
hard timeleft used
soft hard timeleft
vikash -- 0
20000 30000 0 0
0
anurag -- 0
20000 30000 0 0
0
t2user1 -- 0
20000 30000 0 0
0
t2user2 -- 0
20000 30000 0 0
0
t2user3 -- 0
20000 30000 0 0
0
t2user4 -- 0
20000 30000 0 0
0
t2user5 -- 0
20000 30000 0 0
0
root@sol-test-2:>/#
well … what happened here … t2user1 has already quota set… I used this
as prototype for rest of the users…
NOW I WANT TO REMOVE QUOTA
Simple…
If want to remove for single users… then just edit their quota limit to
0
root@sol-test-2:>/# edquota t2user3
"/tmp/EdP.aw3aqg2" 1 line, 80 characters
fs /export/home blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)
see I just make that entry to 0
now check the quota status
root@sol-test-2:>/# quota -v t2user3
Disk quotas for t2user3 (uid 107):
Filesystem usage quota
limit timeleft files
quota limit timeleft
root@sol-test-2:>/# repquota -v /export/home
/dev/dsk/c1t0d0s5 (/export/home):
Block
limits File limits
User used soft
hard timeleft used
soft hard timeleft
vikash -- 0
20000 30000 0 0
0
anurag -- 0
20000 30000 0 0
0
t2user1 -- 0
20000 30000 0 0
0
t2user2 -- 0
20000 30000 0 0
0
t2user4 -- 0
20000 30000 0 0
0
t2user5 -- 0
20000 30000 0 0
0
root@sol-test-2:>/#
Nothing in first o/p and t2user3 is not present in 2nd o/p
BUT NOW I DON’T WANT QUOTA AT ALL….
1.)
Remove the rq from /etc/vfstab
2.)
Quotaoff –v /export/home
Just it…
QUOTA ADMINISTRATION
root@sol-test-2:>/# quota -v <user name>
root@sol-test-2:>/# quota -v anurag
root@sol-test-2:>/# repquota -av ufs
root@sol-test-2:>/# repquota -v /export/home
No comments:
Post a Comment