4

On Microsoft's Best Practices for running Linux on Hyper-V page it is recommended to use ext4 and not ext3 and "specify the number of groups to be 4096" using mkfs.ext4 –G 4096 /dev/sdX1. What is this doing exactly?

The man page says the blocks per group (-g option) shouldn't be changed and using tune2fs -l I can see it's set to 32768. This means block groups of between 128 and 512 GiB (depending on block size) will be packed together, but how does this compare to the default? The man page doesn't say what the default is , and I don't see it in the tune2fs -l output either.

  • Do you want to find out what this option does generally, or what it does to a VM performance? – Konrad Gajewski Jul 12 '15 at 21:07
  • 1
    What is does generally would be good to start with, even better if someone knows what it does with a VM and with a Hyper-V VM. – Sacha K Jul 13 '15 at 5:37
2

The -g option is very, very different from the -G option for mkfs.ext4.

Microsoft is definitely recommending changing the -G option in the best practices document, not the -g option, which is clearly discouraged from being used/changed/tweaked, as you noted from the man page.

-G number-of-groups

Specify the number of block groups that will be packed together to create a larger virtual block group (or "flex_bg group") in an ext4 filesystem. This improves meta-data locality and performance on meta-data heavy workloads. The number of groups must be a power of 2 and may only be specified if the flex_bg filesystem feature is enabled.

You can see the defaults by running dump2fs -h /my/file/system and looking for Flex block group size. For example, for an ext4 partition of mine, the results are:

Flex block group size: 16

Which is exactly what Theodore Tso says it should be from his presentation Speeding up filesystem checks in ext4 on page 17.

By default mke2fs uses 16 block groups/flex_bg group (must be power of 2)

As for what it does, you can see the performance differences on fsck operations on large filesystems in Outline of Ext4 Filesystem and Ext4 Online Defragmentation Foresight, starting on page 14.

According to the linux kernel wiki, this works by grouping the metadata together for faster loading, and to enable larger files to be contiguous on disk. ext4 kernel wiki: Flexible Block Groups

The last part of that wiki entry quote enable larger files to be contiguous on disk is the key part as to why it is considered a Hyper-V best practice to set it to 4096, because it allows for smaller actual disk space usage of the dynamic VHDX files, because the files aren't fragmented as much on the filesystem on the virtual hard disk, and the data structures are more efficiently grouped.

More detail on the reasoning behind the Microsoft best practices recommendations on the Linux side can be found in the OpenSuSE 12.1 Release Notes. Formatting Large Disk Partitions on Windows Server and the Red Hat Enterprise Linux 6 Technical Notes 6.4 Virtualization too.

I hope that helps clear up your confusion and answer your questions. =)

  • Hi, thank you for your answer. I have a related question even tho this might not be the proper place for it: How do I change my current file system "number of groups" to 4096? tune2fs doesn't have a -G parameter like mkfs.ext4 does – cusco Jun 3 '16 at 15:11

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.