Solved

Setting Disk Quotas - Newbie Question

Posted on 2004-10-01
23
439 Views
Last Modified: 2013-12-16
Hi

I have looked at many tutorials in setting disk quotas without success.

I want to restrict folder size on /home/thisuser however I am running Gentoo Linux and I have not got "/home" on a seperate partition. I have a partition on "/" but that is the main one. I have installed the quota tool. I need to restrict /home/thisuser to 50MB and I probably have more users e.g. /home/thisuser2 that I may want to restrict in the future at different sizes.

Can anyone help me to set up this up? - I am desperate to get this working now.

Thanks in advance

Regards

spyrit
0
Comment
Question by:spyrit
  • 10
  • 9
  • 2
23 Comments
 
LVL 10

Expert Comment

by:Luxana
ID: 12198344
Hi,



ENABLE QUOTAS

1:
Set options in /etc/fstab

/dev/hdaX              /home       extX              defaults,usrquota,grpquota     1     2

this is important so check you /etc/fstab and add usrquota,grpquota to options.

2:
Create the quota.user and quota.group files on top of the /home filesystem:

# touch /home/quota.user  /home/quota.group
# chmod 600 /home/quota.user  /home/quota.group

3:
Run quotacheck to initialize the databases ( /home/quota.user  /home/quota.group ).

# quotacheck -avugm

4:
Then verify that your quota database files have been initialized by noting that they are no longer of size zero.

# ls -al /home/quota.*

5:
Run quotaon to enable the quota system:

# quotaon -a

6:
Verify that your system's initialization script /etc/rc.d/rc.sysinit will turn on quotas when system boots.

if [ -x  /sbin/quotacheck ]
then
    echo " Checking quotas."
    /sbin/quotacheck -avug
    echo " DONE "
fi
if [ -x /sbin/quotaon ]
then

echo " Turning on quotas."
       /sbin/quotaon -avug
fi

---------------------------------------


to editing quotas for clients use commad:

# edquota <username>

Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/hdaX                        X      50000   60000       X       0        0

edit soft and hard limits.

and run

# quotacheck -avugm


0
 

Author Comment

by:spyrit
ID: 12199036
Thanks for a swift reply just one minor question before I accept. I don't have /home as a seperate partition in my fstab. Do I have to create that?? Type a new line?? Other commands to make it a partition??

Thanks

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12199498
usualy the home partition is created separatly just because is the most inportant filesystem and also when you fill it up it does not effect your system.

I think that you have /home in / in that case enable quotas on / . But if you just instaled linux and you do not have data in it is good to make separate partition or add another hard drive and create filesystem and mount in into /home directory. :-)
0
 

Author Comment

by:spyrit
ID: 12199984
I have been using it for some time unfortunately. Therefore I will have to enable quotas in the "/" directory I think.

I will try that and accept your answer later tonight.

Regards

spyrit
0
 

Expert Comment

by:murpellc
ID: 12206151
You might want to consider using Webmin. Its totally fast and highly efficient for setting up disk quotas and maintaining them. It also has a number of modules to setup under the /etc/init.d for starting up quota after a server reboot. I utilize it in a heavy server (500+ users) environment and have had zero problems. Setting up disk quotas, user accounts, NFS mounts, you name it... with Webmin its a breeze!

Webmin Site: http://www.webmin.com/

-- Michael
0
 

Author Comment

by:spyrit
ID: 12206343
Hi

I tried setting up those quotas. When i do the quotacheck -avug It said no quota file or something... then carried on checking the dev/hda3/ but when I check to make sure the quota.user and quota.group files ok. They are still 0. and It can't turn on the quotas because the quota files don't exist. What's wrong?

Hi Michael, I am using webmin but need to set up the quota tool and config on the disk first. Thats the problem. It won't let me do anything in webmin yet. - Thanks

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12206438
where did you put files?
try to put tehm on /
did you run
#quotaon
?
better you put another HDD and copy your home directorey there and mount it into /home is more better..
0
 

Expert Comment

by:murpellc
ID: 12208479
Lets see what your files look like. Can you display here your /etc/fstab & /etc/mtab? Also do a quick 'ls -l' on your /home directory -- gives us a better lay of the land to see what you are seeing as well.

-- M
0
 

Author Comment

