tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: EuroBSDcon slides: pivot_root for BSD including NetBSD code
On Tue, Oct 23, 2012 at 10:53:24 -0500, Eric Haszlakiewicz wrote:
> On Sat, Oct 20, 2012 at 04:17:35PM +0200, Adrian Steinmann wrote:
>
> > http://marabu.ch/pivot_root_eurobsdcon_2012/index.html
> >
> > I looking for feedback especially if we should integrate this
> > into a mount -t pivot / mount_pivot program piggy-backing the
> > mount syscall instead of giving it its own syscall which would
> > entail a libc bump. The patch above still uses a new syscall (hence
> > touches quite a few files on only one line) and the userland
> > program "pivot_root" calls the syscall by number so don't forget
> > to modload the kmod :-) First feedback seems to indicate we prefer
> > integration into mount.
>
> Can this be used for filesystems other than root? i.e.
> mount -t pivot -o old=/old_usr /dev/wd1x /usr
I chatted with Adrian about this briefly during social event at the
conference and the following is a brief summary of my attempts to
understand this proposed feature. Your question actually provides a
nice lead in. Disclaimer: I have no clue about file-systems &c, so
don't take this too seriously.
I found it easier to internalize this proposed feature starting from a
more simple question: why can't we mv(1) a mount point, or rather the
fs mounted at that mount point? We can mv /some/dir to /other/place.
All open fds under /some/dir are preserved, obviously. Now, to "move"
a mounted fs we cannot umount(8) it first since open fds make it busy,
but otherise we we would need to do umount /some/dir then mount that
fs at /other/place. Since we only want to manifest (remount) the fs
at a different place in the namespace, we don't really need to care
about "full" umount and open file descriptors, since the files, like
with plain mv, are not going away.
Root is obviously special, since there's no other place to move it to
that is outside root. Thus for pivot-root we need to simultaneously
designate (remount) some other fs as root, so pivot-root is just two
remounts done atomically.
From there we can generalize it to shuffling around arbitrary number
of currently mounted file systems to accomodate scenarios like
"/usr/pkg stays as /usr/pkg under new root (or new /usr)". Since all
currently mounted file systems stay mounted (at different points in
the namespace) there's no problem with open descriptors.
-uwe
Home |
Main Index |
Thread Index |
Old Index