mksquashfs: how to include full absolute directory paths inside the squashfs image?

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












When I create a squashfs image from multiple directories such as:



  • /bin/

  • /usr/bin/

  • /usr/local/bin/

  • /some/other/random/folder/

  • /another/long/path/

If I use command...



mksquashfs /bin /usr/bin /usr/local/bin /some/other/random/folder /another/long/path MyNewImage.squashfs


It gives me an image with these top-level folders:



  • bin/

  • bin_1/

  • bin_2/

  • folder/

  • path/

I want my image to contain the full paths from the original filesystem:



  • bin/

  • usr/bin/

  • usr/local/bin/

  • some/other/random/folder/

  • another/long/path/

Is there any simple way to do this without first making copies or moving the original files before creating the image?







share|improve this question

























    up vote
    0
    down vote

    favorite












    When I create a squashfs image from multiple directories such as:



    • /bin/

    • /usr/bin/

    • /usr/local/bin/

    • /some/other/random/folder/

    • /another/long/path/

    If I use command...



    mksquashfs /bin /usr/bin /usr/local/bin /some/other/random/folder /another/long/path MyNewImage.squashfs


    It gives me an image with these top-level folders:



    • bin/

    • bin_1/

    • bin_2/

    • folder/

    • path/

    I want my image to contain the full paths from the original filesystem:



    • bin/

    • usr/bin/

    • usr/local/bin/

    • some/other/random/folder/

    • another/long/path/

    Is there any simple way to do this without first making copies or moving the original files before creating the image?







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      When I create a squashfs image from multiple directories such as:



      • /bin/

      • /usr/bin/

      • /usr/local/bin/

      • /some/other/random/folder/

      • /another/long/path/

      If I use command...



      mksquashfs /bin /usr/bin /usr/local/bin /some/other/random/folder /another/long/path MyNewImage.squashfs


      It gives me an image with these top-level folders:



      • bin/

      • bin_1/

      • bin_2/

      • folder/

      • path/

      I want my image to contain the full paths from the original filesystem:



      • bin/

      • usr/bin/

      • usr/local/bin/

      • some/other/random/folder/

      • another/long/path/

      Is there any simple way to do this without first making copies or moving the original files before creating the image?







      share|improve this question











      When I create a squashfs image from multiple directories such as:



      • /bin/

      • /usr/bin/

      • /usr/local/bin/

      • /some/other/random/folder/

      • /another/long/path/

      If I use command...



      mksquashfs /bin /usr/bin /usr/local/bin /some/other/random/folder /another/long/path MyNewImage.squashfs


      It gives me an image with these top-level folders:



      • bin/

      • bin_1/

      • bin_2/

      • folder/

      • path/

      I want my image to contain the full paths from the original filesystem:



      • bin/

      • usr/bin/

      • usr/local/bin/

      • some/other/random/folder/

      • another/long/path/

      Is there any simple way to do this without first making copies or moving the original files before creating the image?









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jul 30 at 8:32









      YeB

      17339




      17339




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          man mksquashfs:



           -keep-as-directory
          if one source directory is specified, create a root directory con‐
          taining that directory, rather than the contents of the directory.





          share|improve this answer





















          • Already tried that. It doesn't do it.
            – YeB
            Jul 30 at 12:29

















          up vote
          0
          down vote













          There probably is no simple way, but you can do it with a lot of effort by using the extended wildcard exclude syntax. This may not be documented in the man page but is mentioned more in the README. However, for details of the syntax you need to see the man page for fnmatch(3).



          Basically, you can use !(somedir) as an exclude to not exclude, so you end up only including that directory. Imagine you have the following example tree in /tmp



          $ mkdir -p a/b d/e d/e2
          $ touch a/b/c d/e/f d/e2/f2


          and you only want to copy a and d/e whilst preserving these full pathnames. You can use



          $ echo '!(a)' >exclude
          $ mksquashfs /tmp mysq -ef exclude -wildcards
          $ echo -e '!(d)/nd/!(e)' >exclude
          $ mksquashfs /tmp mysq -ef exclude -wildcards


          Listing the filesystem with unsquashfs -l mysq produces the output



          squashfs-root/a
          squashfs-root/a/b
          squashfs-root/a/b/c
          squashfs-root/d
          squashfs-root/d/e
          squashfs-root/d/e/f


          Each time, the source directory is /tmp, but the first time we exclude everything except directory a, and the second time we exclude everything except directory d and d/e. This uses a multi-level exclude file where on each line we exclude one more directory step in the path except the one that is to be retained.




          A simpler solution is to create the wanted hierarchy of directories somewhere, and mount -bind the final directory to the real directory.
          For example,



          $ mkdir -p a/usr/local/bin a/some/other/bin
          $ sudo mount -o bind /usr/local/bin a/usr/local/bin
          $ sudo mount -o bind /some/other/bin a/some/other/bin
          $ mksquashfs a ~/mysq
          $ sudo umount a/usr/local/bin a/some/other/bin





          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f459284%2fmksquashfs-how-to-include-full-absolute-directory-paths-inside-the-squashfs-ima%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            man mksquashfs:



             -keep-as-directory
            if one source directory is specified, create a root directory con‐
            taining that directory, rather than the contents of the directory.





            share|improve this answer





















            • Already tried that. It doesn't do it.
              – YeB
              Jul 30 at 12:29














            up vote
            0
            down vote













            man mksquashfs:



             -keep-as-directory
            if one source directory is specified, create a root directory con‐
            taining that directory, rather than the contents of the directory.





            share|improve this answer





















            • Already tried that. It doesn't do it.
              – YeB
              Jul 30 at 12:29












            up vote
            0
            down vote










            up vote
            0
            down vote









            man mksquashfs:



             -keep-as-directory
            if one source directory is specified, create a root directory con‐
            taining that directory, rather than the contents of the directory.





            share|improve this answer













            man mksquashfs:



             -keep-as-directory
            if one source directory is specified, create a root directory con‐
            taining that directory, rather than the contents of the directory.






            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Jul 30 at 8:39









            Ipor Sircer

            8,6271920




            8,6271920











            • Already tried that. It doesn't do it.
              – YeB
              Jul 30 at 12:29
















            • Already tried that. It doesn't do it.
              – YeB
              Jul 30 at 12:29















            Already tried that. It doesn't do it.
            – YeB
            Jul 30 at 12:29




            Already tried that. It doesn't do it.
            – YeB
            Jul 30 at 12:29












            up vote
            0
            down vote













            There probably is no simple way, but you can do it with a lot of effort by using the extended wildcard exclude syntax. This may not be documented in the man page but is mentioned more in the README. However, for details of the syntax you need to see the man page for fnmatch(3).



            Basically, you can use !(somedir) as an exclude to not exclude, so you end up only including that directory. Imagine you have the following example tree in /tmp



            $ mkdir -p a/b d/e d/e2
            $ touch a/b/c d/e/f d/e2/f2


            and you only want to copy a and d/e whilst preserving these full pathnames. You can use



            $ echo '!(a)' >exclude
            $ mksquashfs /tmp mysq -ef exclude -wildcards
            $ echo -e '!(d)/nd/!(e)' >exclude
            $ mksquashfs /tmp mysq -ef exclude -wildcards


            Listing the filesystem with unsquashfs -l mysq produces the output



            squashfs-root/a
            squashfs-root/a/b
            squashfs-root/a/b/c
            squashfs-root/d
            squashfs-root/d/e
            squashfs-root/d/e/f


            Each time, the source directory is /tmp, but the first time we exclude everything except directory a, and the second time we exclude everything except directory d and d/e. This uses a multi-level exclude file where on each line we exclude one more directory step in the path except the one that is to be retained.




            A simpler solution is to create the wanted hierarchy of directories somewhere, and mount -bind the final directory to the real directory.
            For example,



            $ mkdir -p a/usr/local/bin a/some/other/bin
            $ sudo mount -o bind /usr/local/bin a/usr/local/bin
            $ sudo mount -o bind /some/other/bin a/some/other/bin
            $ mksquashfs a ~/mysq
            $ sudo umount a/usr/local/bin a/some/other/bin





            share|improve this answer



























              up vote
              0
              down vote













              There probably is no simple way, but you can do it with a lot of effort by using the extended wildcard exclude syntax. This may not be documented in the man page but is mentioned more in the README. However, for details of the syntax you need to see the man page for fnmatch(3).



              Basically, you can use !(somedir) as an exclude to not exclude, so you end up only including that directory. Imagine you have the following example tree in /tmp



              $ mkdir -p a/b d/e d/e2
              $ touch a/b/c d/e/f d/e2/f2


              and you only want to copy a and d/e whilst preserving these full pathnames. You can use



              $ echo '!(a)' >exclude
              $ mksquashfs /tmp mysq -ef exclude -wildcards
              $ echo -e '!(d)/nd/!(e)' >exclude
              $ mksquashfs /tmp mysq -ef exclude -wildcards


              Listing the filesystem with unsquashfs -l mysq produces the output



              squashfs-root/a
              squashfs-root/a/b
              squashfs-root/a/b/c
              squashfs-root/d
              squashfs-root/d/e
              squashfs-root/d/e/f


              Each time, the source directory is /tmp, but the first time we exclude everything except directory a, and the second time we exclude everything except directory d and d/e. This uses a multi-level exclude file where on each line we exclude one more directory step in the path except the one that is to be retained.




              A simpler solution is to create the wanted hierarchy of directories somewhere, and mount -bind the final directory to the real directory.
              For example,



              $ mkdir -p a/usr/local/bin a/some/other/bin
              $ sudo mount -o bind /usr/local/bin a/usr/local/bin
              $ sudo mount -o bind /some/other/bin a/some/other/bin
              $ mksquashfs a ~/mysq
              $ sudo umount a/usr/local/bin a/some/other/bin





              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                There probably is no simple way, but you can do it with a lot of effort by using the extended wildcard exclude syntax. This may not be documented in the man page but is mentioned more in the README. However, for details of the syntax you need to see the man page for fnmatch(3).



                Basically, you can use !(somedir) as an exclude to not exclude, so you end up only including that directory. Imagine you have the following example tree in /tmp



                $ mkdir -p a/b d/e d/e2
                $ touch a/b/c d/e/f d/e2/f2


                and you only want to copy a and d/e whilst preserving these full pathnames. You can use



                $ echo '!(a)' >exclude
                $ mksquashfs /tmp mysq -ef exclude -wildcards
                $ echo -e '!(d)/nd/!(e)' >exclude
                $ mksquashfs /tmp mysq -ef exclude -wildcards


                Listing the filesystem with unsquashfs -l mysq produces the output



                squashfs-root/a
                squashfs-root/a/b
                squashfs-root/a/b/c
                squashfs-root/d
                squashfs-root/d/e
                squashfs-root/d/e/f


                Each time, the source directory is /tmp, but the first time we exclude everything except directory a, and the second time we exclude everything except directory d and d/e. This uses a multi-level exclude file where on each line we exclude one more directory step in the path except the one that is to be retained.




                A simpler solution is to create the wanted hierarchy of directories somewhere, and mount -bind the final directory to the real directory.
                For example,



                $ mkdir -p a/usr/local/bin a/some/other/bin
                $ sudo mount -o bind /usr/local/bin a/usr/local/bin
                $ sudo mount -o bind /some/other/bin a/some/other/bin
                $ mksquashfs a ~/mysq
                $ sudo umount a/usr/local/bin a/some/other/bin





                share|improve this answer















                There probably is no simple way, but you can do it with a lot of effort by using the extended wildcard exclude syntax. This may not be documented in the man page but is mentioned more in the README. However, for details of the syntax you need to see the man page for fnmatch(3).



                Basically, you can use !(somedir) as an exclude to not exclude, so you end up only including that directory. Imagine you have the following example tree in /tmp



                $ mkdir -p a/b d/e d/e2
                $ touch a/b/c d/e/f d/e2/f2


                and you only want to copy a and d/e whilst preserving these full pathnames. You can use



                $ echo '!(a)' >exclude
                $ mksquashfs /tmp mysq -ef exclude -wildcards
                $ echo -e '!(d)/nd/!(e)' >exclude
                $ mksquashfs /tmp mysq -ef exclude -wildcards


                Listing the filesystem with unsquashfs -l mysq produces the output



                squashfs-root/a
                squashfs-root/a/b
                squashfs-root/a/b/c
                squashfs-root/d
                squashfs-root/d/e
                squashfs-root/d/e/f


                Each time, the source directory is /tmp, but the first time we exclude everything except directory a, and the second time we exclude everything except directory d and d/e. This uses a multi-level exclude file where on each line we exclude one more directory step in the path except the one that is to be retained.




                A simpler solution is to create the wanted hierarchy of directories somewhere, and mount -bind the final directory to the real directory.
                For example,



                $ mkdir -p a/usr/local/bin a/some/other/bin
                $ sudo mount -o bind /usr/local/bin a/usr/local/bin
                $ sudo mount -o bind /some/other/bin a/some/other/bin
                $ mksquashfs a ~/mysq
                $ sudo umount a/usr/local/bin a/some/other/bin






                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jul 30 at 14:33


























                answered Jul 30 at 14:07









                meuh

                29k11648




                29k11648






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459284%2fmksquashfs-how-to-include-full-absolute-directory-paths-inside-the-squashfs-ima%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)