Skip to content
Welcome To Charanjit Cheema Blog

Welcome To Charanjit Cheema Blog

An Open Source and Cloud Blog

Menu
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
Menu

Persistent Disk Mapping in Linux – Udev Rules vs. Multipath Configuration

Posted on June 4, 2024June 4, 2024 by Charanjit Singh

In Linux, ensuring persistent device names for storage volumes is crucial, especially in environments where device names can change across reboots or when new devices are added. This persisting mapping become more crucial if you want to provision raw storage volume for Oracle ASM disks. There are two common methods to achieve this persistence either through udev rules or through multipath configuration. In this article I will explain both methods by providing detailed instructions and examples for each.

 

Udev Rules for Persistent Device Naming

Udev is the device manager for the Linux kernel, responsible for managing device nodes in   /dev. By creating custom udev rules, you can ensure consistent device naming based on specific attributes like UUIDs, serial numbers, or other unique identifiers.

Why Use Udev Rules?

  • Consistency: Persistent naming ensures that devices always appear with the same name across reboots.
  • Ease of Management: Custom names or symbolic links can make it easier to identify and manage devices.

Creating a Udev Rule

To create a udev rule, you need to create a new file in the /etc/udev/rules.d/ directory. The filename typically follows the convention NN-name.rules, where NN is a number determining the rule’s priority.

Example: Binding a Device by Serial Number

  1. Identify the Device: First, identify the unique attribute of your device. You can use udevadm to find this information:

udevadm info –query=all –name=/dev/sda | grep ID_SERIAL

Suppose the output is:

ID_SERIAL=3600508b400105e210000900000490000

  1. Create the Udev Rule: Create a file /etc/udev/rules.d/96-cjdevices.rules with the following content:

KERNEL==”sd*”, SUBSYSTEM==”block”, ENV{ID_SERIAL}==”3600508b400105e210000900000490000″, SYMLINK+=”cjdisk1″

  1. Reload Udev Rules: After creating the rule, reload the udev rules and trigger them:

sudo udevadm control –reload-rules

sudo udevadm trigger

  1. Verify the Symbolic Link: Check if the symbolic link has been created:

ls -l /dev/cjdisk1

Benefits and Considerations

  • Flexibility: Udev rules offer great flexibility in naming devices based on various attributes.
  • Manual Effort: Requires manual creation and maintenance of rules, especially in environments with many devices.

 

Multipath Configuration for Persistent Device Naming

Multipath I/O is used in environments where multiple physical paths to the same storage device are present. Multipathing aggregates these paths into a single logical device, improving redundancy and performance.

Why Use Multipath Configuration?

  • Redundancy: Provides failover capabilities in case one path fails.
  • Performance: Can improve performance by load balancing across multiple paths.
  • Consistency: Ensures consistent naming of multipath devices.

Configuring Multipath

  1. Install Multipath Tools: Ensure you have the necessary multipath tools installed.

Command for checking if multipath tool is available in your Linux server:

dpkg -l | grep multipath-tools # Debian/Ubuntu

rpm -qa | grep device-mapper-multipath   # CentOS/RHEL

If above command does not show output then you need to install the multipath package by running below commands:

sudo apt-get install multipath-tools  # Debian/Ubuntu

sudo yum install device-mapper-multipath  # CentOS/RHEL

  1. Edit the Configuration File: Edit /etc/multipath/multipath.conf to define your multipath devices. For example:

defaults {

user_friendly_names yes

}

 

multipaths {

multipath {

wwid 3600508b400105e210000900000490000

alias cjdisk1

}

}

  1. Restart the Multipath Service: Apply the configuration by restarting the multipath service:

sudo systemctl restart multipathd

  1. Verify the Multipath Device: Check the status of multipath devices:

sudo multipath -ll

Benefits and Considerations

  • High Availability: Essential for enterprise environments requiring high availability and performance.
  • Complexity: More complex to set up and manage compared to simple udev rules, but provides significant benefits in multipath environments.

 

Combining Udev and Multipath

In some cases, you may need to use both udev rules and multipath configuration to achieve your desired setup. For example, you can use multipath for managing multiple paths and udev rules for creating additional symbolic links.

