28

I am installing Openshift Origin All-in-One Server using below links

https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary

after download when I did:

tar -xf openshift-origin-server-v3.10.0-rc.0-c20e215-linux-64bit.tar.gz -C /opt/redhat

It throws following output but directory got untar in desired directory

5 Answers 5

28

use --no-xattrs when you create a archive file using BSD tar in macOS, which will turn off xattr headers in the generated archive file.

tar -cz --no-xattrs --exclude .* -f zippath source
3
  • 2
    Please explain why your answer works Nov 10, 2022 at 9:00
  • The --exclude .* part made computer act really weird and produce a beeping noise (M2 Mac). It should probably be --exclude=".*" instead or something along the lines, yet it only removed the .DS_Store files and kept the ._FILE:OR_DIRECTORY_NAME ones.
    – Pjotr
    Sep 29, 2023 at 12:31
  • Sorry, but the --no-xattrs part nowadays seems a bit redundant, as this is the default setting... (see docs)
    – mirekphd
    Oct 14, 2023 at 17:19
26

I just encountered the same.

Based on http://lifeonubuntu.com/tar-errors-ignoring-unknown-extended-header-keyword/

"It turns out this is just an issue with tar files created on Mac OS X. Mac OS X uses BSD tar and creates some extra info that is not recognized by GNU tar."

It should extract just fine, so no need to worry about it.

NOTE: The following is bad advice unless you perform other checks to make sure the file is fine. This will hide legitimate errors encountered while trying to extract.

If you'd prefer to not see those error lines you could just redirect the errors to /dev/null like this:

tar -xf openshift-origin-server-v3.10.0-rc.0-c20e215-linux-64bit.tar.gz -C /opt/redhat 2> /dev/null
4
  • 11
    This is bad advice. This would redirect all errors to /dev/null and thus hide legitimate other possible warning messages.
    – josch
    Jan 13, 2020 at 22:44
  • True that... didn't think of that at the time. I guess if you do other checks like sha to make sure the file isn't damaged you might still be "safe enough".
    – aiguofer
    Jan 14, 2020 at 4:47
  • 1
    I am getting this error is being thrown up by the tar in WSL2 Debian when working with the tar created by wsl --export <WSL Image Name> <Export file>. Apr 6, 2021 at 19:08
  • 1
    instead of 2> /dev/null one could 2> >(grep -v "Ignoring unknown extended header" >&2) Sep 14, 2023 at 13:16
11

If you understand why the warning is happening and you want to suppress it, use, --warning=no-unknown-keyword

2
  • This flag is supported only by GNU tar, so I had to do tar xf yourFile.tar.gz --warning=no-unknown-keyword || tar xf yourFile.tar.gz in order to support both MacOS and Linux.
    – Moshisho
    Aug 9, 2023 at 13:14
  • thanks! other useful flags: tar --no-same-owner --no-same-permissions --warning=no-unknown-keyword --warning=no-timestamp --delay-directory-restore
    – milahu
    Aug 11, 2023 at 14:20
1

Addition to answer by aiguofer, if you don't want to see these errors, but also don't want to suppress all errors, you can just filter it out with the following:

tar -xf openshift-origin-server-v3.10.0-rc.0-c20e215-linux-64bit.tar.gz -C /opt/redhat 2>&1 | grep -v 'LIBARCHIVE.xattr.security.selinux'

Or if to suppress all xattr.security related errors:

tar -xf openshift-origin-server-v3.10.0-rc.0-c20e215-linux-64bit.tar.gz -C /opt/redhat 2>&1 | grep -v 'LIBARCHIVE.xattr.security'
0
0

I faced the same when getting a tar file from a target. The "default" tar command installed on my ubuntu host reports the following:

host$ tar xvf NAD_crash.14h07m50s470_16863.XCAL-NotifiDis-6-full.tar
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'
NAD_crash.14h07m50s470_16863/
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'
NAD_crash.14h07m50s470_16863/core.lz4
tar: Unexpected EOF in archive
tar: rmtlseek not stopped at a record boundary
tar: Error is not recoverable: exiting now

It appears that the tar command installed on the target is the BSD version one:

target# /bin/tar --version
bsdtar 3.4.1 - libarchive 3.4.1 zlib/1.2.7.1 liblz4/1.8.3

And the same command on my ubuntu host is the GNU one:

host$ tar --version
tar (GNU tar) 1.30

So, I installed the BSD tar command on my host through the libarchive-tools package to get the bsdtar command:

host$ sudo apt install libarchive-tools
[...]
host$ bsdtar --version
bsdtar 3.4.0 - libarchive 3.4.0 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.8 liblz4/1.9.2 libzstd/1.4.4

Then, I was able to untar my archive without error:

host$ bsdtar xvf NAD_crash.14h07m50s470_16863.XCAL-NotifiDis-6-full.tar 
x NAD_crash.14h07m50s470_16863/
x NAD_crash.14h07m50s470_16863/core.lz4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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