|
|
|
|
|
|
| Author |
Message |
Maxime Henrion *nix forums beginner
Joined: 20 May 2002
Posts: 48
|
Posted: Mon May 20, 2002 7:24 pm Post subject:
a virtual fs to allow root mounting of any fs without special code
|
|
|
Hello all,
I've written a small virtual filesystem called rootfs which solves the
chicken and egg problem of root mounting quite nicely. Currently, we
need special code in each filesystem to allow root mounting. The reason
for this is that the VFS_MOUNT operations of the filesystems generally
need to do a lookup to get a device file (e.g. /dev/ad0s1a), so they
need devfs to be there, and they need lookups to work.
rootfs is nothing more than a 3-vnodes filesystem (/, /dev and /root).
To mount the root filesystem with rootfs, I do the following :
- initialize rootfs
- mount devfs on /dev (on top of rootfs)
- mount the real fs on /root
- umount devfs from /dev
- translate vnodes so that / is now the /root
- remount devfs on /dev (on top of the real fs)
- terminate rootfs
The attached patch implements the above idea with several restrictions.
First, the filesystem has to be converted to the nmount(2) API for this
to work (of course you also need devfs but it is the default). Second,
this patch includes the bits necessary to convert ufs to nmount, but not
the various userland updates that are needed to get this to work (I've
got those in my tree, but I wait for UFS2 to be committed to avoid
unnecessary conflicts). I just give it as a proof of concept, since it
runs fine on my box, but don't try to compile a kernel with it :-P
I also have converted cd9660fs to nmount here and I will test it as soon
as possible, but it's likely to work without further modifications. NFS
will require a bit more tricks however (it apparently has to configure
the interface with ifioctl() before being able to talk to the server).
Comments are of course much appreciated.
Cheers,
Maxime |
|
| Back to top |
|
 |
Maxime Henrion *nix forums beginner
Joined: 20 May 2002
Posts: 48
|
Posted: Mon May 20, 2002 7:28 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Maxime Henrion wrote:
| Quote: | The attached patch implements the above idea with several restrictions.
|
Oops! This was an old patch, please consider this one instead.
Sorry,
Maxime |
|
| Back to top |
|
 |
