Available block sizes differ dependent on the filesystem - for example:
ext2: 1024 (1Kb), 2048 (2Kb) or 4096 (4Kb) bytes
ext3: 1024 (1Kb), 2048 (2Kb), 4096 (4Kb) or 8096 (8kB) bytes
ext4: 1024 (1Kb) to 65536 (64Kb) bytes
xfs: 512 (0.5kB) to 65536 (64kB) bytes
The block size is defined when initially creating the file system e.g.:
mkfs -t ext3 -b 4096 /dev/sda1
Performance Considerations
Typically if you are going to be storing large files on the disk you will want to ensure you have a large[er] block size - look at it this way: if you have a large file with many blocks (the blocks combine together to create the file) it will take longer to read all of those individual blocks than if you had larger blocks - meaning less blocks to read.
And in reverse - if you have a large amount of small files you will want a small block size as there will be a greater amount of blocks available to accommodate the files and because the blocks are smaller the system is having to read less sectors and hence improves the performance.
Hard disks
A hard disk will contain a (constant) sector size - usually 512. It is important to note that a block size can't be lower than that of the hard disks sector size - it must be a multiple of it's sector size e.g. 1024,2048 and so on.
Block Groups
(Specific to EXT file systems - see 'Allocation Groups' for XFS) Block groups are made of individual blocks - which makes reading and writing large amounts of data easier.
Each block group contains a redundant copy of the super block (mentioned below) and file system descriptors.
The physical structure of the file system is made up as follows:
A superblock contains important filesystem meta data like:
- Blocks per block group
- Number of free blocks in the filesystem
- Mount and write times
- File system state (e.g. clean or dirty mount)
Hence protecting superblocks is extremely important - and loss of a superblock can render a filesystem unmountable!
0 comments:
Post a Comment