21

I'm trying to copy a compressed image into a partition inside a Beaglebone. Usually, it is a 2 step process:

xz -d console.img.xz # console.img is created
dd if=console.img of=/dev/mmcblk0p3

Is there a way, I can do it in a single step without uncompressing the file *.img.xz? This is because after uncompressed the image, it is too big for the current partition.

Sayanee
  • 4,957
  • 4
  • 29
  • 35

2 Answers2

28

xzcat console.img.xz | dd of=/dev/mmcblk0p3 status=progress

xz -dc console.img.xz | dd of=/dev/mmcblk0p3 status=progress

Sam
  • 91
  • 1
  • 5
Lev Lybin
  • 410
  • 1
  • 5
  • 6
  • 3
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – rene Jun 01 '19 at 11:42
  • 1
    I like the use of xzcat here - It's a little simpler and easier to remember – CrazyPyro May 14 '21 at 15:47
  • 3
    For anyone curious, on `xz` the `-d` option is for decompression and `-c` is to send the output to stdout (which helps since we are piping the output to `dd` as stdin) – Jeff Reeves Aug 29 '21 at 07:06
13

This seems to work, if that is what you mean:

xz -d < console.img.xz - | dd of=/dev/mmcblk0p3
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432