Improving mkinitcpio hooks order

In my default Manjaro installations, in /etc/mkinitcpio.conf, hooks look like:

base udev autodetect modconf block keyboard keymap resume filesystems fsck

Because errors that I have seen, I suspect this order has some of these potential drawbacks:

  • No USB keyboard if the block device fails to mount, unable to enter systemd recovery. Perhaps keyboard before block could fix that.
  • No USB keyboard on tty if the computer is a laptop, and the keyboard is connected later on. keyboard and keymap before autodetect can fix that for sure.
  • GRUB won't support encryption passwords if they have special characters, and the keyboard is non USA. Perhaps keymap before block is needed, before encrypt for sure.
  • Useless fsck message during boot. Changing udev and resume for systemd fixes that for sure.

Which shall look something like:

base systemd keyboard keymap autodetect modconf block encrypt fsck filesystems

For technical details, the Arch Wiki.

the resume is in the wrong place

That in fact should be:

base udev resume autodetect modconf block keyboard keymap encrypt fsck filesystems

the udev usr [if used] resume can be replaced by systemd
Since the block provides * mmc , pata , sata , scsi , usb - what would activate keyboard if is put before it?

keyboard and keymap should go before autodetect. Otherwise the modules won't be loaded if your computer is a laptop, permanently disabling support for external keyboards outside the desktop environment. As said on the Arch Wiki.

When systemd fails to load block devices, for example when the system has been left in a half installed state, it throws you to an emergency terminal. This terminal offers you recovery options:

But when this happened to me the USB keyboard I use didn't work. My guess is it was because of the keyboard module being loaded after block.

So, how that "improves" mkinittcpio if what you explain only happens in your particular case ?

You really don't read: it will happen to anybody which internal drive fails to boot and uses an USB keyboard.

And if that happens how the order would matter if the DRIVE itself is not accesible, readable, failed to pass certain point before or after GRUB ?

Don't go that road. Friendly advice :wink:
If you want to build an argument, at least remain consistent, and don't go personal with me ... If you want to ask questions and reply to yourself, that's perfectly fine with me. Have a good one!

Sorry, but I have already explained it three times.

A few weeks ago, the "systemd" hook led to an unbootable system. I wonder whether it's fixed now.

I have tested it works.

... that it happens to your install and your laptop, with an external USB keyboard connected ... that was clear from the start. The part how all this would benefit all systems (including those i have) is not included in your "explanation".

Then what is the issue? Or should be expected that your proposal will be applied and some systems that now work will become experimental ground?


My computer is not a laptop. It just uses an USB keyboard, as most computers.

The laptop problem is just an additional different problem.

And my computer is a laptop with external keyboard. Putting keyboard before autodetect really helped me to have my keyboard accessible when luks passphrase prompt appeared. Keymap is not that important for me, but I understand the logic behind arch wiki recommendations and I'd rather follow it because it never failed me.
Also, regarding resume hook. @bogdancovaciu , I don't understand why you have put it before autodetect and, most importantly, before encrypt one. Cuz swap file location, for instance, must be decrypted first, right?

1 Like

Right, so is not better to address each issue specifically and not mixed? :slight_smile:

I don't use encryption so i got carried along by adding encrypt. From what i know the resume is indeed required after, also after lvm2 if is used, but again, i don't use that ...
On my systems:

HOOKS=(base udev resume autodetect modconf block  keyboard filesystems fsck)

are like so since the installation was done 2 years ago, never touched them ... The systems work with no issue.
But since what i have and use is also contradictory with
and you guys want the exact thing is in the wiki, but you encounter issues ... then ...

OK then, now I see. It drew my attention because I actually use encryption and hibernation, that requires another sequence of hooks, mine are as follows:
base udev keyboard autodetect modconf block consolefont keymap tpm2 encrypt resume filesystems bootsplash-bgrt-manjario. Never had any issue with this.

I have used systemd hook since ages, but since it broke just a few weeks ago, I won't put it back in.

Be careful with that if you use LUKS and your swap partition / swapfile is encrypted. In that case the resume hook needs to come after encrypt.

I don't ... :slight_smile:

Anyways, to be on the save side best pratice is to put resume after encrypt and after lvm2 if that is used too.

OK back to OP question.

Use systemd-fsck-root.service instead if you don't like the message. But changing udev to systemd may lead to unpredictable system failures as Manjaro relies on udev hook, not systemd one. It also means that you would have to change encrypt to sd-encrypt, some useful utilities may stop working, etc. So,

base udev keyboard keymap autodetect modconf block (encrypt lvm) resume filesystems

seems to me the most feasible generic hook order

1 Like

"systemd-fsck-root.service" only activates if the "systemd" hook is present. It's the starting condition.