Free space in unmounted partition

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











up vote
3
down vote

favorite












Can I find free space of unmounted partition using system files like sys or proc?



I know how to find total space but have no idea about free space. Please suggest using system files only. For total space of unmounted partition I am using /proc/partitions file.










share|improve this question























  • bro it gives total space of the partition.
    – Sarthak_Bhutani
    Oct 6 '17 at 4:55














up vote
3
down vote

favorite












Can I find free space of unmounted partition using system files like sys or proc?



I know how to find total space but have no idea about free space. Please suggest using system files only. For total space of unmounted partition I am using /proc/partitions file.










share|improve this question























  • bro it gives total space of the partition.
    – Sarthak_Bhutani
    Oct 6 '17 at 4:55












up vote
3
down vote

favorite









up vote
3
down vote

favorite











Can I find free space of unmounted partition using system files like sys or proc?



I know how to find total space but have no idea about free space. Please suggest using system files only. For total space of unmounted partition I am using /proc/partitions file.










share|improve this question















Can I find free space of unmounted partition using system files like sys or proc?



I know how to find total space but have no idea about free space. Please suggest using system files only. For total space of unmounted partition I am using /proc/partitions file.







linux disk-usage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 3 '17 at 9:23









Vlastimil

6,4761148121




6,4761148121










asked Oct 3 '17 at 3:23









Sarthak_Bhutani

784




784











  • bro it gives total space of the partition.
    – Sarthak_Bhutani
    Oct 6 '17 at 4:55
















  • bro it gives total space of the partition.
    – Sarthak_Bhutani
    Oct 6 '17 at 4:55















bro it gives total space of the partition.
– Sarthak_Bhutani
Oct 6 '17 at 4:55




bro it gives total space of the partition.
– Sarthak_Bhutani
Oct 6 '17 at 4:55










3 Answers
3






active

oldest

votes

















up vote
4
down vote













This is dependent on the filesystem type, but you could try to use fsck to find out how much free space there is left. Finding the free space requires a tool that understands the structure of the filesystem, and there usually aren't many of those in addition to fsck.






