Fascinating.  Yes, I'd love to get a copy of your shell script.  It would be interesting to explore this some more, regardless of whether I end up using it for this particular application.
Thanks,
--Jeff

-----Original Message-----
From: Christopher Marshall [mailto:christopherlmarshall@yahoo.com]
Sent: Wed 2007-03-21 9:17 AM
To: Pipkins, Jeff; user-mode-linux-user@lists.sourceforge.net
Subject: Re: [uml-user] UML for embedded system development

Jeff:

I don't know if you can use the same code with a host kernel (that manages cow files in guest
kernels), but I can think of at least one way to achieve the same effect.

The unionfs filesystem allows you to stack filesystems on top of each other.  Say you have two
directories A, and B, and you mount them on top of each other at directory C.  C's contents are
then the union of the files in A and B.  When you declare, during the mount, that A is read-only
and B is read-write, the effect is that any modifications to the contents of C are stored in B
without molesting the contents of A.  If you delete a file f1 in C (that really exists in A/f1),
the unionfs driver handles that by creating a "whiteout file" in B (B/.wh.f1) that indicates that
f1 should no longer exist in the mount at C.  If you rewrite a portion of a file in C (that really
exists in A), the modified file is written to B.

This has lots of applications.  I somtimes use it to see exactly what files a program is
attempting to modify by mounting the root directory as part of a read-only stack at /usr/root,
using /usr/root-rw as the read-write part of the stack.  I then chroot into /usr/root, run the
program, and examine the contents of /usr/root-rw to see what files were modified / deleted.

In your case, you can alter the boot process by writing a linuxrc file inside an initrd.gz to
setup a union mount of your root filesystem using a ramdisk as a read-write stack and the real
root filesystem as a read-only stack.  After every reboot, any changes to the root filesystem will
disappear, and new changes will be stored in the ramdisk.

This very technique is how some live-CD or live-DVD distributions of linux work.

If you are interested, I have a bash script I use to create the necessary files for doing this
with slackware.  There were some nasty details I had to work out that took me a while to figure
out.  It may save you some time if you decide to go the same route.

Chris Marshall

--- "Pipkins, Jeff" <Jeff.Pipkins@polycom.com> wrote:

> Is there a way to have an embedded system running just one kernel (i.e., not UML), but still
> using a cow file as the root file system?
>
> The reason I ask, is that I'm thinking I want to use UML during development, but not ship it as
> part of an embedded system.  But the use of the cow file is very attractive, especially since
> the system can be restored to factory defaults simply by deleting a file.
>
> So, does the use of a cow file necessarily require a UML guest kernel?  Or can I use the same
> technique with an ordinary linux kernel?
>
> Thanks,
> --Jeff
> > -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV>
_______________________________________________
> User-mode-linux-user mailing list
> User-mode-linux-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user
>