Skip site navigation (1)Skip section navigation (2)
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>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigDD857B7581B8462CC964FA7B
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Modulok wrote:
> What is the easiest way to copy a directory tree as hard links?
>=20
> 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:
>=20
> $ ls
> foo/
>=20
> $ cp -al foo bar
>=20
> 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 throug=
h
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 s=
hould
link only files but it will create a parallel structure of sub-directorie=
s, so
it will use up a bit of space.

Actually, now I peruse the man page, pax(1) has very similar functionalit=
y,
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
--=20
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW


--------------enigDD857B7581B8462CC964FA7B
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----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-----

--------------enigDD857B7581B8462CC964FA7B--



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