tar: Ignoring unknown extended header keyword `LIBARCHIVE.xattr.security.selinux'
Asked Answered
S

5

30

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

Sufism answered 2/8, 2018 at 14:6 Comment(0)
S
27

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
Seldun answered 7/11, 2018 at 13:49 Comment(5)
This is bad advice. This would redirect all errors to /dev/null and thus hide legitimate other possible warning messages.Subclavius
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".Seldun
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>.Microgroove
instead of 2> /dev/null one could 2> >(grep -v "Ignoring unknown extended header" >&2)Nw
I strongly suggest that you remove the part about redirecting stderr to /dev/null. Apart from that bit (start from "NOTE: The following..."), your post is a good and informative, so I suggest you remove the part that isn't.Jargon
W
31

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
Warren answered 9/11, 2022 at 10:59 Comment(4)
Please explain why your answer worksEndorsement
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.Brahe
Sorry, but the --no-xattrs part nowadays seems a bit redundant, as this is the default setting... (see docs)Fester
--no-xattrs doesn't appear to be the default on Mac OS, where I've just had to apply it to suppress a bunch of messages.Matrix
S
27

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
Seldun answered 7/11, 2018 at 13:49 Comment(5)
This is bad advice. This would redirect all errors to /dev/null and thus hide legitimate other possible warning messages.Subclavius
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".Seldun
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>.Microgroove
instead of 2> /dev/null one could 2> >(grep -v "Ignoring unknown extended header" >&2)Nw
I strongly suggest that you remove the part about redirecting stderr to /dev/null. Apart from that bit (start from "NOTE: The following..."), your post is a good and informative, so I suggest you remove the part that isn't.Jargon
F
13

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

Flabellate answered 8/5, 2023 at 19:56 Comment(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.Earthshaker
thanks! other useful flags: tar --no-same-owner --no-same-permissions --warning=no-unknown-keyword --warning=no-timestamp --delay-directory-restoreWasserman
Y
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'
Yeh answered 18/9, 2022 at 13:14 Comment(0)
B
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
Barm answered 16/4 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.