Memory disk "a la mfsroot"?

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Feb 11 19:19:23 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/02/2010 17:10, Pierre-Luc Drouin wrote:
>> Actually, I was thinking more along the lines of mounting a .iso as a
>> cd9660 filesystem.  Which won't muck up the underlying .iso, but only
>> because it's read-only.  You could mount a FFS image read-only in
>> exactly the same way -- I think there's a 'last mounted on' field in the
>> backing file image that will be updated if the it is writable (even if
>> the fs itself is mounted ro) but that's not the right answer either.
>>
>> Basically, you're going to have to mount and initialise as two separate
>> operations as far as I can see.
>>   
> By this do you mean that I would need to copy the whole content of the
> read-only filesystem to the memory disk?

Yes.

> I looked at the man page for mount_unionfs and there is a big warning
> saying that it is a bad idea to use it, so I guess I will pass on this
> solution...

Ah -- that warning is probably a bit more alarming than it really
needs to be nowadays.  unionfs can be used pretty effectively for many
purposes.  Try it and see what happens is the best policy.

> What I am trying to do basically is to mount a filesystem from a CD but
> I want to use a memory disk to allow write operations. I would basically
> want the filesystem to behave like a regular read-write filesystem, but
> not have to copy everything into a memory disk. What does "mfs_root" do
> exactly in the official FreeBSD boot CDs? Does it copy the content of
> mfsroot.gz into a memory disk? That filesystem is so small that I guess
> it can be copied without any problem...

mfs_root does exactly that: it creates a memory based filesystem and
then expands a tarball of the system into it.

One approach you might consider is mounting your CD image read-only as
per usual, but creating memory-based /tmp and /var partitions[*].  Most
of the usual root and /usr filesystems don't need to be read-write at
all. There are only a few special locations that do and those will need
special handling.  You will need to initialise your memory-backed /var
partiton by expanding a skeleton structure into it, but that's going to
be pretty small really. You will also need to make provision for editing
various files under /etc -- you might be able to create a /var/etc and
replace the real files in /etc with symlinks to copies in /var/etc.
Possibly.  Or you could just have /var/etc nullfs mounted on top of /etc.

I've read reports from people setting up such things -- a while back
now, but as far as I recall they were on the whole successful.

	Cheers,

	Matthew

[*] There are already scripts to do this sort of thing within the base
system, although primarily aimed at diskless systems.

- -- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt0WDQACgkQ8Mjk52CukIyWgwCeMHjE7VsdHx5HLGQw75SplJ9v
6zUAni7BZsLYsp2qGSFUUMmkjpVMYomt
=4SwV
-----END PGP SIGNATURE-----


More information about the freebsd-questions mailing list