Configuring persistent storage Naming with UDEV on Linux

Oren Oichman
3 min readDec 15, 2019

This section is for systems with external or networked storage; for example, Fibre Channel, iSCSI, or SRP based storage devices. It is recommended that those systems have persistent device names configured for your hosts. This assists live migration as well as providing consistent device names and storage for multiple virtualized systems. Universally Unique Identifiers (UUIDs) are a standardized method for identifying computers and devices in distributed computing environments. This section uses UUIDs to identify iSCSI, SRP, or Fibre Channel LUNs. UUIDs persist after restarts, disconnection and device swaps. The UUID is similar to a label on the device. Systems which are not running multipath must use Single path configuration. Systems running multipath can use Multiple path configuration.

Single path configuration

This procedure implements LUN device persistence using udev. Only use this procedure for hosts which are not using multipath.

  1. Edit the /etc/scsi_id.config file.
    A. Add the following line:
    B. options=–whitelisted –replace-whitespace
    c. This sets the default options for scsi_id, ensuring returned UUIDs
    contains no spaces. The IET iSCSI target otherwise returns spaces in UUIDs, which can cause problems.
  2. o display the UUID for a given device run the scsi_id –whitelisted –replace-whitespace –device=/dev/sd* command. For example:
scsi_id  --whitelisted --replace-whitespace --device=/dev/sdc==1IET_00010001

3. The output may vary from the example above. The output in this example displays the UUID of the device /dev/sdc.

4. Verify the UUID output from the scsi_id –whitelisted –replace-whitespace –device=/dev/sd* command is correct and as expected.

5. Create a rule to name the device. Create a file named 20-names.rules in the /etc/udev/rules.d directory. Add new rules to this file. All rules are added to the same file using the same format. Rules follow this format:

KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM="/sbin/scsi_id \
--whitelisted --replace-whitespace /dev/$name", RESULT=="UUID", SYMLINK+="devicename"

6. Replace UUID and devicename with the UUID retrieved above, and a name for the device. This is an example for the rule above for three example iSCSI luns:

KERNEL==”sd*”, SUBSYSTEM==”block”, PROGRAM=”/sbin/scsi_id --whitelisted --replace-whitespace"
/dev/$name”, RESULT==”1IET_00010001", SYMLINK+=”rack4row16lun1"
KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM="/sbin/scsi_id --whitelisted --replace-whitespace"
/dev/$name", RESULT=="1IET_00010002", SYMLINK+="rack4row16lun2"

8. Copy the changes in /etc/scsi_id.config and /etc/udev/rules.d/20-names.rules to all relevant hosts.

Networked storage devices with configured rules now have persistent names on all hosts where the files were updated This means you can migrate guests between hosts using the shared storage and the guests can access the storage devices in their configuration files.

Multiple path configuration

The multipath package is used for systems with more than one physical path from the computer to storage devices. multipath provides fault tolerance, fail-over and enhanced performance for network storage devices attached to Red Hat Enterprise Linux 6 systems. Implementing LUN persistence in a multipath environment requires defined alias names for your multipath devices. Each storage device has a UUID, also known as a World Wide Identifier or WWID, which acts as a key for the aliased names. This procedure implements LUN device persistence using the multipath daemon.

  1. Determine the World Wide Identifier of each device using the scsi_id –whitelisted –replace-whitespace –device=/dev/sd* command:
# scsi_id — whitelisted --replace-whitespace --device=/dev/sde
1IET_00010004
# scsi_id — whitelisted --replace-whitespace --device=/dev/sdf
1IET_00010005
# scsi_id --whitelisted --replace-whitespace --device=/dev/sdg
1IET_00010006
# scsi_id --whitelisted --replace-whitespace --device=/dev/sdh
1IET_00010007

2. Create the multipath configuration file, /etc/multipath.conf. In it create a defaults section, and disable the user_friendly_names option unless you have a specific need for it. It is also a good idea to configure the default arguments for the getuid_callout option. This is generally a useful start:

defaults {
user_friendly_names no
getuid_callout “/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/%n”
}

3. Below the defaults section add a multipaths section (note the plural spelling). In this section add each of the WWIDs identified from the scsi_id command above. For example:

multipaths {
multipath {
wwid 1IET_00010004
alias oramp1
}
multipath {
wwid 1IET_00010005
alias oramp2
}
multipath {
wwid 1IET_00010006
alias oramp3
}
}

4. Multipath devices are created in the /dev/mapper directory. The above example will create 4 LUNs named /dev/mapper/oramp1, /dev/mapper/oramp2

5. Start and enable the multipathd daemon to start at system boot:

Systemctl start multipathd
Systemctl enable multipathd

That is it

Have FUN!!!

--

--