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?


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. Either use sudo pv or 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


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

You have added a few additional command flags to the zstd side, and they look fine too. Just to be on the pedantic side, for decompression, zstd -dvc is enough and will work the same, since -f and -T6 are not useful for this scenario (but 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.