56

I have downloaded Kali v1.1.0 for my Raspberry Pi 2 from here.
But the file I must transfer to the SD Card is a .img.xz, not the desired .img one.

I have tried to unpack with:

$ tar -jxvf kali-1.1.0-rpi2.img.xz 
bzip2: (stdin) is not a bzip2 file. tar: Child returned status 2tar: Error is not recoverable: exiting no 

Installing the xz-utils package:

# apt-get install xz-utils 

... seems not to solve anything (it was already installed).

Same for:

$ tar -jxvf kali-1.1.0-rpi2.img.xz 

What is the correct way to extract/convert the .img.xz file to .img ?

3
  • 1
    On Mac OS X you can just double click the file and it decompresses on the spot. #ElCapitan
    – Jacksonkr
    Commented Apr 6, 2016 at 16:13
  • 1
    On Windows, you can use 7-zip to decompress xz files.
    – Hydraxan14
    Commented May 27, 2016 at 14:50
  • tar is for manipulating tar files; it is not a compression utility. But since tar automatically decompresses tar files before extracting them, people get confused...
    – Hydraxan14
    Commented May 27, 2016 at 15:09

5 Answers 5

50

Just use the unxz program:

unxz kali-1.1.0-rpi2.img.xz

Note: the original file will be removed. Only the .img file will remain. If you want to keep the original archive, use

unxz --keep kali-1.1.0-rpi2.img.xz

.

4
  • 3
    If you wish to retain the original file, add -k or --keep to the command.
    – Hydraxan14
    Commented May 27, 2016 at 14:38
  • For example, xz -d -k kali-1.1.0-rpi2.img.xz.
    – Hydraxan14
    Commented May 27, 2016 at 14:54
  • What about the -d flag, @Hydraxan14 ? Commented Jan 29, 2017 at 11:47
  • From the xz man page: unxz is equivalent to xz --decompress. -d is short version of --decompress.
    – Hydraxan14
    Commented Jan 30, 2017 at 17:01
47

You can use xzcat and dd together.

xzcat kali-1.1.0-rpi.img.xz | dd of=/dev/SDCARDNAMEGOESHERE

It retains original file.

3
  • 1
    This is definitely better than the unxz solution. For storage purpose, you can keep the img.xz as it is. Commented May 4, 2018 at 19:45
  • it works like a charm! love this solution!
    – lesca
    Commented Apr 30, 2021 at 2:43
  • This should be the accepted answer (or at least have more votes than the accepted answer)
    – moo
    Commented Jul 3 at 19:59
2

Use 7zip. When 7zip is installed you can right click the img.xz file and excract to an .img file. Installing 7zip can be as easy as installing applications on linux by using chocolatey. Get it from https://chocolatey.org/ Once it is installed open windows powershell in admin privi's and do "choco install 7zip" other packages can be installed the same way and you can find them using https://chocolatey.org/packages to find some of your favorites. NO MORE DOWNLOAD FOLDER CLUTTER!!! YAY!

0

If this helps, I tried gunzip on my mac, which is native, and it worked fine:

gunzip openhabianpi-raspbian-201804031720-gitdba76f6-crc9e93c3eb.img.xz
3
  • 2
    This cannot work if the file is really xz compressed as its prefix .xz indicates. gunzip can only uncompress files in gzip format. You have to use unxz.
    – Ingo
    Commented Apr 18, 2019 at 21:37
  • Thanks. Interesting... Well, I've just unarchived it and also etched the image on the sdcard. I didn't start the openhabian installation actually to see if the image is valid, but I'll do it next days and let you know the result.
    – user101663
    Commented Apr 18, 2019 at 23:03
  • With unix, file names doesn't matter. You can name a file as you like no matter what type it is. It's possible to name a file with prefix .xz but in real it is a gzip compressed file. Check the real file type with file ./filename.xz.
    – Ingo
    Commented Apr 19, 2019 at 7:23
0

On Ubuntu/Debian, I like to use unp.

unp 2022-09-22-raspios-buster-armhf-lite.img.xz

Here is a little summary from its man-page:

unp is a small script with only one goal: Extract as many archives as possible, of any kind and from any path to the current directory, pre‐ serving the subdirectory structure where needed. Is a Do-What-I-Want utility and helps managing several extraction programs without looking for needed options for the particular tool or worrying about the in‐ stallation of the needed program.

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.