Copy directory tree as hard links...
m.seaman at infracaninophile.co.uk
Mon Jul 13 08:17:29 UTC 2009
> 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
> $ 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?
Unfortunately the man page is pretty useless, and you have to hunt through
the info page instead. But something like this should do what you want:
# cd /some/dir
# find . -depth -type f -print0 | cpio -0pdl /other/dir
It's the 'l' (link) option that achieves the desired effect. Note: this should
link only files but it will create a parallel structure of sub-directories, so
it will use up a bit of space.
Actually, now I peruse the man page, pax(1) has very similar functionality,
and you could do something like this:
# pax -rwl /some/dir /other/dir
You might also consider using nullfs mounts. In /etc/fstab:
/some/dir /other/dir nullfs rw 0 0
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090713/d5a530fc/signature.pgp
More information about the freebsd-questions