Memory disk a la mfsroot?

2010-02-11 Thread Pierre-Luc Drouin

Hi,

I would like to know if there is a mount command that allows to create a 
memory disk that can be initialized from a file. What I am looking for 
is something like mount_mfs -F, but that does not modify the actual 
file. I know what I could easily to this by copying the content of the 
file to the memory disk, but I am looking for a solution that can be 
configured via fstab.


Thanks!
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Matthew Seaman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/02/2010 14:53, Pierre-Luc Drouin wrote:

 I would like to know if there is a mount command that allows to create a
 memory disk that can be initialized from a file. What I am looking for
 is something like mount_mfs -F, but that does not modify the actual
 file. I know what I could easily to this by copying the content of the
 file to the memory disk, but I am looking for a solution that can be
 configured via fstab.

Yes.  See mdconfig(8) -- there are examples in there of exactly what you
want to do.

Cheers,

Matthew

- -- 
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/

iEYEARECAAYFAkt0HlYACgkQ8Mjk52CukIyprwCfQj9DwqHtLoDx2ZWCrhglFDfH
dR4AoIEw3CyS2zPajdi4PLGC7aLHj5aI
=Xr7U
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Pierre-Luc Drouin

Matthew Seaman wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/02/2010 14:53, Pierre-Luc Drouin wrote:

  

I would like to know if there is a mount command that allows to create a
memory disk that can be initialized from a file. What I am looking for
is something like mount_mfs -F, but that does not modify the actual
file. I know what I could easily to this by copying the content of the
file to the memory disk, but I am looking for a solution that can be
configured via fstab.



Yes.  See mdconfig(8) -- there are examples in there of exactly what you
want to do.

Cheers,

Matthew

- -- 
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/

iEYEARECAAYFAkt0HlYACgkQ8Mjk52CukIyprwCfQj9DwqHtLoDx2ZWCrhglFDfH
dR4AoIEw3CyS2zPajdi4PLGC7aLHj5aI
=Xr7U
-END PGP SIGNATURE-
  
I might be missing something in the mdconfig man page, but in the 
examples I see they always allow modifications to the backing file. As I 
said I am looking for a solution where the backing file is only read, 
but I want to mount the memory disk in read-write mode. Also, I want 
only the modifications to be kept in the RAM, not the initial files.


Thanks!
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread RW
On Thu, 11 Feb 2010 15:12:22 +
Matthew Seaman m.sea...@infracaninophile.co.uk wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 11/02/2010 14:53, Pierre-Luc Drouin wrote:
 
  I would like to know if there is a mount command that allows to
  create a memory disk that can be initialized from a file. What I am
  looking for is something like mount_mfs -F, but that does not
  modify the actual file. I know what I could easily to this by
  copying the content of the file to the memory disk, but I am
  looking for a solution that can be configured via fstab.
 
 Yes.  See mdconfig(8) -- there are examples in there of exactly what
 you want to do.

I don't think covers what he is asking for. I think you would need a
union filsystem that overlays a swap-backed filesystem on top of a
file-backed filesystem - if that's possible.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Matthew Seaman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/02/2010 15:39, RW wrote:
 On Thu, 11 Feb 2010 15:12:22 +
 Matthew Seaman m.sea...@infracaninophile.co.uk wrote:

 On 11/02/2010 14:53, Pierre-Luc Drouin wrote:

 I would like to know if there is a mount command that allows to
 create a memory disk that can be initialized from a file. What I am
 looking for is something like mount_mfs -F, but that does not
 modify the actual file. I know what I could easily to this by
 copying the content of the file to the memory disk, but I am
 looking for a solution that can be configured via fstab.

 Yes.  See mdconfig(8) -- there are examples in there of exactly what
 you want to do.
 
 I don't think covers what he is asking for. I think you would need a
 union filsystem that overlays a swap-backed filesystem on top of a
 file-backed filesystem - if that's possible.

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.

Cheers,

Matthew

- -- 
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/

iEYEARECAAYFAkt0KDsACgkQ8Mjk52CukIxZaACcCIsHKNBckWDFzRWDJqEH/vVC
Pd4AnRp74n7+Jl+z28VwBEYqpfQmNVJ0
=lxug
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Pierre-Luc Drouin

Matthew Seaman wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/02/2010 15:39, RW wrote:
  

On Thu, 11 Feb 2010 15:12:22 +
Matthew Seaman m.sea...@infracaninophile.co.uk wrote:



  

On 11/02/2010 14:53, Pierre-Luc Drouin wrote:

  

I would like to know if there is a mount command that allows to
create a memory disk that can be initialized from a file. What I am
looking for is something like mount_mfs -F, but that does not
modify the actual file. I know what I could easily to this by
copying the content of the file to the memory disk, but I am
looking for a solution that can be configured via fstab.


Yes.  See mdconfig(8) -- there are examples in there of exactly what
you want to do.
  

I don't think covers what he is asking for. I think you would need a
union filsystem that overlays a swap-backed filesystem on top of a
file-backed filesystem - if that's possible.



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?


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...


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...


Thanks!

Cheers,

Matthew

- -- 
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/

iEYEARECAAYFAkt0KDsACgkQ8Mjk52CukIxZaACcCIsHKNBckWDFzRWDJqEH/vVC
Pd4AnRp74n7+Jl+z28VwBEYqpfQmNVJ0
=lxug
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Matthew Seaman
-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-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Memory disk a la mfsroot?

2010-02-11 Thread Pierre-Luc Drouin

Matthew Seaman wrote:

-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-
  


Thanks,

so I think I will do the following:
1-Create a mfsroot.gz with empty /usr, /var, /boot/kernel and 
/boot/modules directories and have it mounted through loader.conf
2-Create a rc.d script that is called immediately after rc.d/conf and 
that does the following:
-Mount /usr using mdmfs and an independent backing file on the CD (so 
this way the whole content of /usr would not be loaded into RAM)

-Create a 500MB memory disk and mount it in /memdisk
-Create /memdisk/{var,tmp,root,home,usr}
-mount_nullfs /memdisk/var and /memdisk/tmp on /var and /tmp respectively
-copy the content of /root and /home (i.e. just a few config files) to 
their respective directories in /memdisk
-mount_nulls /memdisk/root and /memdisk/home on /root and /home 
respectively

-mount_unionfs /memdisk/usr over /usr
3-use populate_var=YES in rc.conf to automatically populate the /var 
directory


So using this I would have a read-write file system without loading the 
whole content of /usr into RAM, I would minimize memory usage by 
regrouping all the writable directories into a single memory disk and I 
would also minimize the amount of data that is copied from the CD to the 
memory. Does it sound like a good plan?


I read something about a limit of 45MB for mfsroot.gz to prevent kernel 
crashing. Have you ever heard about this?


Thanks!

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org