/var/run and /var/lock on tmpfs
/var/run and /var/lock should be mounted as tmpfs
- Name: Lennart Poettering
- Email: lennart at poettering dot net
- IRC: mezcalero
- Targeted release: Fedora 15
- Last updated: 2010-09-15
- Percentage of completion: 20%
/var/run and /var/lock contain small runtime files which need not to be kept around over a reboot, and hence are pointless to write to disk as it currently is done. Currently there's bootup code that explicitly empties these directories on boot. If we move these two directories to tmpfs this wouldn't be necessary anymore, simplifiying boot-up, making things less fragile. One could also argue that it might make things faster since it gets rid of unnecessary write accesses to disk.
Benefit to Fedora
Simpler, more robust boot-up scheme. Possibly a little bit faster boot up. Since Ubuntu/Suse already do this this would bring Fedora more inline with the other distributions and minimize differences between the distros.
systemd already contains the necessary support which is however not enabled in rawhide yet. This needs to be enabled.
Various .spec files need to add %ghost to the files/dirs in /var/run and /var/lock they currently own. The following packages are presumably affected as they own files in /var/run or /var/lock:
389-ds-base abrt amavisd-new arm4 asterisk avahi balance bdii bind bip bro bucardo callweaver Canna clamav-milter clamav-scanner clamsmtp clement cman cntlm condor conmux ConsoleKit couchdb cups cyphesis cyrus-sasl dansguardian davfs2 dbus ddclient dirmngr dkim-milter dmapd dmraid dovecot drbdlinks dspam ebnetd-common ejabberd exim-clamav ez-ipupdate fail2ban fcron filesystem firebird flumotion freeradius fwknop gdm gearmand greylistd hal halevt heartbeat hostapd httpd icecast initscripts inn iptraf iscsi-initiator-utils jetty kde-settings-kdm ldm libgpod libselinux libvirt lighttpd lirc lockdev logcheck ltspfsd lvm2 lxdm mailman mdadm memcached milter-greylist mirrormanager mldonkey-server mod_fcgid mod_mono mongodb-server monotone-server mrtg munge munin murmur mysql-mmm mysql-server ndoutils netdisco net-snmp NetworkManager ngircd noip nrpe nscd nsd nss-pam-ldapd nuauth nut-client openct openldap-servers openstack-swift openswan openvpn openxcap ovirt-server pacemaker pam pam_mount pam_ssh pathfinderd pcp pki-ca pki-kra pki-ocsp pki-ra pki-tks pki-tps plymouth pm-utils polipo portreserve ppp pptp prcsys prelude-manager proftpd psad puppet pvm pyicq-t qpid-cpp-server quagga radvd rkhunter samba-winbind sblim-gather screen setroubleshoot-server slim smokeping spamassassin spamass-milter spectrum sphinx sslogger-slogd sudo system-config-printer-udev systemd systemtap-initscript tclhttpd tetrinetx tiger tinyproxy tmux tog-pegasus tokyotyrant tor-lsb tuned udisks unbound up-imapproxy util-vserver uucp uuidd vblade vdr vdradmin-am vpnc vtun wesnoth-server wpa_supplicant xemacs-common xen-runtime xl2tpd zabbix
Some software might need patching, so that it is able to recreate its dirs/files in /var/run and /var/lock when they get lost on reboot. Since SUSE and Ubuntu already ship things with tmpfs on /var/run and /var/lock almost nothing should still require patching for this.
The SELinux policy might need updates so that these dirs/files may be created on daemon startup.
In some exceptional cases it might be necessary to add drop-in files to /etc/tmpfiles.d/ to some packages, if they are unable to create their own directories in /var/run on boot, or when the create more than one which shall be labelled differently.
The "find" command in /etc/rc.d/rc.sysinit that cleans up /var/run and /var/lock can go away. (DONE)
How To Test
Check /proc/mounts to verify that /var/run and /var/lock are now tmpfs.
Make sure that software that creates files/dirs beneath those two dirs still works fine. Mostly this means:
a) the rpms can be installed properly b) the rpms can be deinstalled properly, leaving no files in /var/run and /var/lock behind c) the software starts up properly.
A tiny bit of less disk accesses.
None necessary, revert to previous release behaviour.
I don't think this needs much additional documentation, beyond what systemd already contains about this.
/var/run and /var/lock are now mounted from tmpfs, and hence emptied on reboot. Applications must ensure to recreate their own files/dirs on startup, and cannot rely that doing this at package installtion will suffice