Running linux off a CF card

Posted by: andym

Running linux off a CF card - 13/05/2007 15:31

I'm currently preparing a machine that will be running in a harsh environment (transmitter shed with no decent air con).

I'd like this machine to boot off flash so the only moving things are the fans in the case. I've pretty much settled on Xubuntu which uses xfce as its window manager and sits happily on a 2GB Parallels drive on my test machine. I've got it set up just as I want and I'll be trying an actual install tomorrow.

My question is, given the reluctance to continually write to any type of flash device. Is there anything I should be trying to put in a ramdisk to avoid hitting the flash too often.

This is what's currently mounted on the test system:

Code:

/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.20-15-generic/volatile type tmpfs (rw)



It appears to me the two most likely candidates (/var/run and /var/lock) appear to mounted from something already. Any recommendations?

The computer itself is one of these, I have a bunch of them because they're really useful (on board CF and 3 NIC's).
Posted by: tman

Re: Running linux off a CF card - 13/05/2007 16:46

Have a look at this article for laptop mode. Some of the suggestions like setting noatime you'll want to do.
Posted by: andym

Re: Running linux off a CF card - 14/05/2007 20:18

Some good points there, will give them a try.

I'd still like to put some things in a ramdisk, suggestions anyone? Was hoping Mark might have some ideas.
Posted by: mlord

Re: Running linux off a CF card - 14/05/2007 21:40

Quote:
Some good points there, will give them a try.

I'd still like to put some things in a ramdisk, suggestions anyone? Was hoping Mark might have some ideas.


Sure. Remount the root filesystem as read-only, and then wait for programs to complain. Whatever they're writing belongs on a tmpfs (or f/s on top of a ramdisk, for the old-fashioned).

That's my two cents.
Posted by: mlord

Re: Running linux off a CF card - 14/05/2007 21:43

Quote:
Quote:
Some good points there, will give them a try.

I'd still like to put some things in a ramdisk, suggestions anyone? Was hoping Mark might have some ideas.


Sure. Remount the root filesystem as read-only, and then wait for programs to complain. Whatever they're writing belongs on a tmpfs (or f/s on top of a ramdisk, for the old-fashioned).



Actually, what I would really do is just add a little bit of code in the kernel to the sys_open() handler, and have it log the process id/name each time that a program opens a file for RDWR/WRONLY access. Then go after the offenders it identifies and ensure those files end up in RAM.

Once all of that is working, just have the root filesystem always mounted R/O by default.

Cheers
Posted by: andym

Re: Running linux off a CF card - 14/05/2007 22:11

That sounds so ingenious i'm kicking myself for not thinking of it already!

While idea 2 sounds the best, i've never had much luck with compiling kernels under any of the 'buntu's. So will probably try the r/o idea first.

Do you know anything about how/why the run and lock directories are mounted as they are in ubuntu? My gentoo machines don't use this and a quick google didn't turn anything up.
Posted by: mlord

Re: Running linux off a CF card - 15/05/2007 10:12

Quote:

Do you know anything about how/why the run and lock directories are mounted as they are in ubuntu? My gentoo machines don't use this and a quick google didn't turn anything up.

Those are on tmpfs, which is a 100% in-RAM filesystem emulator, exactly what you want for them. They get used for temporary lock files and "PID" files for daemons, stuff that is *never* wanted to survive over a reboot.

EDIT: to roll your own tmpfs, do something like this:

mkdir /junk
mount tmpfs /junk -t tmpfs

Now you have /junk/ as an in-RAM filesystem.

EDIT AGAIN:
Note that Ubuntu also places the udev-generated /dev/ on tmpfs, and hides the real (static) /dev/ underneath it at /dev/.static/dev/

Cheers
Posted by: mlord

Re: Running linux off a CF card - 15/05/2007 14:13

There is also a command-line utility to find file-writers etc.. which might be useful to you. The command is fuser and it has a reasonably okay man page.

-ml
Posted by: peter

Re: Running linux off a CF card - 15/05/2007 14:23

Quote:
There is also a command-line utility to find file-writers etc.. which might be useful to you. The command is fuser and it has a reasonably okay man page.

Ooo, now that's handy. I hadn't come across that!

Peter
Posted by: mlord

Re: Running linux off a CF card - 15/05/2007 14:29

Quote:
Quote:
There is also a command-line utility to find file-writers etc.. which might be useful to you. The command is fuser and it has a reasonably okay man page.

Ooo, now that's handy. I hadn't come across that!

Peter


It's really quite simple -- it just scans all of the /proc/*/fd/* entries matching against whatever one asks for.

But potentially quite handy.

Cheers
Posted by: wfaulk

Re: Running linux off a CF card - 15/05/2007 15:18

That's a fairly common Unix command. You'll find it on many OSes. The BSDs have fstat. I find lsof to be a more useful alternative.
Posted by: Roger

Re: Running linux off a CF card - 15/05/2007 15:50

Quote:
That's a fairly common Unix command. You'll find it on many OSes. The BSDs have fstat. I find lsof to be a more useful alternative.


Hmm. Useful. I normally just ls -l /proc/*/fd | grep
Posted by: andym

Re: Running linux off a CF card - 15/05/2007 16:59

Thanks Mark, you are the fscking man when it comes to all things Linux!