Earlier I was using fsarchiver to create compressed partition image. Due to some weird behavior I am choosing to replace it with dd.

However, I like how fsarchiver compressed with zstd.

So, I studied,

What these essentially say is, I have to use the following command to backup

dd if=/dev/sda2 status=progress | gzip -c > /media/mint/Data/_Fsarchiver/MintV1.img.gz

And the following command to restore

gunzip -c /media/mint/Data/_Fsarchiver/MintV1.img.gz | dd of=/dev/sda2 status=progress

Now I want to replace gzip -c & gunzip -c with zstd & zstd -d

The commands I came up with are

To compress

sudo dd if=/dev/sda2 status=progress | zstd -16vT6 > /media/mint/Data/_Fsarchiver/MintV1.zst

To decompress

zstd -vdcfT6 /media/mint/Data/_Fsarchiver/MintV1.zst | dd of=/dev/sda2 status=progress

Is it safe to try these commands or am I doing something wrong?

2 Answers 2


Using dd like that (without any options) will make your life miserable. Just cut it out entirely. Or at the very least increase its block size and tell it not to object to short reads.

  1. Without dd, first run sudo -s to get a root shell:

     gzip </dev/sda2 >/media/mint/Data/_Fsarchiver/MintV1.img.gz
     gunzip </media/mint/Data/_Fsarchiver/MintV1.img.gz >/dev/sda2

    Your zstd commands look entirely plausible, but just omit dd and read/write the device directly as root. (My version doesn't understand your T6 so I've omitted that here.)

     zstd -16v </dev/sda2 >/media/mint/Data/_Fsarchiver/MintV1.zst    
     zstdcat -v /media/mint/Data/_Fsarchiver/MintV1.zst >/dev/sda2
  2. With dd, either prefix the dd with sudo or use sudo -s to get a root shell:

     dd bs=1M iflag=fullblock if=/dev/sda2 status=progress | gzip >/media/mint/Data/_Fsarchiver/MintV1.img.gz
     gzcat /media/mint/Data/_Fsarchiver/MintV1.img.gz | dd bs=1M iflag=fullblock of=/dev/sda2 status=progress
     dd bs=1M iflag=fullblock if=/dev/sda2 status=progress | zstd -16v >/media/mint/Data/_Fsarchiver/MintV1.img.zst
     zstdcat /media/mint/Data/_Fsarchiver/MintV1.img.zst | dd bs=1M iflag=fullblock of=/dev/sda2 status=progress
  3. With pv instead of dd. Use sudo -s beforehand to get a root shell:

     pv /dev/sda2 | gzip >/media/mint/Data/_Fsarchiver/MintV1.img.gz
     gzcat /media/mint/Data/_Fsarchiver/MintV1.img.gz | pv >/dev/sda2
     pv /dev/sda2 | zstd -16 >/media/mint/Data/_Fsarchiver/MintV1.img.zst
     zstdzcat /media/mint/Data/_Fsarchiver/MintV1.img.zst | pv >/dev/sda2

    Also see Syntax When Combining dd and pv

As always, to read with elevated permissions change command <source to sudo cat source | command, and to write with elevated permissions replace command >target with command | sudo tee target >/dev/null.

  • The different variations are much appreciated.The fullblock flag is interesting. I take it that dd's implementation tries to "be smart" and do clever speed tricks or something. Could you perhaps share some specifics if you know them? Jun 10, 2020 at 15:24
  • @JonathanKomar without fullblock, dd will read and process short blocks (i.e. if you've asked for 1MB but only 500KB was available, that's what you'll get). If the next read returns zero bytes (because none is yet available from the source) it will be considered an EOF marker and reading will end. On Linux-based systems use cat instead of dd and all will be good
    – roaima
    Jun 10, 2020 at 16:15

zstd supports same commands and pipe capabilities as gzip, so if the set of commands works with gzip, it will work with zstd too.

As a minor comment, note that several command flags on the decompression side are redundant: zstd -dvc would be enough and work the same, since -f and -T6 are not useful for this scenario (though thankfully they also don't hurt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.