What does the mkfs.ext4 -G option do?
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. =)