compressing and decompressing dd image - zstd instead of gzip

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















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,




  • How to make a disk image and restore from it later?

  • Using DD for disk cloning

  • Making full disk image with DD

  • compressing dd backup on the fly

  • How do you monitor the progress of dd?

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?










share|improve this question


























    2















    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,




    • How to make a disk image and restore from it later?

    • Using DD for disk cloning

    • Making full disk image with DD

    • compressing dd backup on the fly

    • How do you monitor the progress of dd?

    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?










    share|improve this question
























      2












      2








      2








      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,




      • How to make a disk image and restore from it later?

      • Using DD for disk cloning

      • Making full disk image with DD

      • compressing dd backup on the fly

      • How do you monitor the progress of dd?

      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?










      share|improve this question














      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,




      • How to make a disk image and restore from it later?

      • Using DD for disk cloning

      • Making full disk image with DD

      • compressing dd backup on the fly

      • How do you monitor the progress of dd?

      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?







      command-line dd compression zstd






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 6 at 8:55









      bluerayblueray

      1336




      1336




















          2 Answers
          2






          active

          oldest

          votes


















          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. 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







          share|improve this answer
































            2














            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).






            share|improve this answer






















              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "106"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492773%2fcompressing-and-decompressing-dd-image-zstd-instead-of-gzip%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              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. 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







              share|improve this answer





























                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. 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







                share|improve this answer



























                  2












                  2








                  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. 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







                  share|improve this answer















                  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








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 7 at 18:30

























                  answered Jan 6 at 9:09









                  roaimaroaima

                  43.4k553116




                  43.4k553116























                      2














                      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).






                      share|improve this answer



























                        2














                        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).






                        share|improve this answer

























                          2












                          2








                          2







                          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).






                          share|improve this answer













                          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).







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 6 at 15:46









                          CyanCyan

                          1363




                          1363



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492773%2fcompressing-and-decompressing-dd-image-zstd-instead-of-gzip%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown






                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Bahrain

                              Postfix configuration issue with fips on centos 7; mailgun relay