You are not logged in.

#1 2009-04-15 03:54:22

elifarley
Member
From: Rio de Janeiro
Registered: 2008-03-07
Posts: 37
Website

Simple way to enable /tmp on ram by editing rc.conf

In order to mount tmpfs on /tmp at system startup, one should probably change the rc.sysinit script, which doesn't feel as comfortable as editing rc.conf.

I have a suggestion that may simplify this, by using something we could call SIMs (for SysInit Modules).
A SIM aims to simplify system initialization by spliting file rc.sysinit into modules, which can then be enabled or disabled in rc.conf.

Let's take a look at some patches:

Patch for rc.sysinit:
----------------------------------------------------------
@@ -313,6 +313,17 @@
        stat_done
fi

+# Start SIMs (sysinit modules)
+for sim in "${SIMS[@]}"; do
+       if [ "$sim" = "${sim#!}" ]; then
+               if [ "$sim" = "${sim#@}" ]; then
+                       start_sim $sim
+               else
+                       start_sim_bkgd ${sim:1}
+               fi
+       fi
+done
+
stat_busy "Removing Leftover Files"
/bin/rm -f /etc/nologin &>/dev/null
/bin/rm -f /etc/shutdownpid &>/dev/null@@ -28,6 +28,17 @@
USECOLOR="yes"
----------------------------------------------------------


Patch for rc.conf:
----------------------------------------------------------

# -----------------------------------------------------------------------
+# SIMS (sysinit modules)
+# -----------------------------------------------------------------------
+#
+#  Sysinit modules (SIMs) aim to simplify system initialization
+#   - prefix a SIM with a ! to disable it (some SIMs are essential, so beware)
+#   - prefix a SIM with a @ to start it up in the background (is it useful?)
+#
+#
+SIMS=(tmp-on-ram)
+
+# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
----------------------------------------------------------

New file: /etc/rc.sim/functions:
----------------------------------------------------------
#
# SIM (sysinit module) functions
#

# sysinit modules:

start_sim() {
        if [ -x /etc/rc.sim/$1 ]; then
                stat_busy "Loading SIM $1"
                /etc/rc.sim/$1
                stat_done
        fi
}

start_sim_bkgd() {
        stat_bkgd "Loading SIM $1"
        (/etc/rc.sim/$1) &>/dev/null &
}

# End of file
----------------------------------------------------------


New file: /etc/rc.sim/tmp-on-ram:
----------------------------------------------------------
#! /bin/bash
# SIM that mounts tmpfs on /tmp
# Requirement : RAM >= 256 MB
#               SWAP >= 512 MB
#
# Modified by Elifarley Cruz
# Based on rc.tmpfs By Eko M. Budi
# Released under the GPL

# Load before "Removing Leftover files"

# TODO Put configuration in file /etc/conf.d/sim/tmp-on-ram
SIZE=1024M
INODE=16M

if cat /proc/filesystems | grep -qe "tmpfs$" ; then
    mount -t tmpfs tmpfs /tmp -o size=$SIZE,nr_inodes=$INODE,mode=1777
fi

#### Delete the line below for production use
sleep 8
----------------------------------------------------------

So, do you guys think this idea is worth applying to ArchLinux?

Regards,
Elifarley

Offline

#2 2009-04-15 03:57:43

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: Simple way to enable /tmp on ram by editing rc.conf

Uhhhmm... What does this achieve over just adding the below to /etc/fstab?

tmpfs    /tmp    tmpfs    size=1g    0 0

Offline

#3 2009-04-15 04:03:46

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: Simple way to enable /tmp on ram by editing rc.conf

I my systems i enabled /tmp as tmpfs by putting just one line in /etc/fstab

none                   /tmp          tmpfs     nodev,nosuid,mode=1777               0      0

Offline

#4 2009-04-15 12:12:09

LeoSolaris
Member
From: South Carolina
Registered: 2008-03-30
Posts: 354

Re: Simple way to enable /tmp on ram by editing rc.conf

In a nutshell what your aiming for is making tmp faster by placing it in RAM rather than the hard drive?

Interesting idea. I can see the advantage for those who do compiling work with the tmp folder. If I find that I start using the tmp more than once a week, I will definitely give this a try.

Thank you for the work!


I keep getting distracted from my webserver project...

huh? oooh...  shiny!

Offline

#5 2009-04-15 12:50:04

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Simple way to enable /tmp on ram by editing rc.conf

fukawi2 wrote:

Uhhhmm... What does this achieve over just adding the below to /etc/fstab?

djgera wrote:

I my systems i enabled /tmp as tmpfs by putting just one line in /etc/fstab

I think the idea here is to modularize sysinit, not just for this /tmp thing, but for other uses as well.

OP: I don't know much about the things sysinit does, and I can't bother to look now because I'm at work, but I can tell you that ideas like this posted to the bbs often go unheard.  If you are serious about this and genuinely think there is an advantage to it, it would be best to file a feature request in the bug tracker.  Devs don't always read the bbs.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#6 2009-04-15 22:35:58

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: Simple way to enable /tmp on ram by editing rc.conf

rson451 wrote:

I think the idea here is to modularize sysinit, not just for this /tmp thing, but for other uses as well.

Modularizing things is good, but does anyone have any other candidates for modularization in this context? Doing it for one task isn't really worth it, but if there's a few things that can be added then it sounds good. I can't think of anything off the top of my head.

Offline

#7 2009-04-15 23:24:35

Zariel
Member
Registered: 2008-10-07
Posts: 446

Re: Simple way to enable /tmp on ram by editing rc.conf

Well you could do modesetting this way couldnt you? Though adding it to initrd is far easier

Offline

Board footer

Powered by FluxBB