So how do you assign static names for SCSI device using udev under Linux? Simply use the scsi_id and other udev tools such as :
[b] udev_start – script to initialize /dev by using udev
[c] udevtest – simulate a udev run and print the action to the console.
What the hell is udev?
udev is the device manager for the Linux 2.6 kernel series. Its primary function is managing device nodes in /dev. Old UNIX system creates device in the /dev with static files. udev dynamically provides only the nodes for the devices actually present on a system.
Note following configuration is only tested on Gentoo / RHEL 5.x / CentOS 5.x Linux server systems but it should work with other distros with udev support.
Step # 1: Get WWID of the SCSI device
To get the WWID of /dev/sdd, type:
# scsi_id -g -u -s /block/sdd
Where,
- -g : Treat the device as white listed
- -u : Reformat the output
- -s /bock/sdd : Generate an id for the /block/sdd (/dev/sdd). The mount point must not be included. For example, use /block/sdd, not /sys/block/sdd.
Step # 2: Create /etc/udev/rules.d/25-names.rules file
Open /etc/udev/rules.d/25-names.rules and append following text (replace WWID with actual id obtained from above command):
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="WWID", SYMLINK+="scsiharddisk%n"
Above rule will create /dev/scsiharddisk (a symlink – select any other meaningful name as per your proecjet ) for the SCSI device with a given WWID. Please note that partitions on this device will be assigned the device names like /dev/scsiharddisk1, /dev/scsiharddisk2 and so on. Next, verify that everything is correct order, enter:
# udevtest
Start initialize /dev for new devices:
# start_udev
Verify symbolic links are created, enter:
# ls -l /dev/scsiharddisk*
Read the man pages for more information:
man scsi_id
man udevtest
man 7 udev
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
how can I assign a name to a slot?
Thank you. My computer has been failing to boot half the time ever since I installed my third hard drive. This advice took care of the problem!
FYI, on Fedora Core 13, the command
scsi_id -g -u -s /block/sdd
is
scsi_id –whitelisted –replace-whitespace –device=/block/sdd