Linux – Under Linux, how to copy files from one filesystem to the other (both gpfs) and preserve hard links

copyfilesystemshardlinklinux

I have a directory with huge files and a number of directories, that have hardlinks on these huge files. How do I copy files from one filesystem to the other and preserve hard links?

Best Answer

tar is preserving links (both symbolic and hard ones). To copy between filesystems, you would use it that way:

tar -cf - -C srcdir . | tar -xpf - -C destdir

See the tar man page for more details (this is where this example is actually coming from).

Related Topic