Determine the block size on hard disk filesystem for disk quota

Posted on in Categories FAQ, Linux last updated May 8, 2006

When configuring user disk quotas I need to find out the block size on my SCSI hard disk drive. For example if I am using a block size of 1024 then setting block size to 102400 blocks limit my user to 100MB of disk space.

Therefore, it is necessary to determine the correct block size; otherwise, I will end up assigning wrong disk quota limit.

You can use dumpe2fs command, which prints the super block and blocks group information for the filesystem present on device. You need to type dumpe2fs command as the root user:

# dumpe2fs /dev/sdb3 | grep -i ‘Block size’


Block size:               4096

Now setting a user quota of 40960 would limit a user to 10MB of disk space.

Please note that dumpe2fs command used to determine the actual size of a block on the filesystem (and not BLOCK SIZE OF FILESYSTEM not harddisk).

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 20 comments/add one below):

20 comment

  1. I just found this post, it was exactly what I was looking for, thanks for the help 🙂

    Just two things:

    1) on my system I had to use double quotes rather than single quotes,

    2) I think this means that 100MB could be bigger on one system than another? Am I right?

  2. 100MB is the same size on one system as it is on another. However, with varying block sizes, 100MB may spread over more blocks on systems with smaller block sizes than it does on a system with a larger block size.

    For example, on a system with a 512B block size 100MB will take up 204800 blocks. On a system with a 64K block size 100MB will take up 1600 blocks.

  3. linuxrawkstar:

    No, James Cape’s tip doesn’t assume that all block sizes are all the same, all the time, on all filesystems.

    His tip specifically follows the example in the article, in which LINUXTITLI “discovered” a 4096b block size for the filesystem he was discussing.

    LINUXTITLI, and Shane too, already showed how to discover block size for some other particular filesystem.

  4. I am a bit confused…

    when I try to see block size with command “/sbin/dumpe2fs -h /dev/mapper/System-home”
    then it says:

    Block size: 4096

    but when i run df command: it shows
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/mapper/System-home 61958132 49838676 8972092 85% /home

    and when I run df -h, it shows

    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/mapper/System-home 60G 48G 8.6G 85% /home

    does this mean that 1Kb = 4096 blocks ??

  5. Hello Vivek / Admin,

    This article is little confusing. I would suggest to make necessary correction on this article.

    The output of # dumpe2fs /dev/sdb3 | grep -i ‘Block size’ is IO Block size. not the block size of filesystem which is 512K (each sector size). In your example 8 x 512K = 4096K, which is the default IO Block size.

      1. Agreed, it seems the original post is potentially incorrect. My understanding is that you first need to calculate the total size you want in bytes and divide it by the block size.

        EG: 100MB = 1024 x 1024 x 100 – this is the definition of 100Megabytes

        Then depending on your file system block size, you divide by that to get your number of blocks.

        So just like David explained: 1024x1024x100 = 104,857,600 / 4096 = 25600

        25600 blocks

        1GB = 1024x1024x1024 / 4096 = 262144 blocks

        However, in my case I’m trying to determine what is the block size used by the quota system, or how can I find out what that is? My fs is mounted using a 4096 byte block size, but quota doesn’t seem to be using the same block size to set it’s limits. I assume it’s going by 1024 byte block sizes. Is there anyway to verify that without writing a C program and using the ‘sys/mount.h’ library?

  6. “Now setting a user quota of 40960 would limit a user to 10MB of disk space.” Yeah, I don’t the math here is right if the block size is 4096 B or 4 KiB.

    40960 * 4 KiB = 160 MiB
    40 * 1024 * 4 * 1024 = 160 * 1024^2
    1024^2 = Mi

Leave a Comment