| Free Software at Schools: Installing and Maintaining a Debian-Edu Network; Also Known as Skolelinux | ||
|---|---|---|
| Prev | Chapter 8. Fine-tuning[id=finetuning] | Next |
First, you have to install the necessary packages, if you don't already have them installed.
apt-get install quota quotatool
Then you have to enable the use of quotas on the desired partition. So you first add a line to the file /etc/fstab. Do this for the partition /skole/tjener/home0
/dev/vg_data/lv_home0 /skole/tjener/home0 ext3 defaults,usrquota,grpquota 0 2with the flags 'usrquota' and 'grpquota' you have now enabled the use of user quotas and group quotas on the partition /skole/tjener/home0. In order to get this to take effect, you have to unmount the partition and then mount it; if necessary, reboot the machine.
Then you have to make the databases that contain info about the quotas:
touch /skole/tjener/home0/quota.user touch /skole/tjener/home0/quota.group chmod 600 /skole/tjener/home0/quota.user chmod 600 /skole/tjener/home0/quota.groupAfter that, check that quota.user and quota.group are empty before initialising the databases:
ls -lh /skole/tjener/home0/quota*
will show that quota.user and quota.group have zero size. Then initialise the databases with the commandquotacheck -avug
after which you check that the databases are no longer zero in sizels -lh /skole/tjener/home0/quota*
Then you turn on the quotas: quotaon -a
After that you set the quotas for some of the users.
edquota -u klaustakes you to a vi-based quota editor where you set up the quota the way you want it for klaus. If you think that quota is the one you want for all of the users, you can use the size of quota for klaus as a template for the other users. When that's done, you need to check the current status of the disk quotas,
repquota /skole/tjener/home0gives you
tjener:~# repquota /skole/tjener/home0
*** Report for user quotas on device /dev/vg_data/lv_home0
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 1198381 0 0 12832 0 0
daemon -- 4 0 0 5 0 0
bin -- 1 0 0 1 0 0
man -- 1000 0 0 28 0 0
lp -- 81 0 0 198 0 0
mail -- 5233 0 0 444 0 0
news -- 1 0 0 1 0 0
proxy -- 126788 0 0 4722 0 0
junkbust -- 5 0 0 3 0 0
klaus -- 1993 1500 2000 268 0 0
test16 -- 5 0 0 4 0 0
test15 -- 5 0 0 4 0 0
test14 -- 5 0 0 4 0 0
test13 -- 5 0 0 4 0 0
Here the user klaus has a softlimit of 1.5MB and a hardlimit of 2MB.
If you have a list of usernames in the file LoginName.txt in the form jan janak janne then you can give all of them the same size of quota as klaus with the command
for x in `cat LoginName.txt `;do edquota -p klaus $x;doneIf you now look at the status of the quotas, you will see that all of the users have got the same quota as klaus
tjener:~# repquota /skole/tjener/home0
*** Report for user quotas on device /dev/vg_data/lv_home0
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 1198381 0 0 12832 0 0
daemon -- 4 0 0 5 0 0
bin -- 1 0 0 1 0 0
man -- 1000 0 0 28 0 0
lp -- 81 0 0 198 0 0
mail -- 5233 0 0 444 0 0
news -- 1 0 0 1 0 0
proxy -- 126788 0 0 4722 0 0
junkbust -- 5 0 0 3 0 0
klaus +- 1993 1500 2000 268 0 0
test16 -- 5 1500 2000 4 0 0
test15 -- 5 1500 2000 4 0 0
test14 -- 5 1500 2000 4 0 0
test13 -- 5 1500 2000 4 0 0
If you use LDAP then you can quickly get a list of your users with the command
getent passwd|grep home0|cut -d":" -f1>LoginName.txtcheck that LoginName.txtis the way you want it to be.
Good commands for learning more about disk quotas for users and groups are
man edquota
man quota
man quotacheck
man quotaoff
man quotaon
man quotastats
man quotatool
man repquota
Sometimes a program can get very troublesome and start writing enormous amount of error messages to the file .xsession-errors in a user's home directory. Some programs, especially GIMP, are fully capable in the space of only a few minutes of creating such a large .xsession-erros file that the whole hard drive gets full. So, everything stops working. Then the root user has to go in to the main server and find that file and delete it. This is not exactly what you want to do on a regular schoolday.
So, even if such error message files as .xessions-errors are surely useful to have when you need to diagnose a problem, they are really more of a hassle in the schoolday. So, you need to get rid of it. You can do this by redirecting all messages that would otherwise be written to this file, right into the waste bin /dev/null.
By changing a few lines in the file /etc/X11/Xsession, set a comment symbol(#) in front of these lines, in this way:
#ERRFILE=$HOME/.xsession-errors
#
## attempt to create an error file; abort if we cannot
#if touch $ERRFILE 2> /dev/null && [ -w $ERRFILE ]; then
# chmod 600 "$ERRFILE"
#elif ERRFILE=$(tempfile 2> /dev/null); then
# if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
# message "Xsession: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
# "\"$ERRFILE\"."
# fi
#else
# errormsg "Xsession: unable to create X session log/error file. Aborting."
#fi
#
#exec > "$ERRFILE" 2>&1
And set in these two lines instead:
errfile="/dev/null" exec > "$errfile" 2>&1Now you don't need to be afraid that .xsession-errors will fill up your entire hard drive.