Robert Watson *nix forums Guru Wannabe
Joined: 22 Mar 2002
Posts: 218
|
Posted: Tue May 21, 2002 1:34 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Spiffy. Once the nmount conversion is done, I'd love to have this in the
base system. As we discussed out of band, my only real concern was that
it wasn't quite a "real mount" in the sense that you don't use a 'struct
mount' when bootstrapping. And, as we discussed, that's probably fine for
this limited scenario, from my perspective, although you don't want people
doing "mount -t rootfs foo /mnt" or anything. I'd be interested in
hearing from others if they think the lack of a "heavy weight mount" is a
problem.
Robert N M Watson FreeBSD Core Team, TrustedBSD Project
robert@fledge.watson.org NAI Labs, Safeport Network Services
On Mon, 20 May 2002, Maxime Henrion wrote:
| Quote: | Hello all,
I've written a small virtual filesystem called rootfs which solves the
chicken and egg problem of root mounting quite nicely. Currently, we
need special code in each filesystem to allow root mounting. The reason
for this is that the VFS_MOUNT operations of the filesystems generally
need to do a lookup to get a device file (e.g. /dev/ad0s1a), so they
need devfs to be there, and they need lookups to work.
rootfs is nothing more than a 3-vnodes filesystem (/, /dev and /root).
To mount the root filesystem with rootfs, I do the following :
- initialize rootfs
- mount devfs on /dev (on top of rootfs)
- mount the real fs on /root
- umount devfs from /dev
- translate vnodes so that / is now the /root
- remount devfs on /dev (on top of the real fs)
- terminate rootfs
The attached patch implements the above idea with several restrictions.
First, the filesystem has to be converted to the nmount(2) API for this
to work (of course you also need devfs but it is the default). Second,
this patch includes the bits necessary to convert ufs to nmount, but not
the various userland updates that are needed to get this to work (I've
got those in my tree, but I wait for UFS2 to be committed to avoid
unnecessary conflicts). I just give it as a proof of concept, since it
runs fine on my box, but don't try to compile a kernel with it :-P
I also have converted cd9660fs to nmount here and I will test it as soon
as possible, but it's likely to work without further modifications. NFS
will require a bit more tricks however (it apparently has to configure
the interface with ifioctl() before being able to talk to the server).
Comments are of course much appreciated.
Cheers,
Maxime
|
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Terry Lambert *nix forums Guru
Joined: 19 Mar 2002
Posts: 434
|
Posted: Tue May 21, 2002 7:16 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Robert Watson wrote:
| Quote: | Spiffy. Once the nmount conversion is done, I'd love to have this in the
base system. As we discussed out of band, my only real concern was that
it wasn't quite a "real mount" in the sense that you don't use a 'struct
mount' when bootstrapping. And, as we discussed, that's probably fine for
this limited scenario, from my perspective, although you don't want people
doing "mount -t rootfs foo /mnt" or anything. I'd be interested in
hearing from others if they think the lack of a "heavy weight mount" is a
problem.
|
You need to do exactly what you said you don't want people doing,
in order to achieve proper jails that are indistinguishable by
way of the root mounts.
-- Terry
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Terry Lambert *nix forums Guru
Joined: 19 Mar 2002
Posts: 434
|
Posted: Tue May 21, 2002 7:44 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Robert Watson wrote:
| Quote: | You need to do exactly what you said you don't want people doing, in
order to achieve proper jails that are indistinguishable by way of the
root mounts.
What I'm saying is that if it's a limited-purpose file system that doesn't
follow the normal conventions for vnodes and their relationship to a
struct mount, we need to prevent people from mis-using the file system, as
it will violate existing code assumptions about the presence of a struct
mount under certain circumstances. If we would like people to be able to
mount it just about anywhere following boot (as with any other synthetic
file system), we'll need a heavy-weight struct mount, which rootfs
currently doesn't have.
|
I think if it's integrated, it needs a "struct mount".
Personally, I'd like to see the "real" root union mounted over it.
| Quote: | That said, I'm not sure what you're saying applies. There's nothing
special about "rootfs" itself, it's pretty minimalist, what's special
about it is that it gives you a place to stick devfs during the bootstrap
(etc) so that you can get rid of special mountroot mounting procedures for
other file systems. I.e., the magic in Maxime's patch is in the
general-purpose root mounting case in the boot code, not in rootfs itself.
|
I was really torn on this patch, so I didn't say anything
previously: it implements part of one of my suggestions, but
it tends to encourage people to not implement the correct
solution to root vs. non-root mounting, since it offers a
workable workaround to doing the right thing (seperating the
mount-into-mountlist from the mount-into-fs-hierarchy is the
cannonically correct approach).
Now that you've implied the very thing I feared, I guess I
need to say something.
I would be really unhappy if the mount during boot ended up
being significantly different than the mounting after boot.
8-(.
There really needs to be a new VFSOP "MOUNTEDON", used to set
the "last mounted on" information, which is the main difference
(from an FS perspective) between root and non-root mounts. The
vnode overlay is also a difference, but it's really obvious how
this could be handed in an FS independent manner in higher level
FS independent code (this is where the mount-into-fs-hierarchy
should be done).
-- Terry
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Maxime Henrion *nix forums beginner
Joined: 20 May 2002
Posts: 48
|
Posted: Tue May 21, 2002 8:57 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Terry Lambert wrote:
| Quote: | Robert Watson wrote:
You need to do exactly what you said you don't want people doing, in
order to achieve proper jails that are indistinguishable by way of the
root mounts.
What I'm saying is that if it's a limited-purpose file system that doesn't
follow the normal conventions for vnodes and their relationship to a
struct mount, we need to prevent people from mis-using the file system, as
it will violate existing code assumptions about the presence of a struct
mount under certain circumstances. If we would like people to be able to
mount it just about anywhere following boot (as with any other synthetic
file system), we'll need a heavy-weight struct mount, which rootfs
currently doesn't have.
I think if it's integrated, it needs a "struct mount".
|
Why ? I used to have a "struct mount" in my code. It's just not
needed, and makes the code bigger. I've monitored all VOP calls during
the root mounting sequence. rootfs never gets called from anything else
but the code I added in vfs_conf.c and by the VFS_MOUNT functions of the
root filesystem (which is the purpose of it). All 3 vnodes get recycled
after the root mounting (VOP_RECLAIM + VOP_INACTIVE).
| Quote: | Personally, I'd like to see the "real" root union mounted over it.
|
I've already tried this. There are exactly 3 hooks for MNT_UNION in the
code, one in lookup(), one in getdirentries(), and one in getdirentries().
If you look at the code, you will see that these hooks only occur when
looking for a file while at the VROOT vnode. So when I have devfs in
/dev (as I need it to be for the filesystem to mount) and when I mount the
real fs on top of it on /, the mount union is actually between the real fs
and rootfs, which in my tests was getting lookup for /.profile (as I don't
have it on my real fs).
To have MNT_UNION working you would need to ensure that the real fs has
no /dev directory (an empty /dev is not enough), so that the lookup for
"/dev" fails and that you are able to give the devfs /dev for hte rest
of the lookup to work.
It also has the disadvantage of leaving rootfs active in the kernel
during its whole lifetime whereas in my code it gets only used at root
mounting.
There is however one thing I could do to simplify rootfs even more,
which is before mounting the real fs on /, do a lookup for /dev, retain
the vnode, then mount the real fs normally on /, and call dounmount() to
unmount the devfs under it after this. This could reduce rootfs to a
2-vnodes filesystem but I didn't test it yet.
| Quote: | That said, I'm not sure what you're saying applies. There's nothing
special about "rootfs" itself, it's pretty minimalist, what's special
about it is that it gives you a place to stick devfs during the bootstrap
(etc) so that you can get rid of special mountroot mounting procedures for
other file systems. I.e., the magic in Maxime's patch is in the
general-purpose root mounting case in the boot code, not in rootfs itself.
I was really torn on this patch, so I didn't say anything
previously: it implements part of one of my suggestions, but
it tends to encourage people to not implement the correct
solution to root vs. non-root mounting, since it offers a
workable workaround to doing the right thing (seperating the
mount-into-mountlist from the mount-into-fs-hierarchy is the
cannonically correct approach).
Now that you've implied the very thing I feared, I guess I
need to say something.
I would be really unhappy if the mount during boot ended up
being significantly different than the mounting after boot.
8-(.
|
Fine, my patch precisely intends to make them the same, since with it we
are now able to mount the root filesystem the very same way we mount
other filesystems, that is, via their VFS_MOUNT function without any
special code. BTW, if you use MNT_UNION, you are the one making things
more different.
| Quote: | There really needs to be a new VFSOP "MOUNTEDON", used to set
the "last mounted on" information, which is the main difference
(from an FS perspective) between root and non-root mounts. The
vnode overlay is also a difference, but it's really obvious how
this could be handed in an FS independent manner in higher level
FS independent code (this is where the mount-into-fs-hierarchy
should be done).
|
I don't think I understand what you're saying.
Maxime
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Robert Watson *nix forums Guru Wannabe
Joined: 22 Mar 2002
Posts: 218
|
Posted: Tue May 21, 2002 9:30 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
On Tue, 21 May 2002, Terry Lambert wrote:
| Quote: | Robert Watson wrote:
Spiffy. Once the nmount conversion is done, I'd love to have this in the
base system. As we discussed out of band, my only real concern was that
it wasn't quite a "real mount" in the sense that you don't use a 'struct
mount' when bootstrapping. And, as we discussed, that's probably fine for
this limited scenario, from my perspective, although you don't want people
doing "mount -t rootfs foo /mnt" or anything. I'd be interested in
hearing from others if they think the lack of a "heavy weight mount" is a
problem.
You need to do exactly what you said you don't want people doing, in
order to achieve proper jails that are indistinguishable by way of the
root mounts.
|
What I'm saying is that if it's a limited-purpose file system that doesn't
follow the normal conventions for vnodes and their relationship to a
struct mount, we need to prevent people from mis-using the file system, as
it will violate existing code assumptions about the presence of a struct
mount under certain circumstances. If we would like people to be able to
mount it just about anywhere following boot (as with any other synthetic
file system), we'll need a heavy-weight struct mount, which rootfs
currently doesn't have.
That said, I'm not sure what you're saying applies. There's nothing
special about "rootfs" itself, it's pretty minimalist, what's special
about it is that it gives you a place to stick devfs during the bootstrap
(etc) so that you can get rid of special mountroot mounting procedures for
other file systems. I.e., the magic in Maxime's patch is in the
general-purpose root mounting case in the boot code, not in rootfs itself.
Robert N M Watson FreeBSD Core Team, TrustedBSD Project
robert@fledge.watson.org NAI Labs, Safeport Network Services
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Ian Dowse *nix forums beginner
Joined: 04 May 2002
Posts: 21
|
Posted: Tue May 21, 2002 10:33 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
In message <20020521225713.GJ496@elvis.mu.org>, Maxime Henrion writes:
| Quote: | There is however one thing I could do to simplify rootfs even more,
which is before mounting the real fs on /, do a lookup for /dev, retain
the vnode, then mount the real fs normally on /, and call dounmount() to
unmount the devfs under it after this. This could reduce rootfs to a
2-vnodes filesystem but I didn't test it yet.
|
Of course, one further simplification would be to do away with
rootfs entirely; mount devfs on /, create a "dev -> ." symlink
within devfs, mount the real root, and then unmount the underlying
devfs :-)
Ian
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Peter Wemm *nix forums Guru Wannabe
Joined: 11 Apr 2002
Posts: 113
|
Posted: Tue May 21, 2002 10:41 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Maxime Henrion wrote:
| Quote: | I've written a small virtual filesystem called rootfs which solves the
chicken and egg problem of root mounting quite nicely. Currently, we
need special code in each filesystem to allow root mounting. The reason
for this is that the VFS_MOUNT operations of the filesystems generally
need to do a lookup to get a device file (e.g. /dev/ad0s1a), so they
need devfs to be there, and they need lookups to work.
rootfs is nothing more than a 3-vnodes filesystem (/, /dev and /root).
To mount the root filesystem with rootfs, I do the following :
- initialize rootfs
- mount devfs on /dev (on top of rootfs)
- mount the real fs on /root
- umount devfs from /dev
- translate vnodes so that / is now the /root
- remount devfs on /dev (on top of the real fs)
- terminate rootfs
|
You know, this sounds an awful lot like what linux does with their
'initrd' ramdisk and pivot_root(2). The main difference is that instead
of the rootfs being a synthetic file system, it is a real file system
that is read/write mounted and you can have init etc living in there.
One thing you didn't clarify above, where does starting init live
in the sequence of events above? Or is this all pre-exec-init stage?
It would be nice to be able to fsck/remount the /root fs while we have the
devfs nodes available.
Cheers,
-Peter
--
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Maxime Henrion *nix forums beginner
Joined: 20 May 2002
Posts: 48
|
Posted: Wed May 22, 2002 10:36 am Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Peter Wemm wrote:
| Quote: | Maxime Henrion wrote:
I've written a small virtual filesystem called rootfs which solves the
chicken and egg problem of root mounting quite nicely. Currently, we
need special code in each filesystem to allow root mounting. The reason
for this is that the VFS_MOUNT operations of the filesystems generally
need to do a lookup to get a device file (e.g. /dev/ad0s1a), so they
need devfs to be there, and they need lookups to work.
rootfs is nothing more than a 3-vnodes filesystem (/, /dev and /root).
To mount the root filesystem with rootfs, I do the following :
- initialize rootfs
- mount devfs on /dev (on top of rootfs)
- mount the real fs on /root
- umount devfs from /dev
- translate vnodes so that / is now the /root
- remount devfs on /dev (on top of the real fs)
- terminate rootfs
You know, this sounds an awful lot like what linux does with their
'initrd' ramdisk and pivot_root(2). The main difference is that instead
of the rootfs being a synthetic file system, it is a real file system
that is read/write mounted and you can have init etc living in there.
One thing you didn't clarify above, where does starting init live
in the sequence of events above? Or is this all pre-exec-init stage?
It would be nice to be able to fsck/remount the /root fs while we have the
devfs nodes available.
|
All this is pre-exec-init stage.
Cheers,
Maxime
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Peter Wemm *nix forums Guru Wannabe
Joined: 11 Apr 2002
Posts: 113
|
Posted: Thu May 23, 2002 9:33 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Maxime Henrion wrote:
| Quote: | Peter Wemm wrote:
Maxime Henrion wrote:
I've written a small virtual filesystem called rootfs which solves the
chicken and egg problem of root mounting quite nicely. Currently, we
need special code in each filesystem to allow root mounting. The reason
for this is that the VFS_MOUNT operations of the filesystems generally
need to do a lookup to get a device file (e.g. /dev/ad0s1a), so they
need devfs to be there, and they need lookups to work.
rootfs is nothing more than a 3-vnodes filesystem (/, /dev and /root).
To mount the root filesystem with rootfs, I do the following :
- initialize rootfs
- mount devfs on /dev (on top of rootfs)
- mount the real fs on /root
- umount devfs from /dev
- translate vnodes so that / is now the /root
- remount devfs on /dev (on top of the real fs)
- terminate rootfs
You know, this sounds an awful lot like what linux does with their
'initrd' ramdisk and pivot_root(2). The main difference is that instead
of the rootfs being a synthetic file system, it is a real file system
that is read/write mounted and you can have init etc living in there.
One thing you didn't clarify above, where does starting init live
in the sequence of events above? Or is this all pre-exec-init stage?
It would be nice to be able to fsck/remount the /root fs while we have the
devfs nodes available.
All this is pre-exec-init stage.
|
So, this is to replace the pre-mountroot bdevvp etc kludges that we have?
How do we solve the problem with the root fs being mounted read only and
not having a /dev directory?
Cheers,
-Peter
--
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Maxime Henrion *nix forums beginner
Joined: 20 May 2002
Posts: 48
|
Posted: Fri May 24, 2002 9:55 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Peter Wemm wrote:
| Quote: | So, this is to replace the pre-mountroot bdevvp etc kludges that we have?
|
Exactly.
| Quote: | How do we solve the problem with the root fs being mounted read only and
not having a /dev directory?
|
This patch doesn't address these problems. I guess I'll have either to
fix MNT_UNION so that it's actually useful, or write yet another mount
flag to solve this problem.
Maxime
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Peter Wemm *nix forums Guru Wannabe
Joined: 11 Apr 2002
Posts: 113
|
Posted: Sat May 25, 2002 5:30 pm Post subject:
Re: a virtual fs to allow root mounting of any fs without special code
|
|
|
Maxime Henrion wrote:
| Quote: | Peter Wemm wrote:
So, this is to replace the pre-mountroot bdevvp etc kludges that we have?
Exactly.
How do we solve the problem with the root fs being mounted read only and
not having a /dev directory?
This patch doesn't address these problems. I guess I'll have either to
fix MNT_UNION so that it's actually useful, or write yet another mount
flag to solve this problem.
|
Or figure out a way to mount a file system on a non-existing directory
entry..
Cheers,
-Peter
--
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Jan 10, 2009 2:26 am | All times are GMT
|
|
Power Rangers | Looking for Credit Cards? | Mobile Phone | Bankruptcy | Jokes
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|