First write operation to large ext4 file system is slow

I’m running a large (>20TB) ext4 file system and noticed that the first substantial write operation after mounting is very slow and involves plenty of drive activity. The reason seems to be some memory structure initialisation as described here: https://linux-ext4.vger.kernel.narkive.com/SUFNE520/ext4-slow-performance-on-first-write-after-mount

The workaround is thankfully as simple as running this command in a script after mounting the file system:

cat /proc/fs/ext4/dm-0/mb_groups > /dev/null

The device (here: dm-0) probably will be something different in your setup.

Edit 29 Nov 2020: mb_groups seems to be a block allocation cache. Sources: kernel documentation

Tux by Larry Ewing in 1996, source Wikipedia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.