How do I change the order of storage devices during boot in RHEL 7?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7

Issue

  • The system is having internal RAID disk and few SAN devices. Sometimes, after a reboot /dev/sda name is assigned to SAN devices. How to force /dev/sda name for internal disk?

  • As per the article How do I change the order of storage devices during boot in RHEL 5 and 6?, rdloaddriver kernel option could be used to change the order of storage devices during boot process, and to get /dev/sda name for internal disk. Can the same option be used in RHEL 7 as well?

Resolution

Caution!   While the method outlined herein can make sdX name assignment more consistent in order across boots, it cannot guarantee sdX name ordering persistence across all reboots.
 
The supported method is to use one of the alternative system supplied persistent names, for example /dev/disk/by-id/* devfs entries or data self-identifiers such as UUIDs (LVM or filesystems) and WWIDs (devices). Alternatively, you can use udev to create a custom device name to be used.
NOTE:   The design of the linux kernel architecture is focused on using self-identification of data, disks, partitions, and filesystems (targets) for accessing and mounting of same. This is done via the use of unique names provided by the target (WWIDs or UUIDs for example). The correct method of accessing a target is via the unique names provided by the target itself rather than trying to depend on device name ordering which is not designed, and thus not guaranteed, to be the same across boots. There are some ways to workaround the architecture of using self-identification and instead trying to relying upon device names as outlined below. But these workarounds are contrary to the design of linux and will not always work in all cases..

There is no means of controlling the parallel discovery architecture within the linux kernel. It is contrary to the design goals of faster boot times. At best, system administrators can try workarounds to finesse the scsi host discovery order in support of legacy third party software that can only use the system scsi device names (sdX, stN, etc.).

While the method of specifying driver load order works pretty well in RHEL5 and 6, it works less well within RHEL 7 and 8 due to the additional in-parallel device discovery present in these kernel version. It will eventually happen that while scsi host number is in the expected order, the assigned sdX names will not be in expected order. For example:

    0:0:0:0 => sda   in the following example, local disk under megaraid_sas
    0:0:0:1 => sdb   2nd local disk
    1:0:0:0 => sdc   1st FC disk
    0:0:0:3 => sdd   3rd local disk
    1:0:0:1 => sde   2nd FC disk
     :
  • The rdloaddriver dracut option is deprecated in RHEL 7 and there is another option rd.driver.pre used to define the sequence in which modules are loaded during boot process:

      From  man dracut.cmdline:
      
      
      $ man dracut.cmdline
      [...]
         Deprecated, renamed Options
             Here is a list of options, which were used in dracut prior to version 008, and their new replacement.
      	[...]
             rdblacklist
      	   rd.driver.blacklist
      
             rdinsmodpost
      	   rd.driver.post
      
             rdloaddriver
      	   rd.driver.pre		<<----------
      	[...]
    
  • For RHEL 7 please use the rd.driver.pre option as per the steps below. With following steps, internal disk will get detected first and would get the /dev/sda name:

    o Edit the /etc/sysconfig/grub file and modify GRUB_CMDLINE_LINUX line as shown in following example:

      GRUB_CMDLINE_LINUX="rd.lvm.lv=rootvg/rootlv rd.lvm.lv=rootvg/swaplv rd.driver.pre=megaraid_sas,lpfc"
    

    In above example, the internal disk is connected to MegaRAID controller managed by megaraid_sas module and SAN devices are connected using Emulex FC HBAs managed by lpfc driver.

    So, loading the megaraid_sas modules before lpfc would help to initialize the internal disk first and get /dev/sda name for it.

    Note: Above solution would only help to initialize the internal RAID controller and disk connected to it before other HBAs available on the system. If there are multiple disks connected to the same MegaRAID controller, then it could not be guaranteed that a specific disk connected to same MegaRAID controller will get sda name. In such case any disk connected to MegaRAID controller may get sda name.

  • There are also scenarios when a controller should be enumerated first, prior to others. Let the scenario where two device controllers, one AHCI and another Megaraid, and I need to use AHCI as first device. Then, use the following configuration:

      rd.driver.pre=ahci and rd.driver.post=megaraid_sas
    

And finally after you make your desired changes, run following command to write the GRUB configuration:

  • On BIOS-based machines: ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
  • On UEFI-based machines: ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

And reboot your system.

SBR
Components

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.