Make a module setting survive a kernel update

applied · 40 min · Objective 1.2

Task

Configure a module parameter and a blacklist so both survive a reboot and a kernel update, then verify by actually rebooting. Then rebuild the initramfs and confirm the change reached the early boot stage as well -- the step whose omission produces "unable to mount root fs".

Steps

  1. Pick a module with a parameter you can observe. dummy takes numdummies. Load it with modprobe dummy numdummies=3 and confirm three interfaces appear.
  2. Unload it and confirm the parameter did not persist -- loading it again plainly gives the default.
  3. Make the parameter persistent: create /etc/modprobe.d/dummy.conf containing options dummy numdummies=3, and confirm it takes effect on the next modprobe.
  4. Make the module load at boot: add its name to a file under /etc/modules-load.d/.
  5. Blacklist a module you do not want loading automatically -- create /etc/modprobe.d/blacklist-lab.conf with blacklist floppy or similar -- and note that an explicit modprobe would still load it.
  6. Learn the stronger form: replace the blacklist line with install floppy /bin/true and confirm an explicit modprobe now does nothing.
  7. Rebuild the initramfs so early-boot module handling matches: dracut -f or update-initramfs -u. Confirm the new file is newer than the configuration you just wrote.
  8. Reboot and verify everything held.

Verify

cat /sys/module/dummy/parameters/numdummies      # 3, after reboot
ip -br link | grep -c '^dummy'                   # 3
systemctl status systemd-modules-load --no-pager | head -3
lsinitrd 2>/dev/null | grep -c dummy || lsinitramfs /boot/initrd.img-$(uname -r) | grep -c dummy
stat -c '%y %n' /boot/initramfs-$(uname -r).img /etc/modprobe.d/dummy.conf 2>/dev/null

The last check is the point: the initramfs timestamp must be NEWER than the configuration file. If it is older, the early boot stage is still running with the previous settings, and that is the state in which a storage driver change leaves a machine unable to find its root filesystem.

Notes

Step 6 is the distinction the exam asks about. blacklist prevents automatic loading only; install <module> /bin/true replaces the load command with a no-op, so even a deliberate modprobe achieves nothing.