Example

  1. Configure Multipath: As shown in the previous section.
  2. Create Udev Rule for Multipath Device: Add a rule in /etc/udev/rules.d/96-cjdevices.rules:

KERNEL==”dm-*”, SUBSYSTEM==”block”, ENV{DM_UUID}==”mpath-3600508b400105e210000900000490000″, SYMLINK+=”cjdisk1″

  1. Reload Udev Rules:

sudo udevadm control –reload-rules

sudo udevadm trigger

 

Wrap up!

Choosing between udev rules and multipath configuration depends on your specific needs:

  • Use udev rules for simple environments where you need persistent device names or symbolic links.
  • Use multipath configuration for environments with multiple physical paths to storage devices, requiring high availability and performance.

By understanding and implementing these methods, you can ensure consistent and reliable device naming in your Linux environment, tailored to your specific requirements.

Loading

  • Author
  • Recent Posts
Charanjit Singh
Follow him
Charanjit Singh
Charanjit is currently working as a Cloud Architect at Mphasis, with 18 years of experience in IT infrastructure projects, implementation, and support. While his main role is as a DevOps engineer, he holds a Cloud Architect position and has strong skills in cloud technologies and automation. His expertise includes Terraform, AWS, Azure DevOps, Azure Cloud, VMware, and Linux systems.

Charanjit is passionate about automating tasks and improving processes. He uses tools like Terraform and Azure DevOps to build and manage cloud infrastructure and streamline deployment. He also enjoys using Shell scripts and Ansible playbooks to make systems run more efficiently.

In his free time, Charanjit enjoys learning about new technologies and sharing his knowledge through his blog. When he’s not working, he likes listening to music, having a cup of coffee, and relaxing in nature.

You can connect with Charanjit on Twitter, Facebook, LinkedIn, or email him at charanjit.cheema@cjcheema.com.
Charanjit Singh
Follow him
Latest posts by Charanjit Singh (see all)
  • How to Deploy Docker Containers with NGINX on AWS EC2 Using Ansible and GitHub Actions - April 26, 2025
  • No More DynamoDB! Use Native S3 locking for Terraform State - February 7, 2025
  • How to Bring and Manage Manually Created AWS Resources Under Terraform Management - January 31, 2025

Like this:

Like Loading...

Related

Leave a ReplyCancel reply

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

Tags

AWS Cloud Computing Dockers Networking Open Networking OpenSource RHEL-CentOS SDN Server Hardware SLES tcpdump Ubuntu WSL

Follow me @

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2 other subscribers

Recent Posts

  • How to Deploy Docker Containers with NGINX on AWS EC2 Using Ansible and GitHub Actions
  • No More DynamoDB! Use Native S3 locking for Terraform State
  • How to Bring and Manage Manually Created AWS Resources Under Terraform Management
  • Iterating Cloud Resource Provisioning Using Terraform Count and For_Each Meta-Arguments
  • Terraform and Ansible Collaboration for AWS Cloud Deployment

Recent Comments

  1. Charanjit Singh on Terraform and Ansible Collaboration for AWS Cloud Deployment
  2. christinatodd2020aeaa798563 on Terraform and Ansible Collaboration for AWS Cloud Deployment
  3. Charanjit Singh on How to Set password policy in CentOS or RHEL system
  4. SAURABH on How to recover or rebuild initramfs in CentOS 7 Linux
  5. Sangita on How to Set password policy in CentOS or RHEL system

Archives

  • April 2025
  • February 2025
  • January 2025
  • August 2024
  • July 2024
  • June 2024
  • January 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • September 2022
  • August 2022
  • July 2020
  • May 2020
  • February 2020
  • November 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018

Categories

  • Automation
  • Cloud Computing
  • Coding
  • CyberSecurity
  • Networking
  • OpenSource
  • RHEL-CentOS
  • Server Hardware
  • SLES
  • Technical Blog
  • Ubuntu
  • WSL

Blog Stats

  • 18,353 hits
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
© 2025 Welcome To Charanjit Cheema Blog | Powered by Superbs Personal Blog theme
%d