by:spyrit
ID: 12208901
Hi

Here is what I have got.....


# /etc/fstab: static file system information.
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/fstab,v 1.14 2003/10/13 20:03:38 azarah Exp $
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed; notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail and tail freely.

# <fs>                  <mountpoint>    <type>          <opts>                  <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/hda1               /boot           reiserfs        noatime,notail          1 1
/dev/hda3               /               reiserfs        noatime,usrquota,grpquota                       1 2
/dev/hda2               none            swap            sw                      0 0
/dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro               0 0
#/dev/fd0               /mnt/floppy     auto            noauto                  0 0

# NOTE: The next line is critical for boot!
none                    /proc           proc            defaults                0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
# Adding the following line to /etc/fstab should take care of this:

none                    /dev/shm        tmpfs           defaults                0 0
/dev/hdb1               /mnt/store      reiserfs        defaults                0 0

If I run quotaon I get this message....

quotaon -a
quotaon: Cannot find quota file on / [/dev/hda3] to turn quotas on/off.
quotaon: using //aquota.user on /dev/hda3 [/]: No such process
quotaon: Quota format not supported in kernel.

This is an ls -l on my /home directory

ls -l
total 0
drwxr-xr-x  2 root   root   72 Jun 29 17:55 ftp
drwxr-xr-x  6 joof   joof  208 Oct  1 23:02 joof
drwx------  3 oliver users 192 Jun 30 18:17 oliver
drwx------  2 stuart users 136 Aug  7 13:15 stuart

This is what I get doing a quota check

quotacheck -avugm
quotacheck: Cannot get quotafile name for /dev/hda3
quotacheck: Scanning /dev/hda3 [/] done
quotacheck: Checked 22846 directories and 208146 files

This is what happens doing an ls -la on the "/"

/ # ls -la
total 26
drwxr-xr-x  19 root root  528 Oct  2 21:39 .
drwxr-xr-x  19 root root  528 Oct  2 21:39 ..
-rw-r--r--   1 root root 8192 Oct  2 21:39 aquota.user
drwxr-xr-x   2 root root 3592 Aug  2 06:35 bin
drwxr-xr-x   4 root root  176 Jun 28 18:10 boot
drwxr-xr-x   1 root root    0 Jan  1  1970 dev
drwxr-xr-x  60 root root 3920 Oct  1 23:26 etc
drwxr-xr-x   6 root root  168 Oct  1 23:04 home
drwxr-xr-x   8 root root 3456 Aug  2 08:12 lib
drwxr-xr-x   8 root root  216 Sep 29 21:50 mnt
drwxr-xr-x   3 root root   96 Jun 29 08:31 opt
dr-xr-xr-x  65 root root    0 Oct  1 23:20 proc
-rw-------   1 root root    0 Oct  1 23:04 quota.group
-rw-------   1 root root    0 Oct  1 23:04 quota.user
drwx------   9 root root 1744 Oct  2 00:00 root
drwxr-xr-x   2 root root 3680 Sep 29 21:21 sbin
drwxr-xr-x   2 root root   48 Aug 11 12:03 store
drwxr-xr-x   9 root root    0 Oct  1 23:20 sys
drwxrwxrwt   8 root root 2424 Oct  2 03:13 tmp
drwxr-xr-x  13 root root  448 Jul 23 17:04 usr
drwxr-xr-x  14 root root  384 Jun 30 08:03 var

As you can see the quota.user and quota.group are still zero in file size after performing all the other stuff.

I have increased the points to 400. I hope someone can help. Thanks.

spyrit






0
 
LVL 10

Expert Comment

by:Luxana
ID: 12209529
hi sprit heve look here :
http://www.linuxmafia.com/faq/Filesystems/quotas.html

my quotas:
# <file system> <mount point>   <type>  <options>               <dump>  <pass>
/dev/hda1       /               ext3    errors=remount-ro,       1      0
/dev/hda2       none            swap    sw                      0       0
/dev/hda3       /mnt/backup_hda3 ext3   errors=remount-ro       0       0
/dev/hdb1       /home           ext3    errors=remount-ro,usrquota       2       0  ->different hdd just for /home
proc            /proc           proc    defaults                0       0
/dev/fd0        /floppy         auto    user,noauto             0       0
/dev/cdrom      /cdrom          iso9660 ro,user,noauto          0       0

