Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jul 2000 13:29:18 -0700
From:      "Crist J. Clark" <cjc@cjc-desktop.reflexcom.com>
To:        Doug Lee <dgl@visi.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Fake root for symlinks?
Message-ID:  <20000729132918.B7953@cjc-desktop.reflexcom.com>
In-Reply-To: <Pine.BSF.4.21.0007290310130.81871-100000@kirk.dsl.visi.com>; from dgl@visi.com on Sat, Jul 29, 2000 at 03:18:57AM -0500
References:  <Pine.BSF.4.21.0007290310130.81871-100000@kirk.dsl.visi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[This mail was resent due to delivery problems. If you have received it 
twice, please ignore. Sorry for any inconvenience.]

On Sat, Jul 29, 2000 at 03:18:57AM -0500, Doug Lee wrote:
> I have had occasion to mount drives and NFS shares containing absolute
> symlinks which, once mounted, point to the wrong thing.  Can I somehow
> make the "root" for such absolute links something other than /?
> 
> Example:  I mount an old FreeBSD drive in /old complete with all its
> partitions:  The old / becomes /old, the old /usr becomes /old/usr,
> etc.  (I recently did this while upgrading from 3.4 to 4.1 via a fresh
> install on a new drive.)  I then make the mistake of trying to change to
> /old/home, which was a symlink to the old /usr/home... but now I'm
> suddenly waking up in /usr/home on my current system.  I want to mount the
> old partitions such that the absolute symlink /old/home --> /usr/home is
> redirected to point to /old/usr/home.  This is surely a problem
> encountered by many folks making NFS mounts as well.

This is not unique to NFS. I learned this lesson too from putting
FreeBSD 3.x and 4.x systems on the same drive. The 4.x system has a
/3.x-STABLE directory and the 3.x has a /4.x-STABLE where they mount
the stuff from one another. Sometimes absolute symlinks drop you in
the running system when 'cd'ing around the other.

There is no reasonable way to change this, not with the way symlinks
actually work. The fact symlinks are the only way to link files
across filesystems, starting to do dynamic things with what / means
will be a mess. The fact that a link pointed to /usr/home is _always_
/usr/home no matter where the filesystem containing a link to it is
mounted, IMHO, a useful feature rather than bug.

In your case, and what I do with my two FreeBSDs on one disk, is to,

  % rm /old/home
  % ln -s /old/home usr/home

Note... NO initial '/'. If you are in /old and now do a 'cd home,'
you'll end up in the right place. As a rule of thumb, always make
symlinks that are supposed to point to something in the same
filesystem relative (cannot start with '/'); this way, they can never
break by moving the mount point. As for symlinks that cross
filesystems... a much stickier point. Since you cannot necesarily be
sure the other filesystem will be there, they cannot be guaranteed to
work. What to do will depend on how you mean things to work.
-- 
Crist J. Clark                           cjclark@alum.mit.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000729132918.B7953>