Friday, July 30, 2010

Altering a Mount Point While Something Mounted, Easier in Linux than Solaris

Sooner or later, you'll be bitten by a strange permissions bug:  although you seem to be able to move around and through a mountpoint, you'll notice that stupid things don't work:

# cd .
Permission Denied
# pwd
/mnt/foo
# cd /mnt/foo
# cd ../foo
..:  Permission Denied
Just weird stuff.  You finally get to it, and realize that your mountpoint has bad permissions.

This happens -- usually when adding an NFS or drive mount quickly, and it's not often that bad permissions on the mountpoint will be noticed or a problem;  but it will, that one day.

But now what?  You can't be sure, since when you ls-ld it you'll just see the permissions granted on the mounted volume, which are usually what we want except today the ones on the mountpoint itself is what we need to see.  We can't unmount the volume because, usually, this kinda thing is discovered when people need - need, you understand - the volume to be mounted.  Reboot?  Nuh-uh.

The fix is fun, and, as I may have mentioned, it's easier in Linux.
  1. create a mountpoint
    # mkdir /mnt/save
  2. nfsmount your root volume on itself at the mountpoint
    # mount -t nfs localhost:/ /mnt/save
  3. check and fix the mountpoint
    # ls -ld /mnt/save/mnt/foo
    # chmod 755 /mnt/save/mnt/foo

How does it even work?  Well, since mounting a filesystem (now) doesn't re-export the mounts on top of it, when you mount the root volume on top of itself, all you get is the bare filesystem and not the things mounted on it.  But unless you know the trick, you can neither inspect the mountpoint nor anything normally underneath it before something else gets mounted on top of it -- and squashes what's there from view.

 .. which is why you should always keep your bikini pics in /boot on the root, before the /boot is mounted on top of it.  The wife will never find them there !

How is Linux easier?  Check out and confirm that your autofs is configured out of the box, and usually it is.  Start autofs if it's not already, and navigate to /net/localhost/mnt/foo .  Too easy.

Labels: , ,