I'm having a problem unpacking files when I try to build from source on my OpenBSD First I thought it was just corrupted files but after it happened to many different programs and from different methods of download (curl -O, FTP, download on Windows and transfer via WinSCP) and even different files of the same program (.xz, .bz2, .lz) I came to believe I must be doing something wrong. The error I get when using

tar xzvf file


gzip: stdin: unrecognized file format
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.

It's happening with different programs, with different download methods and even different files, and this is making me crazy.

Examples of files I can't unpack right now : gnutls-3.4.3.tar.xz and gmp-6.0.0a.tar.bz2 downloaded via Windows and transferred via WinSCP binary mode.

ls -L output:

-rw-r--r--   1 root  wheel  6546268 Jul 12 09:18 gnutls-3.4.3.tar.xz
-rw-r--r--   1 root  wheel  2319400 Jul 24  2015 gmp-6.0.0a.tar.bz2

od -x output:

od -x gnutls-3.4.3.tar.xz | head -10
0000000     37fd    587a    005a    0400    d6e6    46b4    0002    0121
0000020     0016    0000    2f74    a3e5    00e8    f06d    5d02    3300
0000040     8b9b    1912    a356    72d2    a129    5502    49fb    f64d
0000060     c492    64da    be73    7fde    4d79    9170    c055    27b9
0000100     8fc9    6caa    3f02    b551    e014    fd24    a2ad    c57d
0000120     ce49    59f3    da73    0ee9    0319    b7ea    c55c    5e2e
0000140     8fd8    7af6    4f97    b1a8    1ac9    d553    a703    1f1d
0000160     b226    682e    3e00    d2bc    a0f8    4b57    13d0    f887
0000200     7f84    c83f    94cd    154b    1dfe    37cd    25db    13d9
0000220     cdcd    5861    6558    acc3    0103    21ed    e8d9    979d

My tar seems to not even recognize J as an option:

tar xJvf gmp-5.1.3.tar.xz
tar: unknown option J

And error output from the second command :

tar xjvf gmp-6.0.0a.tar.bz2
tar: could not exec bzip2: No such file or directory
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.

More useful error output :

tar xvf gnutls-3.4.3.tar.xz
tar: Cannot identify format. Searching...
tar: Cpio file name length 36039 is out of range
tar: Invalid header, starting valid header search.
tar: Cpio file name length 63118 is out of range
tar: Cpio file name length 38744 is out of range
<suppressed similar errors>
tar: Cpio file name in header is corrupted
tar: Cpio file name length 46161 is out of range
tar: Cpio file name length 32085 is out of range
<suppressed similar errors>
tar: Cpio file name in header is corrupted
<more suppressed similar errors>
tar: End of archive volume 1 reached
  • Suggest you give an example of a file you downloaded. Remote URL, output of "ls -l filename" , output of "od -x filename | head -10".
    – steve
    Jul 24, 2015 at 21:10
  • I'm doing this as root, i don't think its a permission problem...anyway i'm going to do what you said
    – Freedo
    Jul 24, 2015 at 21:16

1 Answer 1


The z option tells tar to decompress an archive using gunzip (or its internal equivalent), and is appropriate only for gzip-compressed archives, typically with a .tar.gz extension.

To decompress archives using other compression formats, you can try

tar xvf file

to see if your tar is clever enough to figure things out on its own. If it isn't, you can either tell it what decompression tool to use, or decompress and pipe the archive:

  • for .tar.bz2: tar xjvf file or bunzip2 -c file | tar xvf -
  • for .tar.xz: tar xJvf file or xzcat file | tar xvf -
  • for .tar.lz: tar xjf file --lzip or lunzip -c file | tar xvf -

With the files you're using:

tar xJvf gnutls-3.4.3.tar.xz
tar xjvf gmp-6.0.0a.tar.bz2

or apparently with OpenBSD tar:

xzcat gnutls-3.4.3.tar.xz | tar xvf -
bunzip2 -c gmp-6.0.0a.tar.bz2 | tar xvf -

You need to make sure you have xz and bunzip2 installed; bunzip2 may be packaged with bzip2.

  • bunzip2 failed, apparently i don't have it installed and could not find it on a packages mirror of OpenBSD, i was able to unpack gnutls thanks!
    – Freedo
    Jul 24, 2015 at 21:34
  • As a note, how do i know if i should download using FTP or curl -O, can this corrupt a file ? And do i need X permission to unpack files ( i noticed that nobody had the permission to execute them too) ?
    – Freedo
    Jul 24, 2015 at 21:36
  • It might be packaged as bzip2... You're welcome! Jul 24, 2015 at 21:36
  • You're unlikely to corrupt a file using FTP or curl. (The only real gotcha is ASCII mode with FTP.) There isn't a permission for unpacking files, you just need to be able to read the archive and to write in the folder you're unpacking to. Jul 24, 2015 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .