linux – Ignore Symlinks When Extracting Tarball

gnulinuxsymlinktar

I am attempting to extract a tarball (*.tgz, to be exact) and receiving terminal errors on extracted symlinks. Unfortunately, I cannot simply recreate the archive as this is a legacy archive for a system that no longer exists which was created before I was even out of high school (have to love working for a big company).

I have consulted the almighty Google; however all I can seem to find is information for excluding / following symlinks at creation time. The exact error I am receiving is something of a misnomer (error: read-only filesystem) and comes from the fact that a very large portion of the data payload is contained within numerous squash / cram / loop filesystems. The symlinks are referencing data within them which, obviously, cannot be mounted due to errors while extracting said tarball. Chicken; meet egg.

So, in short:

How can I extract a *.tgz archive to completion while either ignoring symlinks or ignoring resultant symlink errors?

For reference:

$ tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
$ uname -a
Linux localhost.localdomain 3.7.9-205.fc18.x86_64 #1 SMP Sun Feb 24 20:10:02 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Best Answer

-h (or --dereference) to dereference will only work upon creation.

Reference: http://www.gnu.org/software/tar/manual/tar.html#SEC138

According to a similar answer here: How do I dereference links when extracting from a tar file? you can mount the archive then copy from it, though I have not tested this myself.

Related Question