Determine the block size on hard disk filesystem for disk quota

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'

Output:

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).

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 7 comments… read them below or add one }

1 mj 05.29.06 at 4:57 pm

hi,
i think that this is BLOCK SIZE OF FILESYSTEM not harddisk. Title is a bit missleading. BLOCK SIZE OF DISK is allmost always 512B

2 LinuxTitli 05.29.06 at 5:08 pm

Opps :( you are right. Above command is to determine the actual size of a block on the filesystem.

Thanks, I will update post :)

3 Tortanick 01.04.07 at 11:58 am

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?

4 Teslamike 03.28.07 at 3:04 pm

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.

5 James Cape 03.08.09 at 4:49 pm

Umm, 409600 blocks = 409600(blocks) * 4096(B) = 1.6G

6 linuxrawkstar 04.23.09 at 6:56 pm

Nice tip. The comment by James Cape assumes that all block sizes are all the same, all the time, on all filesystems… hmmm. Is that true??

7 Shane Menshik 06.13.09 at 11:07 am

You can also get the block size for all disks using the following command, as well as readahead, size, etc.

blockdev –report

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Tunneling VNC connections over SSH – Howto

Next post: Re-read the partition table without rebooting Linux system