dd a compressed *.xz image into a partition
Asked Answered
N

2

23

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.

Notwithstanding answered 5/1, 2018 at 8:21 Comment(0)
O
13

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

xz -d < console.img.xz - | dd of=/dev/mmcblk0p3
Orta answered 5/1, 2018 at 9:24 Comment(1)
Would that be xz -d - < console.img.xz | dd of=/dev/mmcblk0p3 instead? Even then, why pipe the file and not just give it to xz?Cacia
Q
34

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

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

Quicksand answered 1/6, 2019 at 10:18 Comment(3)
While this code snippet may solve the question, including an explanation 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.Embracery
I like the use of xzcat here - It's a little simpler and easier to rememberBekki
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)Trifacial
O
13

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

xz -d < console.img.xz - | dd of=/dev/mmcblk0p3
Orta answered 5/1, 2018 at 9:24 Comment(1)
Would that be xz -d - < console.img.xz | dd of=/dev/mmcblk0p3 instead? Even then, why pipe the file and not just give it to xz?Cacia

© 2022 - 2024 — McMap. All rights reserved.