34

Is there any way to 'force' ext4lazyinit to finish the thing it does with maximum priority? Something like "I don't care about my system's ressources, just do your job as fast as you can"?

I should add: Without reformatting the drive. I am aware of mkfs's lazy_itable_init option.

3
  • Sounds pretty XY to me. What are you actually trying to achieve?
    – Daniel B
    Commented Jul 18, 2014 at 8:18
  • 7
    It took my Raspberry Pi multiple hours to finish ext4lazyinit on an external hard drive. I wanted to test if the hd spins down correctly after some time of inactivity however that wasn't possible due to ext4lazyinit. After looking at some kernel code (github.com/torvalds/linux/blob/master/fs/ext4/super.c#L2931) it seems not possible to force the thread to finish since the delays are somewhat hardcoded. That is however no definitive answer, I am no kernel nor ext4 expert and I just took a glimpse at that function.
    – Marius
    Commented Jul 18, 2014 at 9:29
  • @Marius You are correct that the delay is hard-coded.
    – Moshe Katz
    Commented Sep 14, 2016 at 18:49

2 Answers 2

33

In order to 'force' ext4lazyinit to finish the thing it does with maximum priority, you need to mount the filesystem with 'init_itable=0'. By default it is 10 (for detail please see link below)

Alternative solution is to disable the ext4lazyinit thread by mount option 'noinit_itable' which may however not be a good idea on production system (for detail please see link below).

Source with detailed info here ext4lazyinit git commit comment.

2
  • 5
    To get command that can be used to remount (without off lining) you can run mount | grep /path/to/mount/point | sed -E 's/^.* on (.*) type ext4 \((.*)\)$/mount -o remount,init_itable=0,\2 \1/g' - This will output something like mount -o remount,init_itable=0,rw,noatime,seclabel,stripe=512,data=ordered /path/to/mount/point Commented May 14, 2018 at 20:05
  • Thanks init_itable=0 was the answer I was looking for. Commented Nov 8, 2020 at 3:59
-1

You can set the 'nice' level of the process to a higher priority over others. Not sure if it will make it go any faster though and could adversely affect system stability if set too high (-20 is the highest priority).

nice -n [nice value] [command]
2
  • 3
    nice would be giving it more CPU priority, what it needs is more IO priority, @VencaBSpam has the right solution Commented Mar 14, 2018 at 0:17
  • There is always ionice -c 2 (or possibly -c 1) for that (counterpart is ionice -c 3 for maximum "nice level"). However, neither of these are probably applicable to the lazy initialization, as there does not seen to be a pid associated to it.
    – Wolfram
    Commented Jun 19, 2023 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .