Skip to contentSkip to conversation

ext2 optimal partition size

DISCUSSION DervishD 2 participants 4 messages May 15, 2005 – May 16, 2005

lore
Share & tools
lore

DervishD

author
#0 lore raw

Hi all :)

Let's assume I want to partition a hard disk so the partition
size is optimal for a given block size and bytes per inode ratio in an ext2/ext3 filesystem. By 'optimal' I mean that no space in the partition is wasted, that is, the metadata and the data blocks fit perfectly in the partition, and no space is left unused because that space is less than a data block.

For example, if disk structures occupy 1024 bytes and each data
block is 1024 bytes too, the partition size must be a multiple of 1024: if I allocate 2049 bytes for the partition, then one byte will be lost because ext2/3 cannot have blocks smaller than the block size.

So: which is the optimal partition size for a given block size
and a given bytes per inode ratio? Can it be easily calculated?

Thanks a lot in advance :)

Raúl Núñez de Arenas Coronado

Signature · 3 lines
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
#1 lore raw
Quoted 9 lines · DervishD

Hi all :)

Let's assume I want to partition a hard disk so the partition
size is optimal for a given block size and bytes per inode ratio in an ext2/ext3 filesystem. By 'optimal' I mean that no space in the partition is wasted, that is, the metadata and the data blocks fit perfectly in the partition, and no space is left unused because that space is less than a data block.

Quoted 9 lines

For example, if disk structures occupy 1024 bytes and each data
block is 1024 bytes too, the partition size must be a multiple of 1024: if I allocate 2049 bytes for the partition, then one byte will be lost because ext2/3 cannot have blocks smaller than the block size.

So: which is the optimal partition size for a given block size
and a given bytes per inode ratio? Can it be easily calculated?

You can't allocate 2049 bytes for a partition - it is always a whole number of 512-byte blocks.

ext2/ext3 uses either 1024-byte b�locks or 4096-byte blocks. (well, you may be able to use 2048-byte blocks, or 8192-byte blocks on systems with 8k pages, but thats another issue.)

Just make sure your partition is a whole number of blocks, ext2/ext3 should then be able to utilize the partition fully to the last block.

Using a blocksize equal to the pagesize (i.e. 4096) is usually optimal. 1024-byte blocks may be useful if your filesystem is dominated by files smaller than 2K, otherwise don't bother.

So make sure your partition consist of an integral number of 4k blocks, it will then be perfect.

Helge Hafting

author
#2 lore raw

Hi Helge :)

* Helge Hafting <[email protected]> dixit:

Quoted 16 lines · DervishD
Quoted 15 lines

Hi all :)

Let's assume I want to partition a hard disk so the partition
size is optimal for a given block size and bytes per inode ratio in an ext2/ext3 filesystem. By 'optimal' I mean that no space in the partition is wasted, that is, the metadata and the data blocks fit perfectly in the partition, and no space is left unused because that space is less than a data block.

For example, if disk structures occupy 1024 bytes and each data
block is 1024 bytes too, the partition size must be a multiple of 1024: if I allocate 2049 bytes for the partition, then one byte will be lost because ext2/3 cannot have blocks smaller than the block size.

Quoted 5 lines
Quoted 3 lines

So: which is the optimal partition size for a given block size
and a given bytes per inode ratio? Can it be easily calculated?

You can't allocate 2049 bytes for a partition - it is always a whole number of 512-byte blocks.

That's was just an example, and anyway I can create an ext2/3
filesystem on a file.

Quoted 3 lines

Just make sure your partition is a whole number of blocks, ext2/ext3 should then be able to utilize the partition fully to the last block.

Do that means that metadata (disk structures, block groups
structs and the like) all fits in block-size chunks???

Quoted 1 line

Using a blocksize equal to the pagesize (i.e. 4096) is usually optimal.

Thanks, I'll try it :) My main doubt was if the metadata was
managed in block-sized chunks, it seems so.

Raúl Núñez de Arenas Coronado

Signature · 3 lines
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
#3 lore raw
Quoted 4 lines · DervishD

Hi Helge :)

That's was just an example, and anyway I can create an ext2/3
filesystem on a file.

Sure. It won't be a "partition" though.

Quoted 7 lines
Quoted 4 lines

Just make sure your partition is a whole number of blocks, ext2/ext3 should then be able to utilize the partition fully to the last block.

Do that means that metadata (disk structures, block groups
structs and the like) all fits in block-size chunks???

fs-blocksize chunks, yes. (i.e. 1K or 4K blocks, not the 512 byte disk blocks.)

I don't know if aøll metadata fits iarbitrary number of block-sized chunks, but that cannot matter. Any "extra" block can surely be utilized for file data.

Quoted 5 lines
Quoted 2 lines

Using a blocksize equal to the pagesize (i.e. 4096) is usually optimal.

Thanks, I'll try it :) My main doubt was if the metadata was
managed in block-sized chunks, it seems so.

Managing everything in block-sized chunks is a common design in unix filesystems. It avoids many problems and allows arbitrary filesystem sizes.
Of course some structures will need quite a few blocks, but the number of blocks will depend on the size of the filesystem and will therefore always fit in the available space. (Well, unless you try creating something silly like a 1-block fs. :-)

Helge Hafting