FYI:
https://swapoff.blogspot.com/2018/12/ext4-ext4lazyinit.htmlBefore it gets forgotten
My experience with computers. Might be useful to someone.
Tuesday, December 25, 2018
ext4 ext4lazyinit
Today I formatted a 3TB hard disk and mounted it with default options. However after mounting it I noticed that it periodically writes about 2 MB data. Initially I thought it was some journal information writing for the files I copied to the disk, but this 2MB data writing was not stopped when I mounted the disk after removing the journal.
Therefore I installed iotop to see what's going on. Aha, I was able to find the culprit immediately.
It was a process called ext4lazyinit.
Apparently when a partition is formatted with ext4, it does not initialize all inode tables in the file system during the file system creation time in order to speed up the process. When the new file system is mounted, it starts ext4lazyinit process to initialize the inode tables leisurely.
Needless to say, it's really annoying to hear the sound of the disk is being accessed in every second indefinitely.
After searching about this ext4lazyinit process, I found out that all the inode tables can be initialized passing lazy_itable_init=0 with the -E option when the filesystem is created. Since I have already copied some files to the disk, I didn't want to reformat it. Therefore I followed another mechanism described in the articles I read. That is mount the partition with init_itable=0 mount option. This will speed up the inode table initialization. (
https://www.kernel.org/doc/Documentation/filesystems/ext4.txt)