How to find the size of a filesystem?












6















How can I find out the size of a filesystem in Linux? By that I mean the exact number of bytes that are used from the partition, not just the output of df, as that can differ from the true size when compression or deduplication is used on the filesystem.



The size of the partition itself can be printed with:



$ lsblk -b


or



$ blockdev --getsize64 /dev/sda


I am looking for something similar for the filesystem.



PS: This is for LVM grow/shrink stuff. I am mostly interested in ext2/3/4 and btrfs, but any other filesystem info is appreciated as well.










share|improve this question























  • I think you mean "partition" or "HD" with "filesystem".

    – Eduardo Cola
    May 11 '15 at 21:31






  • 2





    No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

    – Grumbel
    May 11 '15 at 23:31
















6















How can I find out the size of a filesystem in Linux? By that I mean the exact number of bytes that are used from the partition, not just the output of df, as that can differ from the true size when compression or deduplication is used on the filesystem.



The size of the partition itself can be printed with:



$ lsblk -b


or



$ blockdev --getsize64 /dev/sda


I am looking for something similar for the filesystem.



PS: This is for LVM grow/shrink stuff. I am mostly interested in ext2/3/4 and btrfs, but any other filesystem info is appreciated as well.










share|improve this question























  • I think you mean "partition" or "HD" with "filesystem".

    – Eduardo Cola
    May 11 '15 at 21:31






  • 2





    No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

    – Grumbel
    May 11 '15 at 23:31














6












6








6


2






How can I find out the size of a filesystem in Linux? By that I mean the exact number of bytes that are used from the partition, not just the output of df, as that can differ from the true size when compression or deduplication is used on the filesystem.



The size of the partition itself can be printed with:



$ lsblk -b


or



$ blockdev --getsize64 /dev/sda


I am looking for something similar for the filesystem.



PS: This is for LVM grow/shrink stuff. I am mostly interested in ext2/3/4 and btrfs, but any other filesystem info is appreciated as well.










share|improve this question














How can I find out the size of a filesystem in Linux? By that I mean the exact number of bytes that are used from the partition, not just the output of df, as that can differ from the true size when compression or deduplication is used on the filesystem.



The size of the partition itself can be printed with:



$ lsblk -b


or



$ blockdev --getsize64 /dev/sda


I am looking for something similar for the filesystem.



PS: This is for LVM grow/shrink stuff. I am mostly interested in ext2/3/4 and btrfs, but any other filesystem info is appreciated as well.







partitioning filesystem lvm btrfs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 11 '15 at 20:58









GrumbelGrumbel

2,73432540




2,73432540













  • I think you mean "partition" or "HD" with "filesystem".

    – Eduardo Cola
    May 11 '15 at 21:31






  • 2





    No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

    – Grumbel
    May 11 '15 at 23:31



















  • I think you mean "partition" or "HD" with "filesystem".

    – Eduardo Cola
    May 11 '15 at 21:31






  • 2





    No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

    – Grumbel
    May 11 '15 at 23:31

















I think you mean "partition" or "HD" with "filesystem".

– Eduardo Cola
May 11 '15 at 21:31





I think you mean "partition" or "HD" with "filesystem".

– Eduardo Cola
May 11 '15 at 21:31




2




2





No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

– Grumbel
May 11 '15 at 23:31





No, I mean "filesystem". A filesystem size can be different from the partition it is on, this is common when you grow or shrink partitions.

– Grumbel
May 11 '15 at 23:31










3 Answers
3






active

oldest

votes


















8














If you want filesystem information and not partition/volume information, I think you'll have to use filesystem-specific tools.



In the case of the extN systems, that would be dumpe2fs. And dumpe2fs doesn't directly print the size in bytes, as far as I can tell. It does, however, print the block count and the size of blocks, so you can parse the output instead:



$ dumpe2fs -h /dev/sda1 |& awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size}'           
29999980544


In my case, this size is slightly different from the partition size:



$ parted /dev/sda u b p
Model: ATA ST500LT012-1DG14 (scsi)
Disk /dev/sda: 500107862016B
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 17408B 30000000511B 29999983104B ext4 boot, esp
2 30000807936B 453049843711B 423049035776B ext4
5 453049843712B 495999516671B 42949672960B ext4
3 495999516672B 500102862847B 4103346176B linux-swap(v1)
4 500102862848B 500107845119B 4982272B bios_grub


The partition size is 29999983104 bytes, 2560 bytes more than a multiple of the block size, which is why the size reported by dumpe2fs is less.






share|improve this answer
























  • What about other file systems than extNfs, like iso9660?

    – Jarl
    Jan 5 at 13:02



















2














For btrfs, you can use:



sudo btrfs filesystem usage -b /mountpoint





share|improve this answer































    1














    It depends on the filesystem you want to investigate:



    ext2, ext3, ext4 file system




    dumpe2fs -h /dev/sda1 | grep '^Block'


    You have to multiply block count and block size to get number of bytes.



    ISO-9660 file system




    isoinfo -d -i ubuntu-18.10-desktop-amd64.iso | grep -A1 '^Logical block size'


    The unit for volume size is logical blocks, so you have to multiply volume size and logical block size to get number of bytes.



    BTRFS file system



    As one btrfs can include several devices, the command takes the mountpoint as argument




    btrfs filesystem usage -b /mnt/mountpoint | grep 'Device size'





    share|improve this answer

























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      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: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2faskubuntu.com%2fquestions%2f622489%2fhow-to-find-the-size-of-a-filesystem%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      8














      If you want filesystem information and not partition/volume information, I think you'll have to use filesystem-specific tools.



      In the case of the extN systems, that would be dumpe2fs. And dumpe2fs doesn't directly print the size in bytes, as far as I can tell. It does, however, print the block count and the size of blocks, so you can parse the output instead:



      $ dumpe2fs -h /dev/sda1 |& awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size}'           
      29999980544


      In my case, this size is slightly different from the partition size:



      $ parted /dev/sda u b p
      Model: ATA ST500LT012-1DG14 (scsi)
      Disk /dev/sda: 500107862016B
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 17408B 30000000511B 29999983104B ext4 boot, esp
      2 30000807936B 453049843711B 423049035776B ext4
      5 453049843712B 495999516671B 42949672960B ext4
      3 495999516672B 500102862847B 4103346176B linux-swap(v1)
      4 500102862848B 500107845119B 4982272B bios_grub


      The partition size is 29999983104 bytes, 2560 bytes more than a multiple of the block size, which is why the size reported by dumpe2fs is less.






      share|improve this answer
























      • What about other file systems than extNfs, like iso9660?

        – Jarl
        Jan 5 at 13:02
















      8














      If you want filesystem information and not partition/volume information, I think you'll have to use filesystem-specific tools.



      In the case of the extN systems, that would be dumpe2fs. And dumpe2fs doesn't directly print the size in bytes, as far as I can tell. It does, however, print the block count and the size of blocks, so you can parse the output instead:



      $ dumpe2fs -h /dev/sda1 |& awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size}'           
      29999980544


      In my case, this size is slightly different from the partition size:



      $ parted /dev/sda u b p
      Model: ATA ST500LT012-1DG14 (scsi)
      Disk /dev/sda: 500107862016B
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 17408B 30000000511B 29999983104B ext4 boot, esp
      2 30000807936B 453049843711B 423049035776B ext4
      5 453049843712B 495999516671B 42949672960B ext4
      3 495999516672B 500102862847B 4103346176B linux-swap(v1)
      4 500102862848B 500107845119B 4982272B bios_grub


      The partition size is 29999983104 bytes, 2560 bytes more than a multiple of the block size, which is why the size reported by dumpe2fs is less.






      share|improve this answer
























      • What about other file systems than extNfs, like iso9660?

        – Jarl
        Jan 5 at 13:02














      8












      8








      8







      If you want filesystem information and not partition/volume information, I think you'll have to use filesystem-specific tools.



      In the case of the extN systems, that would be dumpe2fs. And dumpe2fs doesn't directly print the size in bytes, as far as I can tell. It does, however, print the block count and the size of blocks, so you can parse the output instead:



      $ dumpe2fs -h /dev/sda1 |& awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size}'           
      29999980544


      In my case, this size is slightly different from the partition size:



      $ parted /dev/sda u b p
      Model: ATA ST500LT012-1DG14 (scsi)
      Disk /dev/sda: 500107862016B
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 17408B 30000000511B 29999983104B ext4 boot, esp
      2 30000807936B 453049843711B 423049035776B ext4
      5 453049843712B 495999516671B 42949672960B ext4
      3 495999516672B 500102862847B 4103346176B linux-swap(v1)
      4 500102862848B 500107845119B 4982272B bios_grub


      The partition size is 29999983104 bytes, 2560 bytes more than a multiple of the block size, which is why the size reported by dumpe2fs is less.






      share|improve this answer













      If you want filesystem information and not partition/volume information, I think you'll have to use filesystem-specific tools.



      In the case of the extN systems, that would be dumpe2fs. And dumpe2fs doesn't directly print the size in bytes, as far as I can tell. It does, however, print the block count and the size of blocks, so you can parse the output instead:



      $ dumpe2fs -h /dev/sda1 |& awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size}'           
      29999980544


      In my case, this size is slightly different from the partition size:



      $ parted /dev/sda u b p
      Model: ATA ST500LT012-1DG14 (scsi)
      Disk /dev/sda: 500107862016B
      Sector size (logical/physical): 512B/4096B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 17408B 30000000511B 29999983104B ext4 boot, esp
      2 30000807936B 453049843711B 423049035776B ext4
      5 453049843712B 495999516671B 42949672960B ext4
      3 495999516672B 500102862847B 4103346176B linux-swap(v1)
      4 500102862848B 500107845119B 4982272B bios_grub


      The partition size is 29999983104 bytes, 2560 bytes more than a multiple of the block size, which is why the size reported by dumpe2fs is less.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered May 11 '15 at 22:40









      murumuru

      1




      1













      • What about other file systems than extNfs, like iso9660?

        – Jarl
        Jan 5 at 13:02



















      • What about other file systems than extNfs, like iso9660?

        – Jarl
        Jan 5 at 13:02

















      What about other file systems than extNfs, like iso9660?

      – Jarl
      Jan 5 at 13:02





      What about other file systems than extNfs, like iso9660?

      – Jarl
      Jan 5 at 13:02













      2














      For btrfs, you can use:



      sudo btrfs filesystem usage -b /mountpoint





      share|improve this answer




























        2














        For btrfs, you can use:



        sudo btrfs filesystem usage -b /mountpoint





        share|improve this answer


























          2












          2








          2







          For btrfs, you can use:



          sudo btrfs filesystem usage -b /mountpoint





          share|improve this answer













          For btrfs, you can use:



          sudo btrfs filesystem usage -b /mountpoint






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 17 '18 at 16:14









          Tom HaleTom Hale

          1,46421027




          1,46421027























              1














              It depends on the filesystem you want to investigate:



              ext2, ext3, ext4 file system




              dumpe2fs -h /dev/sda1 | grep '^Block'


              You have to multiply block count and block size to get number of bytes.



              ISO-9660 file system




              isoinfo -d -i ubuntu-18.10-desktop-amd64.iso | grep -A1 '^Logical block size'


              The unit for volume size is logical blocks, so you have to multiply volume size and logical block size to get number of bytes.



              BTRFS file system



              As one btrfs can include several devices, the command takes the mountpoint as argument




              btrfs filesystem usage -b /mnt/mountpoint | grep 'Device size'





              share|improve this answer






























                1














                It depends on the filesystem you want to investigate:



                ext2, ext3, ext4 file system




                dumpe2fs -h /dev/sda1 | grep '^Block'


                You have to multiply block count and block size to get number of bytes.



                ISO-9660 file system




                isoinfo -d -i ubuntu-18.10-desktop-amd64.iso | grep -A1 '^Logical block size'


                The unit for volume size is logical blocks, so you have to multiply volume size and logical block size to get number of bytes.



                BTRFS file system



                As one btrfs can include several devices, the command takes the mountpoint as argument




                btrfs filesystem usage -b /mnt/mountpoint | grep 'Device size'





                share|improve this answer




























                  1












                  1








                  1







                  It depends on the filesystem you want to investigate:



                  ext2, ext3, ext4 file system




                  dumpe2fs -h /dev/sda1 | grep '^Block'


                  You have to multiply block count and block size to get number of bytes.



                  ISO-9660 file system




                  isoinfo -d -i ubuntu-18.10-desktop-amd64.iso | grep -A1 '^Logical block size'


                  The unit for volume size is logical blocks, so you have to multiply volume size and logical block size to get number of bytes.



                  BTRFS file system



                  As one btrfs can include several devices, the command takes the mountpoint as argument




                  btrfs filesystem usage -b /mnt/mountpoint | grep 'Device size'





                  share|improve this answer















                  It depends on the filesystem you want to investigate:



                  ext2, ext3, ext4 file system




                  dumpe2fs -h /dev/sda1 | grep '^Block'


                  You have to multiply block count and block size to get number of bytes.



                  ISO-9660 file system




                  isoinfo -d -i ubuntu-18.10-desktop-amd64.iso | grep -A1 '^Logical block size'


                  The unit for volume size is logical blocks, so you have to multiply volume size and logical block size to get number of bytes.



                  BTRFS file system



                  As one btrfs can include several devices, the command takes the mountpoint as argument




                  btrfs filesystem usage -b /mnt/mountpoint | grep 'Device size'






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 6 at 12:50

























                  answered Jan 5 at 15:51









                  JarlJarl

                  1376




                  1376






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • 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%2faskubuntu.com%2fquestions%2f622489%2fhow-to-find-the-size-of-a-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

                      flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                      Mangá

                       ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