I'm running a VPS with a webserver (Apache+PHP), a database (MySQL) and smtp server (Exim). OS: Debian Lenny. RAM: 512MB. Using (quota](http://packages.debian.org/lenny/quota).
At the moment, I've /tmp
mounted as tmpfs. This is not ideal, as I've only 512MB RAM and thus, /tmp
is only 256MB. I've decided to create a 1GB ext3 partition file (or whatever it's called) on /var/tmpdisk
. (the decision on using ext3 was made after reading Askubuntu.com: Good filesystem for /tmp?)
For keeping /tmp clean while running, I've found tmpreaper: serverfault.com: Cleanup of /tmp
What would be recommended for quickly wiping /var/tmpdisk
, while retaining the quota settings?
Currently, I'm thinking of doing the following on startup (/etc/rc.local
?):
- Check for the existence of
/var/tmpdisk
. if it does not exist, rundd if=/dev/zero of=/var/tmpdisk bs=1K count=1000000
- Create the ext3 filesystem in
/var/tmpdisk
. This was the fastest way for me on clearing the "disk". Command:mkfs.ext3 -F /var/tmpdisk
- Mount it on
/tmp
:mount -t ext3 -o loop,rw,nodev,noexec,nosuid,quota /var/tmpdisk /tmp
In this draft, I have not added a way for keeping the quota settings. Any ideas?
Most of my requirements have already been available in Debian.
By default,
/etc/default/rcS
sets environment variableTMPTIME=0
.$ man rcS
:Looking in
/lib/init/bootclean.sh
, I found out that the quota file './aquota.user(owned by root) is excluded from removing. Conclusion: quota settings will persist during reboots and
TMPTIME=0can safely be set in
/etc/default/rcS`.To keep
/tmp
clean while running, I installedtmpreaper
. To activate it,SHOWWARNING=true
should be commented. Furthermore,TMPREAPER_TIME=7d
should be uncommented in order to clean files older than 7 days.A 1GB temp disk was created and formatted ext3 with:
Mounting it at boot-time required a change in
/etc/fstab
:Since
/var/tmpdisk
is not a real device, it should be mounted as loop device, henceloop
.nosuid,noexec,nodev
have been added as a layer of security to prevent common exploit kits from abusing/tmp
. Finally,quota
enables quota for the disk.After modifying
/etc/fstab
, I ranmount -a
to mount the new/tmp
disk. Since/tmp
should be world-writable, and users should not be able to delete files they do not own, the directory permissions should be changed too:Activate quotas:
Now
/tmp
fully suits my needs with quotas activated and auto-cleaning junk files. The only thing I have to do is adding quotas for each user by runningedquota username
.