pwd
/home
ls -alF *user
-rw-------    1 root     root      2097120 Oct  3 03:00 quota.user

do not try open this files

what kernel you got?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:spyrit
ID: 12210768
Hi

I will try that when I get back tonight.

In the meantime any other suggestions.... ideas.... as I don't have the /home partition anda reformat is not an option.

My kernel is.... Gentoo Linux - Custom Kernel

2.6.7-gentoo-r6

I hope this helps.

Thanks once again

spyrit
0
 

Author Comment

by:spyrit
ID: 12213295
All done - I think... Is there any way I can make sure it is done... like testing the limits? Thanks for all your help. I will award the points to Luxana for his swift detailed response at the start. I think the only thing missing was to mention I needed to change to single user mode which I now worked out. Thanks for helping me and providing great responses!

Can I test the quota then?? Any sort of tests or programs??

Thanks!

spyrit
0
 

Author Comment

by:spyrit
ID: 12213341
ARGHHHHHHHHHH!!!!!

repquota / shows

repquota /
*** Report for user quotas on device /dev/hda3
Block grace time: 00:00; Inode grace time: 00:00
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      -- 2711502       0       0         225079     0     0
bin       --      37       0       0              5     0     0
lp        --      13       0       0              4     0     0
named     --      21       0       0             11     0     0
mysql     --    1440       0       0            226     0     0
apache    --     296       0       0             62     0     0
postfix   --       2       0       0             13     0     0
portage   --    4193       0       0            856     0     0
stuart    --    5567       0       0            538     0     0
oliver    --  493078       0       0           2251     0     0
ldap      --       1       0       0              4     0     0
clamav    --    1398       0       0              4     0     0
joof      --   22923   45000   50000            445     0     0
#55       --    1969       0       0             74     0     0

so that looks ok

BUT! quotaon -a is doing this........

quotaon: using //aquota.group on /dev/hda3 [/]: No such process
quotaon: Quota format not supported in kernel.
quotaon: using //aquota.user on /dev/hda3 [/]: No such process
quotaon: Quota format not supported in kernel.

Why does it all go wrong for me....... :s

Please please help. I have increased points another 50

Thanks

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12213743
Hi spyrit,

1)
first remove from /etc/fstab ",grpquota" we do not need enable group quotas yet and it make our life easyer at tho moment
2)
what you get when you type :
#quotaoff -a
then
#quotaon -a
does you get this message again ?:
quotaon: using //aquota.user on /dev/hda3 [/]: No such process
quotaon: Quota format not supported in kernel.
0
 

Author Comment

by:spyrit
ID: 12214845
Hi

Yes I do still get that message....

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12215201
hi


run
#modprobe -v quota_v2
and then
# quotaoff -a
# quotaon -a
0
 

Author Comment

by:spyrit
ID: 12215289
Hi

I will try that as soon as I can get home....

Just as an extra - I don't know whether this helps but when I originally installed gentoo I didn't have the quota tool installed. I have used emerge quota to get the tool and install it.

Everything now works... like the commands except quotaon :s I don't have to do anything special do I, because I didn't install quota when the kernel was compiled?

I will try that command later tonight.

Thanks

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12215356
ok try taht but if everithing is working there is no poit to try anything...:))

0
 

Author Comment

by:spyrit
ID: 12221960
Points increased another 15... thats all I have left now....

I ran that command.... here are the results.

modprobe -v quota_v2
FATAL: Module quota_v2 not found.

spyrit
0
 
LVL 10

Expert Comment

by:Luxana
ID: 12222641
Hi spyrit,


modprobe -v quota_v2
FATAL: Module quota_v2 not found.

this just tell us that you do not have modul quota_v2
---------------------------
you said that you have your own compiled kernel so go to your kernel source and do:
# make menuconfig
or
# make xconfig
and see if you have enabled quotas and also see if quotas supports also Rieserfs filesystem which you have on your / directory.

lubo
0
 
LVL 10

Accepted Solution

by:
Luxana earned 465 total points
ID: 12224127
spyrit ,

it seems that our Newbie Question becomes to complex problem:)))


http://linuxberg.vc-graz.ac.at/mirror/reiserfs/quota-patches/

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now