share|improve this answer



























    up vote
    1
    down vote













    procfs should be used specifically for process related info. (as it is not stictly followed but still to be on safer side don't depend on it as there is chance of it getting deprecated).



    so sysfs will give us system info.
    this will give info of full disk size.



    cat /sys/block/sda/size


    replace sda with your partition name.



    ls /sys/block/sda/


    will give info about partitions available check for directory naming sda1, sda2 ...



    same thing as sda can be used to check size of these partitions.



    cat /sys/block/sda/sda1/size


    Same note as above watch partition names. change sda to sdb,sdc, etc according to your requirement.



    Hope this answers your question.






    share|improve this answer




















    • without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
      – Devidas
      Oct 3 '17 at 6:29










    • It shows the number of all blocks on the partition, not the free ones.
      – peterh
      Oct 4 '17 at 2:27










    • Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
      – Devidas
      Oct 4 '17 at 6:56

















    up vote
    0
    down vote













    There is no general way for that, but there is a way which works in most cases.



    The reason, why there is no general way for that, that also the kernel doesn't know it. To know it, first it would need to analyze the partition.



    Without mounting the partition, the kernel knows only its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows, where is it and how to access, but doesn't know, what to do with it.



    However, there are also user-space tools which can analyze the content of a filesystem, without mounting them. As all the filesystems have very different data structures, to handle them you need different tools.



    In the case of ext2/3/4, it is



    # dumpe2fs /dev/your_root|grep '^Free blocks'
    dumpe2fs 1.42.13 (17-May-2015)
    Free blocks: 5721580





    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%2f395745%2ffree-space-in-unmounted-partition%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote













      This is dependent on the filesystem type, but you could try to use fsck to find out how much free space there is left. Finding the free space requires a tool that understands the structure of the filesystem, and there usually aren't many of those in addition to fsck.






      share|improve this answer
























        up vote
        4
        down vote













        This is dependent on the filesystem type, but you could try to use fsck to find out how much free space there is left. Finding the free space requires a tool that understands the structure of the filesystem, and there usually aren't many of those in addition to fsck.






        share|improve this answer






















          up vote
          4
          down vote










          up vote
          4
          down vote









          This is dependent on the filesystem type, but you could try to use fsck to find out how much free space there is left. Finding the free space requires a tool that understands the structure of the filesystem, and there usually aren't many of those in addition to fsck.






          share|improve this answer












          This is dependent on the filesystem type, but you could try to use fsck to find out how much free space there is left. Finding the free space requires a tool that understands the structure of the filesystem, and there usually aren't many of those in addition to fsck.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 3 '17 at 9:09









          Johan Myréen

          6,94711423




          6,94711423






















              up vote
              1
              down vote













              procfs should be used specifically for process related info. (as it is not stictly followed but still to be on safer side don't depend on it as there is chance of it getting deprecated).



              so sysfs will give us system info.
              this will give info of full disk size.



              cat /sys/block/sda/size


              replace sda with your partition name.



              ls /sys/block/sda/


              will give info about partitions available check for directory naming sda1, sda2 ...



              same thing as sda can be used to check size of these partitions.



              cat /sys/block/sda/sda1/size


              Same note as above watch partition names. change sda to sdb,sdc, etc according to your requirement.



              Hope this answers your question.






              share|improve this answer




















              • without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
                – Devidas
                Oct 3 '17 at 6:29










              • It shows the number of all blocks on the partition, not the free ones.
                – peterh
                Oct 4 '17 at 2:27










              • Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
                – Devidas
                Oct 4 '17 at 6:56














              up vote
              1
              down vote













              procfs should be used specifically for process related info. (as it is not stictly followed but still to be on safer side don't depend on it as there is chance of it getting deprecated).



              so sysfs will give us system info.
              this will give info of full disk size.



              cat /sys/block/sda/size


              replace sda with your partition name.



              ls /sys/block/sda/


              will give info about partitions available check for directory naming sda1, sda2 ...



              same thing as sda can be used to check size of these partitions.



              cat /sys/block/sda/sda1/size


              Same note as above watch partition names. change sda to sdb,sdc, etc according to your requirement.



              Hope this answers your question.






              share|improve this answer




















              • without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
                – Devidas
                Oct 3 '17 at 6:29










              • It shows the number of all blocks on the partition, not the free ones.
                – peterh
                Oct 4 '17 at 2:27










              • Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
                – Devidas
                Oct 4 '17 at 6:56












              up vote
              1
              down vote










              up vote
              1
              down vote









              procfs should be used specifically for process related info. (as it is not stictly followed but still to be on safer side don't depend on it as there is chance of it getting deprecated).



              so sysfs will give us system info.
              this will give info of full disk size.



              cat /sys/block/sda/size


              replace sda with your partition name.



              ls /sys/block/sda/


              will give info about partitions available check for directory naming sda1, sda2 ...



              same thing as sda can be used to check size of these partitions.



              cat /sys/block/sda/sda1/size


              Same note as above watch partition names. change sda to sdb,sdc, etc according to your requirement.



              Hope this answers your question.






              share|improve this answer












              procfs should be used specifically for process related info. (as it is not stictly followed but still to be on safer side don't depend on it as there is chance of it getting deprecated).



              so sysfs will give us system info.
              this will give info of full disk size.



              cat /sys/block/sda/size


              replace sda with your partition name.



              ls /sys/block/sda/


              will give info about partitions available check for directory naming sda1, sda2 ...



              same thing as sda can be used to check size of these partitions.



              cat /sys/block/sda/sda1/size


              Same note as above watch partition names. change sda to sdb,sdc, etc according to your requirement.



              Hope this answers your question.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Oct 3 '17 at 6:21









              Devidas

              1896




              1896











              • without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
                – Devidas
                Oct 3 '17 at 6:29










              • It shows the number of all blocks on the partition, not the free ones.
                – peterh
                Oct 4 '17 at 2:27










              • Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
                – Devidas
                Oct 4 '17 at 6:56
















              • without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
                – Devidas
                Oct 3 '17 at 6:29










              • It shows the number of all blocks on the partition, not the free ones.
                – peterh
                Oct 4 '17 at 2:27










              • Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
                – Devidas
                Oct 4 '17 at 6:56















              without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
              – Devidas
              Oct 3 '17 at 6:29




              without mounting the partition I doubt we will be able to read free blocks. there is draw back doing so because this info will be written multiple time to update which may be harmful for disk life. so after disk is mounted and scanned this info is available to you.
              – Devidas
              Oct 3 '17 at 6:29












              It shows the number of all blocks on the partition, not the free ones.
              – peterh
              Oct 4 '17 at 2:27




              It shows the number of all blocks on the partition, not the free ones.
              – peterh
              Oct 4 '17 at 2:27












              Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
              – Devidas
              Oct 4 '17 at 6:56




              Yeah you are right peterh. So I have added comment above stating "without mounting the partition I doubt we will be able to read free blocks". I meant in sysfs or procfs. there are other utilities as stated, but he asked for procfs or sysfs so I mentioned it. what I meant while answering was there is a place where info about all partition is stored in kernel but free scpace is not one of them.
              – Devidas
              Oct 4 '17 at 6:56










              up vote
              0
              down vote













              There is no general way for that, but there is a way which works in most cases.



              The reason, why there is no general way for that, that also the kernel doesn't know it. To know it, first it would need to analyze the partition.



              Without mounting the partition, the kernel knows only its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows, where is it and how to access, but doesn't know, what to do with it.



              However, there are also user-space tools which can analyze the content of a filesystem, without mounting them. As all the filesystems have very different data structures, to handle them you need different tools.



              In the case of ext2/3/4, it is



              # dumpe2fs /dev/your_root|grep '^Free blocks'
              dumpe2fs 1.42.13 (17-May-2015)
              Free blocks: 5721580





              share|improve this answer
























                up vote
                0
                down vote













                There is no general way for that, but there is a way which works in most cases.



                The reason, why there is no general way for that, that also the kernel doesn't know it. To know it, first it would need to analyze the partition.



                Without mounting the partition, the kernel knows only its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows, where is it and how to access, but doesn't know, what to do with it.



                However, there are also user-space tools which can analyze the content of a filesystem, without mounting them. As all the filesystems have very different data structures, to handle them you need different tools.



                In the case of ext2/3/4, it is



                # dumpe2fs /dev/your_root|grep '^Free blocks'
                dumpe2fs 1.42.13 (17-May-2015)
                Free blocks: 5721580





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  There is no general way for that, but there is a way which works in most cases.



                  The reason, why there is no general way for that, that also the kernel doesn't know it. To know it, first it would need to analyze the partition.



                  Without mounting the partition, the kernel knows only its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows, where is it and how to access, but doesn't know, what to do with it.



                  However, there are also user-space tools which can analyze the content of a filesystem, without mounting them. As all the filesystems have very different data structures, to handle them you need different tools.



                  In the case of ext2/3/4, it is



                  # dumpe2fs /dev/your_root|grep '^Free blocks'
                  dumpe2fs 1.42.13 (17-May-2015)
                  Free blocks: 5721580





                  share|improve this answer












                  There is no general way for that, but there is a way which works in most cases.



                  The reason, why there is no general way for that, that also the kernel doesn't know it. To know it, first it would need to analyze the partition.



                  Without mounting the partition, the kernel knows only its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows, where is it and how to access, but doesn't know, what to do with it.



                  However, there are also user-space tools which can analyze the content of a filesystem, without mounting them. As all the filesystems have very different data structures, to handle them you need different tools.



                  In the case of ext2/3/4, it is



                  # dumpe2fs /dev/your_root|grep '^Free blocks'
                  dumpe2fs 1.42.13 (17-May-2015)
                  Free blocks: 5721580






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 4 '17 at 2:35









                  peterh

                  3,97792755




                  3,97792755



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395745%2ffree-space-in-unmounted-partition%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      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?