Help regenerating initramfs in order to apply edits to /etc/modprobe.d/hid_apple.conf?

I’m looking to configure function lock functionality for my wireless keyboard, and on a traditional distribution I followed these steps. However I don’t know how to regenerate initramfs to make the changes persist. Running sudo dracut --force produces the error

dracut[F]: Can't write to /boot/efi/fde6406b6ffa4c609869132721a0f265/6.14.11-300.fc42.x86_64: Directory /boot/efi/fde6406b6ffa4c609869132721a0f265/6.14.11-300.fc42.x86_64 does not exist or is not accessible.

lock function keys:

echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode

unlock function keys:

echo 1 | sudo tee /sys/module/hid_apple/parameters/fnmode

To make the change permanent across reboots and reconnects:

sudo nano /etc/modprobe.d/hid_apple.conf

Write:

options hid_apple fnmode=0

Save with Ctrl + S and Ctrl + O

Regenerate initramfs:

sudo dracut --force

Reboot.

I have not used this featureset myself, however, there are a couple of cli sub-commands that seemed to be intended for just this purpose.

rpm-ostree 
Usage:
  rpm-ostree [OPTION…] COMMAND

Builtin Commands:
  ...
  initramfs              Enable or disable local initramfs regeneration
  initramfs-etc          Add files to the initramfs
  ...

Client administration | rpm-ostree just points to the man page.

Here is the text from the man page on my bluefin-dx installation.

initramfs
    By default, the primary use case mode for rpm-ostree is to replicate an initramfs as part of a base layer. However, some use cases require locally regenerating it to add
    configuration or drivers. Use rpm-ostree initramfs to inspect the current status.

    Use --enable to turn on client side initramfs regeneration. This runs dracut to create the new initramfs. A new deployment will be generated with this new initramfs, and after
    reboot, further upgrades will continue regenerating. You must reboot for the new initramfs to take effect.

    To append additional custom arguments to the initramfs program (currently dracut), use --arg. For example, --arg=-I --arg=/etc/someconfigfile.

    The --disable option will disable regeneration. You must reboot for the change to take effect.

    Note that for the simpler use case of adding a few files to the initramfs, you can use rpm-ostree initramfs-etc instead. It is more lightweight and does not involve running
    dracut.

initramfs-etc
    Add configuration (/etc) files into the initramfs without regenerating the entire initramfs. This is useful to be able to configure services backing the root block device as well
    as early-boot services like systemd and journald.

    Use --track to start tracking a specific file. Can be specified multiple times. A new deployment will be generated. Use --untrack or --untrack-all to stop tracking files.

    When there are tracked files, any future created deployment (e.g. when doing an upgrade) will ensure that they are synced. You can additionally use --force-sync to simply
    generate a new deployment with the latest versions of tracked files without upgrading.

Hope that helps.

1 Like

I was able to get initramfs to regenerate using sudo rpm-ostree initramfs --enable but it didn’t take my changes into account until i ran it with the args flag to point to what I had changed. If changes don’t persist through updates I’ll update my post but for now I’ll mark this as solved. Thanks so much for your help!

sudo rpm-ostree initramfs --enable --arg=-I --arg=/etc/modprobe.d/hid_apple.conf

Note what the man page says for initramfs-etc:

Use --track to start tracking a specific file. Can be specified multiple times. A new deployment will be generated. Use --untrack or --untrack-all to stop tracking files.

When there are tracked files, any future created deployment (e.g. when doing an upgrade) will ensure that they are synced. You can additionally use --force-sync to simply generate a new deployment with the latest versions of tracked files without upgrading.

But please do dig into the docs a little deeper. I only have surface knowledge about this.

I am glad to hear you are getting close to a solution though.

Lucky you!

Last time I tried something with initramfs, I had to reinstall.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.