7

question: How can I calculate the size of an ext4 partition that is needed to have a predefined amount of space available for the filesystem?

example: I'd like to have a filesystem with 100 GB space (according to df) and would like to know how much space in MiB I need to give my new ext4 partition in GParted.

background: I noticed that df (1K block equals 1024 bytes) displays different filesystem sizes than lsblk -b (1 size unit equals 1 byte). I understand that this is because lsblk shows the size of partitions while df shows the size of filesystems (the space that is actually available for files).

example:

$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda10      90187896   57032  85506480   1% /home/user

$ lsblk -b
NAME  MAJ:MIN RM        SIZE RO TYPE MOUNTPOINT
sda10   8:10   0 94371840000  0 part /home/user

df-calculation: 90187896*1024 = 92352405500 bytes
lsblk:                          94371840000 bytes
overhead:                       1 - 92352405500/94371840000 ~ 2.14%

Using the default ext4 configuration (GParted, LinuxMint and probably others) the block to inode ratio is 4:1 and block size is 4096 while inode size is 256 so the data to inode ratio is 64:1 (source: tune2fs -l). Thus, the inode table only contributes to 1.5625% ext4 filesystem overhead.

Where does the remaining overhead occur and how can I calculate it? I've done a test for various ext4 partition sizes (10,000 to 380,000 MiB) and the overhead fluctuates between ~1.8 and ~2.3% but seems to decrease with increasing partition size (see image).

filesystem overhead [%] over partition size [MiB]

side note #1: My question has nothing to do with KiB (2¹⁰ bytes) vs. KB (10³ bytes), MiB (2²⁰ bytes) vs. MB (10⁶ bytes), GiB (2³⁰ bytes) vs. GB (10⁹ bytes) and so on.

side note #2: This is also not about reserved blocks (5% per default) as those are shown in df.

2

1 Answer 1

1

Well, the available maximum capacity can be estimated at [Partition Size] * (1 - inode_size / inode_ratio - reserved-blocks-percentage). So to get a specific capacity, calculate [Partition Size] = [Capacity] / (1 - inode_size / inode_ratio - reserved-blocks-percentage).. See /etc/mke2fs.conf for common values.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .