From owner-freebsd-questions@FreeBSD.ORG Mon Jul 13 08:17:28 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B8E7106564A for ; Mon, 13 Jul 2009 08:17:28 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 21E2F8FC14 for ; Mon, 13 Jul 2009 08:17:27 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id n6D8HJrR029766; Mon, 13 Jul 2009 09:17:20 +0100 (BST) (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk n6D8HJrR029766 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1247473040; bh=v21lF3uo2BFxf6s6ttiIq0x8g0ZUTtwAYEcrHlD1giM=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4A5AED8A.8050300@infracaninophile.co.uk>|Date:=20M on,=2013=20Jul=202009=2009:17:14=20+0100|From:=20Matthew=20Seaman= 20|Organization:=20Infracaninophi le|User-Agent:=20Thunderbird=202.0.0.22=20(X11/20090625)|MIME-Vers ion:=201.0|To:=20Modulok=20|CC:=20freebsd-quest ions@freebsd.org|Subject:=20Re:=20Copy=20directory=20tree=20as=20h ard=20links...|References:=20<64c038660907130002i73a95d9bq9224373b 5ff89f08@mail.gmail.com>|In-Reply-To:=20<64c038660907130002i73a95d 9bq9224373b5ff89f08@mail.gmail.com>|X-Enigmail-Version:=200.95.6|C ontent-Type:=20multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A= 20protocol=3D"application/pgp-signature"=3B=0D=0A=20boundary=3D"-- ----------enigDD857B7581B8462CC964FA7B"; b=qxAlzShdUddx2BilaSwEf7xDkcHVDfOPtrIvtSKn8g3LNggc33IzcqROInE3ZuHQb dkm0o68YHfPnW53QGdctgnBXbEO7SnMbGn8HBNTIXbk4gCbjz2CcfT5Wa5sGE+hWk2 pwgYfL9yY5ue2X7NqisAW8Hesn1uQvxNAuQupVbI= X-Authentication-Warning: happy-idiot-talk.infracaninophile.co.uk: Host localhost [IPv6:::1] claimed to be happy-idiot-talk.infracaninophile.co.uk Message-ID: <4A5AED8A.8050300@infracaninophile.co.uk> Date: Mon, 13 Jul 2009 09:17:14 +0100 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.22 (X11/20090625) MIME-Version: 1.0 To: Modulok References: <64c038660907130002i73a95d9bq9224373b5ff89f08@mail.gmail.com> In-Reply-To: <64c038660907130002i73a95d9bq9224373b5ff89f08@mail.gmail.com> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigDD857B7581B8462CC964FA7B" X-Virus-Scanned: clamav-milter 0.95.2 at happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: freebsd-questions@freebsd.org Subject: Re: Copy directory tree as hard links... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jul 2009 08:17:29 -0000 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--