|
|
| Author |
Message |
maus
|
|
Loop mounting in BSD
|
Nov 17 07:00 UTC 2006 |
Is there a BSD equivalent of Loop-back mounting from UNIX, and if there
is, is it implemented in OpenBSD? Specifically, can a directory be
mounted (perhaps with different permissions or flags) in another
location? As an example, suppose I have a stripped down version of /bin
and /sbin and /lib that all reside in /usr/template and I wanted to
mount those read-only in each of several jails, is there some mechanism
by which I could do something to the effect of:
# for i in `ls -d /usr/jails/*` ;
do imaginary_loop_mount_command -o ro /usr/template/bin ${i}/bin ;
imaginary_loop_mount_command -o ro /usr/template/sbin ${i}/sbin ;
imaginary_loop_mount_command -o ro /usr/template/lib ${i}/lib ;
done
I know I could use vnconfig to make files look like block devices and
mount them that way (with each file formatted as a filesystem), but it
seems inflexible, as I seem to understand that the files must be
presized and if it needed to be bigger, a new filesystem within a file
would need to be created and the contents moved across, and that the
extra overhead of a filesystem in a file in another filesystem would
make access fairly slow.
Is there a better way?
Thanks in advance.
- a small, cute rodent
|
| 8 responses total. |
gull
|
|
response 1 of 8:
|
Nov 17 21:10 UTC 2006 |
You could export them as read-only NFS shares and mount them in the
jails, but that's awfully ugly too.
|
maus
|
|
response 2 of 8:
|
Nov 17 22:12 UTC 2006 |
I thought about that, but it seems to be very expensive in terms of
system resources (going through the network stack and userland NFS
stuff), and I would prefer for this server to not have an NFS server
running on it at all.
|
kingjon
|
|
response 3 of 8:
|
Nov 17 22:36 UTC 2006 |
On Linux at least, mount has a -o bind option that allows you to remount a
particular directory elsewhere. On my computer with multiple source-based
distributions, I use it to remount /dev when I chroot into the one I'm not
currently running to do an update. I don't know if you can combine it with
-o ro.
|
maus
|
|
response 4 of 8:
|
Nov 18 03:13 UTC 2006 |
I believe that that is a Linuxism, and is not present in either BSD or
UNIX. As of version 4.0, it does not appear to be an option for OpenBSD.
Also, I am not sure it does what I want; presuming I issued the
commands:
# mount -o bind /usr/template/bin /usr/jails/maus/bin
# mount -o bind /usr/template/bin /usr/jails/brian/bin
Would the directory still be at its original place (/usr/template/) and
copied to the additional mountpoints or would it be *moved* to the new
mountpoint? Would it only exist at the mountpoint of the most recent
call to the command?
I looked over the linux man page for mount(8), and it is a bit unclear
as to what the behaviour would be. I guess the point is academic only,
since this does not appear to be available in BSD or UNIX anyway.
I appreciate the idea though, and it is not a bad one, just probably not
applicable.
|
kingjon
|
|
response 5 of 8:
|
Nov 18 18:28 UTC 2006 |
(First, I appear to have gotten the syntax wrong. According to my manpage, it's
--bind, not -o bind.)
--bind makes the same hierarchy available in two places; --rbind does the same
thing but includes submounts (for example, mount --bind /usr /tmp/usr would
leave /tmp/usr/local as an empty directory if /usr/local was a separate
partition, while mount --rbind /usr /tmp/usr would make /tmp/usr/local have the
same contents as /usr/local). --move makes the tree available in the new place
but not in the old place.
Unfortunately, the manpage says "Note that the filesystem mount options will
remain the same as those on the original mount point, and cannot be changed by
passing the -o option along with --bind/--rbind." And it appears that this is a
Linuxism rather than merely a GNUism as I had thought, since it gives kernel
version numbers when the options appeared.
|
maus
|
|
response 6 of 8:
|
Nov 18 20:38 UTC 2006 |
Thank you for the explanation. Looks like I need to keep looking.
|
cross
|
|
response 7 of 8:
|
Nov 18 23:55 UTC 2006 |
Poor imitation of Plan 9's per-process-group namespaces.
|
herasleftnut
|
|
response 8 of 8:
|
Nov 19 23:08 UTC 2006 |
God damn it. When do we talk about mounting someones mom.
|