[Pkg-sysvinit-devel] Use only one tmpfs for /lib/init/rw/, /var/run/ and /var/lock/?

Petter Reinholdtsen pere at hungry.com
Fri Sep 22 16:26:35 UTC 2006


What about creating only one tmpfs file system, and make it available
in /lib/init/rw/ and bind-mount it to /var/run/ and /var/lock/ if the
RAMRUN and RAMLOCK options are set?  This way it will not be as easy
to use up all the memory in a system.  Instead of this:

        # Get some writable area available before the root is checked
        # and remounted.
        domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid
        touch /lib/init/rw/.ramfs

        # Mount /var/run and /var/lock as tmpfs if enabled
        if [ yes = "$RAMRUN" ] ; then
                domount tmpfs "" /var/run varrun -omode=0755,nosuid
                touch /var/run/.ramfs
        fi
        if [ yes = "$RAMLOCK ] ; then
                domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid
                touch /var/lock/.ramfs
        fi

We could do something like this:

        # Get some writable area available before the root is checked
        # and remounted.
        domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid
        touch /lib/init/rw/.ramfs

        # Mount /var/run and /var/lock as tmpfs if enabled
        if [ yes = "$RAMRUN" ] ; then
                mkdir /lib/init/rw/run
		chmod 0755 /lib/init/rw/run
		mount -n --bind /lib/init/rw/run /var/run
                touch /var/run/.ramfs
        fi
        if [ yes = "$RAMLOCK ] ; then
                mkdir /lib/init/rw/lock
		chmod 1777 /lib/init/rw/lock
		mount -n --bind /lib/init/rw/lock /var/lock
                touch /var/lock/.ramfs
        fi

Any objections?  It might also need some changes to mtab.sh to get the
correct content into /etc/mtab.

Friendly,
-- 
Petter Reinholdtsen



More information about the Pkg-sysvinit-devel mailing list