How do I remove a particular module from initramfs in Red Hat Enterprise Linux 6 and 7?
Environment
- Red Hat Enterprise Linux (RHEL) 6
- Red Hat Enterprise Linux (RHEL) 7
dracut(the tool that generates initramfs images in RHEL6 and 7)
Issue
- Requirement to remove a module from initrd image in order to avoid it loading at boot time.
- In some cases, a SAN disk may get labelled as "/dev/sda", before the local disk does.
Resolution
There are three alternative methods to avoid a particular kernel module being loaded at boot time in RHEL 6 and RHEL7
-
In order to remove / disable a kernel module at boot time, omit the module (in the following example the
lpfcdriver) and rebuild the initrd.# mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-old.img # dracut --omit-drivers lpfc /boot/initramfs-$(uname -r).img -
Add the module to the
omit_drivers+=""line in /etc/dracut.conf. Specify a space-separated list of kernel modules to omit from the initramfs. Uncomment the line if required and then rebuild the initrd file. For example:# grep ^omit_drivers /etc/dracut.conf omit_drivers+="lpfc" # mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-old.img # dracut /boot/initramfs-$(uname -r).img $(uname -r)
NOTE: The value specified in omit_drivers can be an regular expression string.
-
Add the
rdblacklistboot parameter to thevmlinuzkernel command line in /boot/grub/grub.conf:-
For example, append the following line to the vmlinuz line(s) in /boot/grub/grub.conf:
rdblacklist=lpfc -
An example:
# grep vmlinuz /boot/grub/grub.conf kernel /vmlinuz-version ro root=/dev/sda2 rdblacklist=lpfc
-
NOTE: In RHEL7, rdblacklist= is deprecated by rd.driver.blacklist=, but it still works for compatibility.
Root Cause
dracut provides a method for manually excluding kernel modules from the initrd file: the --omit-drivers options explained here.
Please note that this is different from omitting dracut modules themselves: see omit_dracutmodules in dracut.conf(5) (or the -o / --omit command line option for ``dracut(8)` to exclude dracut modules from the initramfs. As an example:
--omit-drivers dm-multipathwill excludedm-multipath.kofrom the initrd--omit multipathwill generate an intird which does not include the code that loadsdm-multipathand activatesmultipathd
More information about omitting kernel modules from dracut are available at the dracut(8) and dracut.conf(5) man pages, and at This content is not included.at the following site.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.