How to resize logical volume to fit filesystem

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












1















How can I resize logical volume to fit filesystem automagically?










share|improve this question


























    1















    How can I resize logical volume to fit filesystem automagically?










    share|improve this question
























      1












      1








      1








      How can I resize logical volume to fit filesystem automagically?










      share|improve this question














      How can I resize logical volume to fit filesystem automagically?







      partition hard-disk lvm fdisk volume






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 '12 at 14:44









      Zim3rZim3r

      15018




      15018




















          2 Answers
          2






          active

          oldest

          votes


















          3














          To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.



          A shorthand way of expanding a logical volume and the filesystem is contains can be achieved using lvextend with the --resizefs option. For example, assume that you have a logical volume of 1000 extents that you want to grow to 1600 and then expand the filesystem within; do:



          lvextend -l 1600 --resizefs /dev/vg01/lvol1


          This increases the logical volume size to a total of 1600 extents and then grows the filesystem associated with it. There is no need to unmount the filesystem to perform this operation.



          In order to shrink the size of a filesystem, you must first unmount it and fsck it. Then, reduce the size of the filesystem first, followed by shrinking the size of the surrounding logical volume container. Use tune2fs to ascertain the "Block size" of the filesystem. Multiply the block size value by the number of physical extents you want the final logical volume to contain, and use that product as the argument to resize2fs. For example if the block size is 4096 and the final number of physical extents you want in your logical volume is 1200, then the product is 4915200 (blocks). Hence:



          umount /myfs
          e2fsck -f /dev/vg01/lvol1
          resize2fs /dev/vg001/lvol1 4915200
          lvreduce -l 1200 /dev/vg01/lvol1
          [ respond "y" when asked if you really want to reduce it ]





          share|improve this answer
































            2














            JRFerguson provided a great answer. I think the OP was looking for something like this:



            lvextend -l+100%FREE /dev/path/to/your/logical/volume


            It's convenient to be able to refer to the available space in relative terms than calculating the number of blocks by hand. For more information, you can check out the man page for lvextend or any of the other lvm2 commands.






            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%2f55368%2fhow-to-resize-logical-volume-to-fit-filesystem%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









              3














              To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.



              A shorthand way of expanding a logical volume and the filesystem is contains can be achieved using lvextend with the --resizefs option. For example, assume that you have a logical volume of 1000 extents that you want to grow to 1600 and then expand the filesystem within; do:



              lvextend -l 1600 --resizefs /dev/vg01/lvol1


              This increases the logical volume size to a total of 1600 extents and then grows the filesystem associated with it. There is no need to unmount the filesystem to perform this operation.



              In order to shrink the size of a filesystem, you must first unmount it and fsck it. Then, reduce the size of the filesystem first, followed by shrinking the size of the surrounding logical volume container. Use tune2fs to ascertain the "Block size" of the filesystem. Multiply the block size value by the number of physical extents you want the final logical volume to contain, and use that product as the argument to resize2fs. For example if the block size is 4096 and the final number of physical extents you want in your logical volume is 1200, then the product is 4915200 (blocks). Hence:



              umount /myfs
              e2fsck -f /dev/vg01/lvol1
              resize2fs /dev/vg001/lvol1 4915200
              lvreduce -l 1200 /dev/vg01/lvol1
              [ respond "y" when asked if you really want to reduce it ]





              share|improve this answer





























                3














                To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.



                A shorthand way of expanding a logical volume and the filesystem is contains can be achieved using lvextend with the --resizefs option. For example, assume that you have a logical volume of 1000 extents that you want to grow to 1600 and then expand the filesystem within; do:



                lvextend -l 1600 --resizefs /dev/vg01/lvol1


                This increases the logical volume size to a total of 1600 extents and then grows the filesystem associated with it. There is no need to unmount the filesystem to perform this operation.



                In order to shrink the size of a filesystem, you must first unmount it and fsck it. Then, reduce the size of the filesystem first, followed by shrinking the size of the surrounding logical volume container. Use tune2fs to ascertain the "Block size" of the filesystem. Multiply the block size value by the number of physical extents you want the final logical volume to contain, and use that product as the argument to resize2fs. For example if the block size is 4096 and the final number of physical extents you want in your logical volume is 1200, then the product is 4915200 (blocks). Hence:



                umount /myfs
                e2fsck -f /dev/vg01/lvol1
                resize2fs /dev/vg001/lvol1 4915200
                lvreduce -l 1200 /dev/vg01/lvol1
                [ respond "y" when asked if you really want to reduce it ]





                share|improve this answer



























                  3












                  3








                  3







                  To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.



                  A shorthand way of expanding a logical volume and the filesystem is contains can be achieved using lvextend with the --resizefs option. For example, assume that you have a logical volume of 1000 extents that you want to grow to 1600 and then expand the filesystem within; do:



                  lvextend -l 1600 --resizefs /dev/vg01/lvol1


                  This increases the logical volume size to a total of 1600 extents and then grows the filesystem associated with it. There is no need to unmount the filesystem to perform this operation.



                  In order to shrink the size of a filesystem, you must first unmount it and fsck it. Then, reduce the size of the filesystem first, followed by shrinking the size of the surrounding logical volume container. Use tune2fs to ascertain the "Block size" of the filesystem. Multiply the block size value by the number of physical extents you want the final logical volume to contain, and use that product as the argument to resize2fs. For example if the block size is 4096 and the final number of physical extents you want in your logical volume is 1200, then the product is 4915200 (blocks). Hence:



                  umount /myfs
                  e2fsck -f /dev/vg01/lvol1
                  resize2fs /dev/vg001/lvol1 4915200
                  lvreduce -l 1200 /dev/vg01/lvol1
                  [ respond "y" when asked if you really want to reduce it ]





                  share|improve this answer















                  To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.



                  A shorthand way of expanding a logical volume and the filesystem is contains can be achieved using lvextend with the --resizefs option. For example, assume that you have a logical volume of 1000 extents that you want to grow to 1600 and then expand the filesystem within; do:



                  lvextend -l 1600 --resizefs /dev/vg01/lvol1


                  This increases the logical volume size to a total of 1600 extents and then grows the filesystem associated with it. There is no need to unmount the filesystem to perform this operation.



                  In order to shrink the size of a filesystem, you must first unmount it and fsck it. Then, reduce the size of the filesystem first, followed by shrinking the size of the surrounding logical volume container. Use tune2fs to ascertain the "Block size" of the filesystem. Multiply the block size value by the number of physical extents you want the final logical volume to contain, and use that product as the argument to resize2fs. For example if the block size is 4096 and the final number of physical extents you want in your logical volume is 1200, then the product is 4915200 (blocks). Hence:



                  umount /myfs
                  e2fsck -f /dev/vg01/lvol1
                  resize2fs /dev/vg001/lvol1 4915200
                  lvreduce -l 1200 /dev/vg01/lvol1
                  [ respond "y" when asked if you really want to reduce it ]






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 18 at 15:46









                  Jeff Schaller

                  43.4k1160140




                  43.4k1160140










                  answered Nov 10 '12 at 15:19









                  JRFergusonJRFerguson

                  10.2k32432




                  10.2k32432























                      2














                      JRFerguson provided a great answer. I think the OP was looking for something like this:



                      lvextend -l+100%FREE /dev/path/to/your/logical/volume


                      It's convenient to be able to refer to the available space in relative terms than calculating the number of blocks by hand. For more information, you can check out the man page for lvextend or any of the other lvm2 commands.






                      share|improve this answer



























                        2














                        JRFerguson provided a great answer. I think the OP was looking for something like this:



                        lvextend -l+100%FREE /dev/path/to/your/logical/volume


                        It's convenient to be able to refer to the available space in relative terms than calculating the number of blocks by hand. For more information, you can check out the man page for lvextend or any of the other lvm2 commands.






                        share|improve this answer

























                          2












                          2








                          2







                          JRFerguson provided a great answer. I think the OP was looking for something like this:



                          lvextend -l+100%FREE /dev/path/to/your/logical/volume


                          It's convenient to be able to refer to the available space in relative terms than calculating the number of blocks by hand. For more information, you can check out the man page for lvextend or any of the other lvm2 commands.






                          share|improve this answer













                          JRFerguson provided a great answer. I think the OP was looking for something like this:



                          lvextend -l+100%FREE /dev/path/to/your/logical/volume


                          It's convenient to be able to refer to the available space in relative terms than calculating the number of blocks by hand. For more information, you can check out the man page for lvextend or any of the other lvm2 commands.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 19 '13 at 14:19









                          gkb0986gkb0986

                          1,656296




                          1,656296



























                              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%2f55368%2fhow-to-resize-logical-volume-to-fit-filesystem%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?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?