Is there a way to move an existing mount point?

From: Rob Landley (landley@trommello.org)
Date: Sun Aug 04 2002 - 21:23:47 EST


I've got a boot script that mounts an ext3 partition, and out of that
loopback mounting a zisofs image to be the system's root partition. (Sort of
a firmware setup: the whole OS can be upgraded atomically by replacing one
file, which rsyncs against a copy of itself fairly nicely.)

The partition the zisofs image lives in is going to become the "var"
partition when the system's the rest of the way up, and I'd like to move the
existing mount to newmount/var. Right now I'm mounting /var, loopback
mounting /zisofs, doing an "exec chroot zisofs /sbin/init auto", and just
leaving a couple of inaccessable mount points cluttering up the start of
/proc/mounts.

This works fine, but it's ugly. I'm in the process of switching to using a
ramdisk for the boot loader, and in the process I was hoping to actually
relocate the first /var mount down under the zisofs/var.

Here's why pivot_root doesn't work: I have to mount the var partition before
I can loopback mount the zisofs (firmware) root partition out of it. Once
the zisofs image is mounted, the var partition is busy (due to loop0 holding
a file open), and pivot_root won't relocate it (on 2.4.18 anyway). In
theory, the zisofs image should point to the same inode out of the same
superblock, so it shouldn't mind moving the mount as long as I don't UNMOUNT
it. But for some reason pivot_root is mad anyway.

pivot_root is even less useful when booting from an initrd, since the var
partition (mounted onto a directory of the ramdisk) is never actually the
root partition anyway. What I WANT is some kind of "move_mount path1 path2".

"mount -o remount" explicitly doesn't change the mount point. "mount --bind
oldmout newmount" just makes duplicate mounts (of subdirectories, which is
cool, but not what I'm looking for. Mounting the same partition again in a
new location (creating a duplicate mount) doesn't allow the first one to
become un-busy and thus be unmounted, even though the reference count of the
superblock should be increased.

Is this a toolchain problem, or a kernel problem, or a documentation problem,
or a "I just don't know what I'm doing yet" problem? I THINK it's a kernel
problem because things seem to be happening per mount that should probably be
happening per superblock (now that superblocks may be multiply mounted and
reference counted), but my understanding of this part of the code is still
very incomplete.

Anybody have any suggestions?

Rob

(P.S. Zisofs is really cool. Thanks HPA. :)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 07 2002 - 22:00:26 EST