I'd like to make a partition for keeping ISO images of nightly builds. Most of files will be bigger than 1Mb. Unfortunately ext2/ext3/ext4 supports only 4Kb blocks.

# mkfs.ext4 -b 1048576 -L DISTR -m 0 /dev/sdb1 
mkfs.ext4: invalid block size - 1048576

Is there any other reliable filesystem that can be used in order to reduce fragmentation?

  • 2
    ext4 tries to avoid fragmentation, for example it allocates extends (block groups) up to 128 MiB. Because of this, you should not get much fragmentation problems if you keep the disk usage under a certain limit. Depending how the ISO images are generated, it could be helpful to reserve space for them by using fallocate. – jofel Jan 15 '13 at 18:08
  • Unfortunately that's not unders my control... – Anthony Ananich Jan 15 '13 at 18:25
  • 1
    If you are trying to prevent fragmentation, -m 0 is certainly not what you want. As jofel said, that reserved space is used to reduce fragmentation. Also, if you had a 1MB block size and stored a 1.00001MB file, it would consume 2MB of disk space. – jordanm Jan 15 '13 at 18:48
  • Most of files are from 40Mb to 4.7Gb – Anthony Ananich Jan 15 '13 at 21:43

man mke2fs states

Valid block-size values are 1024, 2048 and 4096 bytes per block

If we have a look to fs/block_dev.c we could find following:

int set_blocksize(struct block_device *bdev, int size)
        /* Size must be a power of two, and between 512 and PAGE_SIZE */
        if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
                return -EINVAL;

And finally we can determine PAGE_SIZE:

# getconf -a| grep PAGE_SIZE
PAGE_SIZE                          4096

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.