View Full Version : Install as RO filesystem

03-04-2005, 11:55 PM
Hi all,

I have an app that I want to run on linux that does not require filesystem access. I want to install it on several computers which may be turned on and shut down ungracefully, so I want to be sure that nothing is ever written to disk anyway. I thought knoppix would be a good place to start, because being CD-ROM based, it runs happily on a read-only filesystem.

I installed knoppix on a computer using knoppix-install from the CD, using the "CD-based" distribution option. I set the / filesystem to ro via /etc/fstab, but it is still mounted as rw and I can still write to the filesystem when the computer boots up. I want to enforce that the / partition remain ro so that I know nothing is writing to it, and the computer can bounce any time without any files open.

Does knoppix mount the filesystems from some location other than /etc/fstab?


03-05-2005, 03:12 AM
Does knoppix mount the filesystems from some location other than /etc/fstab?
Well, yes and no. :D

Knoppix actually rewrites /etc/fstab while the computer is booting. You can see when this happens - a line is written to the screen in blue and yellow that says,
Scanning for Harddisk partitions and creating /etc/fstab... If it goes by too fast, you can review the boot process by typing
$ dmesg
This behavior is a good thing when running from CD, because the disk never knows from one boot to the next what environment it will find. It's probably not that useful after installation to HD, and can be downright annoying in situations like yours.

True to the Unix Way, there are different options for dealing with this default behavior. The easiest is probably to give the Knoppix parameter nofstab at boot time. You can do it each and every time you want to skip the rewrite or, if you're using a bootloader, add a line like this:
append="nofstab"If there's already an append line, just add to it:
append="lang=us nofstab"Note that this isn't a kernel parameter - it's specific to Knoppix. So it won't work if you do a Debian install. Of course, it won't be needed if you do a Debian install. :wink:

Other ways involve modifying the script that carries out the procedure, and aren't hard at all. Do this by editing (as root) /etc/init.d/knoppix-autoconfig. On my system there are 12 lines of code starting at line 951 (or search for nofstab). The file has useful comments inside, so it's easy to see what it does.

You can comment these lines out by adding # at the beginning of each one. (Well, two of the lines are already just comments, so you'd do that to the other 10.) Or you could add a test for HD-install - the script already does that for other actions, so you could browse through the file and see how it's done elsewhere.

Still other ways might be to have the boot process skip this whole script entirely, or put something else in its place. Whatever gets you down the road. :D

I hope this helps!

-- Ed

03-07-2005, 04:35 PM
Hi mr_ed

Thank you for the reply! I was able to set my fstab the way I liked it, and now I understand better how knoppix boots. But I found in the same file, on line 486:

# / must be rw in any case, starting from here
mount -o remount,rw / 2>/dev/null

so it remounts root as rw anyway. Back to square #1, I booted again from CD, and found that it creates a 2mb root partition on "/dev/root", then fills it with a default filesystem full of symlinks to the CD. It's great! All the binaries are run from the CD image, but / is still a writable partition for temporary files.

Now I'm stuck though. Where does it get /dev/root from? And what populates it with the filesystem full of symlinks? I suspect the answer lies in a pivitroot call, but I don't know much about pivitroot, or where it's called from. I didn't find any hints in the knoppix-autoconf script.

Basically, I want to be able to do this same thing when booting from the hard drive: mount the hard drive as read-only, then create a root mountpoint that contains this same default filesystem as when booting from the CD. Then I would have a temporary root filesystem that could be trashed and thrown away, and start over when the box is rebooted.

Are there any hints for where I should look to accomplish this?

Thanks all!


03-08-2005, 03:09 AM
As you saw, I was in over my head with the last question, never mind this one! :D

I'm sorry, I don't know. I did some poking around but didn't find anything useful. I would suspect that it was something on the CD (in the compressed KNOPPIX file) that didn't get copied to HD, but when you remaster a new CD, everything comes from the HD.

This should be an easy question for someone who knows the process better. If you don't get an answer shortly, give another shout.

-- Ed