Copy directory tree as hard links...
mel.flynn+fbsd.questions at mailing.thruhere.net
Mon Jul 13 08:39:09 UTC 2009
On Monday 13 July 2009 00:17:14 Matthew Seaman wrote:
> Modulok wrote:
> > What is the easiest way to copy a directory tree as hard links?
> > Linux has a nice little 'cp -al' flag combo to do this. The FreeBSD
> > cp(1) manual page says to use pax or tar, but how do I get the ability
> > to rename the file without first creating a destination file? I don't
> > want an archive, just regular directory tree sitting right next to the
> > original, but with a new name ... consisting of of hard links back to
> > the original. For example on linux I could do something like:
> > $ ls
> > foo/
> > $ cp -al foo bar
> > The result would be a new copy of foo, which takes up no additional
> > space, as all files share the same inodes. Is there an easy way to do
> > this on FreeBSD?
> You might also consider using nullfs mounts. In /etc/fstab:
> /some/dir /other/dir nullfs rw 0 0
> See mount_nullfs(8).
There's one important difference there:
rm bar/baz disconnects the hardlink, while with nullfs both foo/baz and
bar/baz are gone (assuming rw mount). unionfs would replicate the hardlink
behavior with quite a few caveats.
More information about the freebsd-questions