Link to home
Start Free TrialLog in
Avatar of spyrit
spyrit

asked on

Setting Disk Quotas - Newbie Question

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
Avatar of Luxana
Luxana
Flag of Australia image

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


Avatar of spyrit
spyrit

ASKER

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
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. :-)
Avatar of spyrit

ASKER

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
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
Avatar of spyrit

ASKER

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
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..
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
Avatar of spyrit

ASKER

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






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?
Avatar of spyrit

ASKER

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
Avatar of spyrit

ASKER

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
Avatar of spyrit

ASKER

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
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.
Avatar of spyrit

ASKER

Hi

Yes I do still get that message....

spyrit
hi


run
#modprobe -v quota_v2
and then
# quotaoff -a
# quotaon -a
Avatar of spyrit

ASKER

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
ok try taht but if everithing is working there is no poit to try anything...:))

Avatar of spyrit

ASKER

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
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
ASKER CERTIFIED SOLUTION
Avatar of Luxana
Luxana
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial