5

I got a tarball (let's say t.tar.gz) that contains the following files

./a/a.txt
./b/b.txt 

where ./b/b.txt is a hard link to ./a/a.txt.

I want to unpack the tarball on a network file system (AFS) that only supports hard links in the same directory (see here). Therefore, just unpacking it via tar -xzf t.tar.gz raises an error that the hard link ./b/b.txt cannot be created.

So far, my solution to the problem was to unpack ./t.tar.gz on a file system that supports ordinary hard links. Then pack it again with the option --hard-dereference as the GNU tar manual proposes. And lastly, unpack that new tarball into the AFS.

As this is unsatisfactory for me, I'm asking if there is an easier way to get the content of the archive unpacked directly to it's final destination? Such as an equivalent option to --hard-dereference for unpacking instead of archiving?

2

Mount the archive as a directory, for example with AVFS, then use your favorite file copying tool.

mountavfs
cp -a --no-preserve=links ~/.avfs/path/to/t.tar.gz\# target-directory/

or

mountavfs
rsync -a ~/.avfs/path/to/t.tar.gz\#/ target-directory/
  • Thanks for the introduction to mountavfs. This seems to be the best option for me right now. – Denis Mar 1 '16 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.