4

I just installed Debian 5 (Lenny) and I noticed that /lib/init/rw is reported as a RAM Disk (tmpfs). I've only had experience with Fedora so I'm curious what function does that directory serve in Debian. Can it be used by user written shell scripts to cache stuff or is it off-limits and only for use by the OS? Thanks.

3 Answers 3

10

As others point out (this would have been a comment on their replies, but grew too long to fit the comment box) this is used by some initscripts, generally during the boot process, when your other filesystems may be read-only or even not yet mounted at all.

The filesystem is left mounted after startup has completed as initscripts that write there may be run at other times (if you manually restart a service, or switch runlevels). You should not force it to unmount in case the device/filesystem /lib/init is on becomes readonly. It does not consume any appreciable resource when not actually storing data so is not a performance concern.

While I do not see any harm in using it for your own scripts if your scripts are well tested and can be guaranteed not to completely fill it such that initscripts can't write there when they need to, you would be safer to create your own tmpfs mount for this purpose (you can have as many as you like, in theory, and they only consume memory when actually storing data) or just use /tmp and have that mounted as a tmpfs filesystem instead of being on disk.

If you do use a tmpfs filesystem for temporary data, be aware that this will consume memory and if you are low on memory to start with may induce swapping. This is why I generally use a separate mount instead of /tmp (which is where many processes will put stuff so it is more likely to use more memory long term than my scripts alone). If you have plenty of memory "spare" most of the time this is not an issue though. In the output of free, top and similar tools memory used by data held in tmpfs filesystems is usually counted in the "cached" count - see In Linux, what is the difference between "buffers" and "cache" reported by the free command? for more detail on that.

Edit: I forgot to add... The other reason for creating your own tmpfs based mount instead of using the one Debian creates for their standard scripts, is that you are making your scripts less reliant on a distribution specific property, meaning you have a little more to change if your scripts are migrated to other configurations.

0
4

It is used by initscript requiring a writable namespace at the time /sbin/init is run. Remember, at that time your root partition might very well be readonly.

Anders

2

Apparently it is used by initscripts at startup see this link

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .