ext4lazyinit takes forever to finish
January 19, 2025
tl;dr
After creating a new ext4 file system on an HDD, ext4lazy4init
runs in the background to initialize the inode tables for it, but on large drives this can take over a week, resulting in seeking noises every second or so. Remounting the file system with option init_itable=0
will force the inode tables to initialize immediately.
I recently bought and installed a refurbished enterprise HDD, but right after I partitioned and mounted it on my Debian server, I noticed it was emitting seeking noises every second or so.
My first thoughts were that the disk might be broken - I wasn’t even using the disk! After some quick research, however, I realized that it was the ext4lazyinit process running in the background:
pulsh@holo-01:~$ ps -ef | grep ext4lazyinit
root 2712 2 0 Jan17 ? 00:00:14 [ext4lazyinit]
pulsh 52244 51747 0 12:12 pts/3 00:00:00 grep ext4lazyinit
It turns out that ext4lazyinit runs as a background process to initialize the inode tables for new ext4 filesystems, however this can take up to several days to complete as it runs lazily - not ideal if the drive is near your bedroom and you can’t sleep to the sound of hard drive seeking every second!
From stackoverflow, I found this command from Iwan Aucamp which produces a remount command that preserves your current mount settings, but also includes the init_table=0
flag to disable lazy initialization and force immediate inode table creation:
mount | grep </path/to/mount/point> | sed -E 's/^.* on (.*) type ext4 \((.*)\)$/mount -o remount,init_itable=0,\2 \1/g'
This gave me the following command:
pulsh@holo-01:~$ mount | grep /mnt/hdd_pool | sed -E 's/^.* on (.*) type ext4 \((.*)\)$/mount -o remount,init_itable=0,\2 \1/g'
mount -o remount,init_itable=0,rw,relatime /mnt/hdd_pool
After remounting with the ext4lazyinit disabled, the seeking noises become VERY loud, but it only took another 25 minutes for the inode table creation to finish! (•ω•)
Given that my HDD is 10TB, I don’t want to even think about how long it’d take for lazy table creation to finish.
PS: There are still audible clicks from the HDD every 5 seconds, but this is totally normal and is not ext4lazyinit - it’s just the Preventive Wear Leveling (PWL). This video has an audio recording or what it sounds like - The below video is what my HDD sounds like: