|

Gain Control of the Storage Controller Loading Order

I encountered an intriguing issue recently after replacing my motherboard. Some block devices underwent a change in their order, causing /dev/sda to appear as /dev/sdy due to a modification in the PCI-e enumeration. This change, though seemingly insignificant, led to an unexpected consequence. Since the disk was subject to a specific mdadm filter, its altered name caused it to drop out of the filter’s scope.

This problem may arise when using multiple disk storage controllers, like the combination of ‘ahci’ device driver and ‘mpt3sas’ in my case. When installing a new Linux system, uncertainty prevails as to whether the kickstart file pointing at ‘/dev/sda’ will erase the external storage disk connected through a different storage controller. While some Linux admins opt to disconnect additional storage controllers before installation and reconnect them afterwards, or blacklist the driver (e.g., using “modprobe.backlist=mpt3sas”), I aim to introduce alternative approaches for handling such scenarios by taking control over the loading order of drivers in the initial RamDisk (initrd, initramfs).

The procedure I’ll describe was successfully tested on Oracle Linux 8 and is incorporated into ‘dracut’, making it compatible with all RHEL-based systems version 8 and newer. I encourage readers to also test it on older Linux distributions utilizing ‘dracut’.

The key to this method lies in utilizing the “rd.driver.pre” argument in ‘dracut’ command-line. By adding this command-line parameter (edit /etc/default/grub and recreate grub2 configuration), you can reference a driver that is already included in the dracut ramdisk. Doing so ensures that the device driver associated with that driver is loaded early in the boot process, leading to the desired disk enumeration on that storage controller device before others. Here’s an example of the command-line, to enforce an order where ahci loads early, but before mpt3sas.

rd.driver.pre=ahci,mpt3sas

Alternatively, you can enforce ‘dracut’ driver order through the configuration file directive ‘force_drivers+=’ in /etc/dracut.conf or a modular config file in /etc/dracut.conf.d/. If you need to add multiple drivers, enclose the list in quotes and separate them with spaces. Make sure to leave a space between the quotes and the drivers name as well. For example:

force_drivers+=" ahci virtio_scsi usb_storage "

Once you have taken the necessary action, rebuild the initramfs by running the following command as the root user:

dracut -f

By following these steps, you gain control over the loading order of storage controllers and other drivers during the boot process, granting you flexibility and ensuring a smoother system setup. The possibilities are vast, and this method opens up new avenues for customising your Linux environment to suit your specific requirements.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.