LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-08-2009, 02:53 AM   #1
TheR_
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Rep: Reputation: 0
Help on naming iscsi devices with udev


I don't like the idea when iscsi drives are attached on target system,
devices get names /dev/sdb, /dev/sdc. In virtual environment you get
easly 100 targets and how about when I don't need that LUN 26 on drive
iqn.2100-05.ozs.si:disks.sas anymore. Will my device /dev/sdbb still
be there or will it be at /dev/sdba. And it is ugly anyway.

Partial solution can be found in /dev/disk/by-path/ where device is
assigned by iscsi server name and lun.
ip-192.168.1.221:3260-iscsi-iqn.2100-05.si.ozs:diski.sas-lun-0
ip-192.168.1.221:3260-iscsi-iqn.2100-05.si.ozs:diski.sas-lun-0-part1
ip-192.168.1.221:3260-iscsi-iqn.2100-05.si.ozs:diski.sas-lun-0-part2
But this is ugly too. And doesn't tell much about what does one device
contain.

On iscsi server I have LVM with logical volume names like wwwportal,
dns1, dns2, windowsAD ..... and what I would like is name devices on
target with similar names /dev/iscsi/wwwportal, /dev/iscsi/dns1 .....
and the same way I will also name my KVM machines.

I know it can be done with udev rule calling extern script which would
have to include some kind of conversion table which would return name
for disk and lun. I also know that table must be edited each time new
disk is added. But that is just about everything I know.

Can you help me with this please.
1. udev rule and into which file to put it
2. skeleton of shell script which would be called by rule

by
TheR
 
Old 09-09-2009, 07:46 AM   #2
TheR_
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Since nobody got nothing I am asking you what do you think of this solution. I still have lots of testing to do, but so far it works:

1. I have created /etc/iscsi/persistent.names.conf. It looks like this:

iqn.2100-05.si.ozs:diski.sas;0;iscsi/win_portal
iqn.2100-05.si.ozs:diski.sas;1;iscsi/dns1
iqn.2100-05.si.ozs:diski.sas;2;iscsi/dns2


2. I have created /etc/udev/rules.d/60-persistent-iscsi.rules. It looks like this:

# This file maintains persistent names for iscsi disks.

ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{program}="path_id %p"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", PROGRAM="/usr/bin/persistent_iscsi.rb $env{ID_PATH}", SYMLINK+="%c"


3. And finaly I have created this Ruby script, since I do almost all my programing in Ruby.

#!/usr/bin/ruby

# id looks like this: ip-192.168.1.221:3260-iscsi-iqn.2100-05.si.ozs:diski.sas-lun-0
device = nil
id = ARGV.first
# parse id on - sign
a = id.split('-')
# get lun and iqn
id_iqn = a[3] + '-' + a[4]
id_lun = a[6]
# third part should be iscsi
exit 1 unless a[2] == 'iscsi'
# read my configuration file /etc/iscsi/persistent.names.conf
File.new('/etc/iscsi/persistent.names.conf').readlines.each do |line|
# config line looks like this: iqn.2100-05.si.ozs:diski.sas;2;iscsi/dns1
iqn, lun, dev = line.chomp.split(';')
if iqn == id_iqn and lun == id_lun
device = dev
break
end
end
# Error if not found
exit 1 if device.nil?
# out device name on stdout
puts device



by
TheR

Last edited by TheR_; 09-09-2009 at 07:51 AM.
 
  


Reply

Tags
iscsi, udev rules


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
udev rule failing to create iscsi symlinks! patrarch Linux - Newbie 2 10-21-2021 01:01 PM
Hotswap and udev persisten naming Thure Linux - Server 3 01-26-2009 06:41 AM
Changing UDEV persistent naming schemes orbit Slackware 5 04-21-2008 09:22 PM
udev rule failing to create iscsi symlinks patrarch Linux - Networking 1 11-29-2007 01:41 AM
iSCSI, LUN, and devices gmex Linux - Software 3 09-22-2007 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration