Skip to contentSkip to conversation

Rootfs choice ideas

DISCUSSION Michael 3 participants 3 messages Dec 17, 2004 – Dec 21, 2004 Memory technology devices (MTD)

lore
Share & tools
lore

Michael

author
#0 lore raw

Hi. I was wondering if you could comment on some of my ideas regarding a root filesystem choice. I did some simple searches on google, but didn't find what I was looking for. I thought this list was the most appropriate to post to.

I have an embedded system, using only NAND flash. This stores my bootloader, kernel, and root filesystem. The bootloader and kernel are protected by using the same block ECC mechanisms that JFFS2 uses. I write them (mtd0 and mtd1) with nandwrite -j, and read them (correcting bits using the ECC as necessary) in my bootloader. I could further protect them (in case of powerfail during updating) by having another copy (either mirrored or failsafe) of each, using a CRC or similar to check the validity of the entire image.

Now, I'm unclear as to the best way to protect the root filesystem and its files against accidental corruption; Either by flash errors or by a logical error (e.g. in the update procedure).

Currently, we're using JFFS2 as the root filesystem, in read-write mode. It's nice, as it provides power-fail safety, wear levelling and such. And we can modify files freely.

However, there seem to be some disadvantages:
1. Instead of versioning a fixed filesystem image (which you could
do with cramfs or initrd), you now manage a collection of files each of which could change independently.
2. It would be hard or impractical to check the entire image for
consistency, as you could with a cramfs image.
3. I could perhaps run into problems when updating it, for
instance if the update fails part-way through.
4. There seems to be some overhead in scanning the rootfs at boot
time (yeah, there are recent changes that speed this up), and garbage collection running in the background. (which is a seperate issue)

So, it's acting very much like a desktop (which can possibly develope cruft), and very little like an embedded device (which typically can't change).

Does anyone share some of these same concerns (or perhaps others as well)? What schemes have you used or seen, and how do they compare?

These are some ideas I've been throwing around:

1. Use a non-changing cramfs or initrd root filesystem, mounting /var and /tmp in ram, using tmpfs.
Then I can verify and version this rootfs as a whole, perhaps storing multiple copies.

2. Use JFFS2 only for logs, application data and config (and perhaps the application itself).

3. Allow updating when booting (the static rootfs in idea #1 could check for the existance of an update file (I'm going to use a USB flash drive), and use that to update the system while it's safe to overwrite anything and everything.

4. If any base OS files need to change (modules, /etc/*, ...), they can be stored on the JFFS2 rootfs and overwrite the base ones. (kind of like Knoppix or DSL do)

How do these ideas sound?
Am I too paranoid? going about this the wrong way? misinformed?

Any feedback would be great.
Thanks in advance.
Mike

#1 lore raw
Quoted 1 line · Michael

And we can modify files freely.

Yes but you don't _have_ to modify files freely. You can exercise a little restraint :)

Quoted 4 lines

However, there seem to be some disadvantages:
1. Instead of versioning a fixed filesystem image (which you could
do with cramfs or initrd), you now manage a collection of files each of which could change independently.

Yes. This is usually done in packages -- by RPM or more usefully on an embedded system by something smaller like ipkg. Take a look at the Familiar distribution.

Quoted 2 lines

2. It would be hard or impractical to check the entire image for
consistency, as you could with a cramfs image.

'rpm -Vva'

Not sure if ipkg stores checksums of the installed files.

Quoted 2 lines

3. I could perhaps run into problems when updating it, for
instance if the update fails part-way through.

You reattempt the update after you come back up.

Quoted 4 lines

4. There seems to be some overhead in scanning the rootfs at boot
time (yeah, there are recent changes that speed this up), and garbage collection running in the background. (which is a seperate issue)

These are true. We're trying to improve it.

Quoted 7 lines

So, it's acting very much like a desktop (which can possibly develope cruft), and very little like an embedded device (which typically can't change).

Does anyone share some of these same concerns (or perhaps others as well)? What schemes have you used or seen, and how do they compare?

Basically it's up to you -- if you can manage to live with a read-only file system, as presumably you could since you seem to consider writeability a disadvantage, then you might as well stick with cramfs.

Signature · 1 line
dwmw2
#2 lore raw
Quoted 4 lines
Quoted 1 line

And we can modify files freely.

Yes but you don't _have_ to modify files freely. You can exercise a little restraint :)

Well, perhaps you don't know me too well. =] But you have a good point.

Quoted 3 lines

Yes. This is usually done in packages -- by RPM or more usefully on an embedded system by something smaller like ipkg. Take a look at the Familiar distribution.

Thanks, I will do that. I guess I just haven't thought along those lines.

Quoted 3 lines

'rpm -Vva'

Not sure if ipkg stores checksums of the installed files.

Aha. Well, I'd have to say I've never used rpm before. I usually use Slackware, just starting with Debian (laptop) and Gentoo (x86-64 desktop)

Quoted 4 lines
Quoted 2 lines

3. I could perhaps run into problems when updating it, for
instance if the update fails part-way through.

You reattempt the update after you come back up.

If I can come back up with a partially failed update. But yes, the same thing can be done that I was proposing, but using packages on a JFFS2 filesystem as well.

Quoted 3 lines

Basically it's up to you -- if you can manage to live with a read-only file system, as presumably you could since you seem to consider writeability a disadvantage, then you might as well stick with cramfs.

Well, I suppose I considered it a disadvantage when I don't need it. My idea was to partition read-only areas (maybe CRAMFS) separately from a read-write area (JFFS2). But there seem to be multiple ways of doing this.

Thanks for your feedback. It is appreciated, and I'll mull over it for a bit.

Mike