Date: Mon, 13 Jul 2009 09:17:14 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Modulok <modulok@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Copy directory tree as hard links... Message-ID: <4A5AED8A.8050300@infracaninophile.co.uk> In-Reply-To: <64c038660907130002i73a95d9bq9224373b5ff89f08@mail.gmail.com> References: <64c038660907130002i73a95d9bq9224373b5ff89f08@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
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?
cpio(1)
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
See mount_nullfs(8).
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEAREIAAYFAkpa7Y8ACgkQ8Mjk52CukIyOEACfVc4hAk7EbKs+0LOmp4exI3c7
Zz0AnRQGJjsbJ1a+lMaq6vXzG8KbTOCF
=Lciu
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A5AED8A.8050300>
