LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 02-17-2013, 06:26 AM   #1
Absolon
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Rep: Reputation: Disabled
UDEV: Persistent disk-name


Hello,

after I reinstalled the system my disks are not in order and that
makes a big problem for my raids. I've been reading up on UDEV,
but I can't find a way of making "sdd" in kernel to show up as
"sdb" for instance.

Can someone please help me?

/Paul

Running Gentoo and Udev v197
 
Old 02-17-2013, 10:24 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
Writing udev rules to force a particular drive ordering in the /dev/sd* namespace is moderately difficult and can run afoul of race conditions where udev is adjusting names while the kernel is still discovering drives and creating names in that same namespace. Can you build your RAID array using the names from /dev/disk/by-id/ ? Those names are formed from the drive model and serial number, and will not change.
 
Old 02-17-2013, 11:24 AM   #3
Absolon
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
Can you build your RAID array using the names from /dev/disk/by-id/ ? Those names are formed from the drive model and serial number, and will not change.
Yes, that is what I will do when I build a new one, but the current ones. It's 12 disks so I guess I have to start changing
cables back and forth. Thought that it could be a bit easier with a rule in UDEV since it's populating the /dev/sd* in the
persistant-block-device rule. If I look with ls -lR in disks I see the disks that are sorted by labels and UUID so I thought
that I could change it in the udev-rules since there are rules for it already?

The problem I have is that I don't really understand them. The documentation is poor and I've read posts with the same problem;
like someone putting in a usb-stick and boot and it enumerates it first etc.

There must be some way to populate the links through the udev, or not?
 
Old 02-17-2013, 01:58 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
The problem is that the kernel assigns a /dev/sd* name before udev starts processing the device. When you try to use a udev rule to swap two names, udev must first rename the first device to a temporary name, then rename the second device to it's intended name, then rename the temporary. Things get dicey if this is going on while the kernel is still discovering new devices and assigning names in that same namespace. If you want to avoid using the admittedly unwieldy /dev/disk/by-id/* names, you can write a udev rule that either creates a symlink or changes the name to something other than the "sd[a-z]" names the kernel is using, perhaps "sdx[a-z]". For example (untested):
Code:
KERNEL=="sd*[!0-9]", ENV{ID_SERIAL_SHORT}=="WD-WCAV54441182", symlink+=sdxa
KERNEL=="sd*[0-9]", ENV{ID_SERIAL_SHORT}=="WD-WCAV54441182", symlink+=sdxa%n
The first rule will take whatever sd[a-z] device has that serial number and give it a symlink "sdxa". The second rule does a similar action for all of that device's partitions. (Actually, I think the second rule alone should suffice by simply making the match: KERNEL=="sd*".) I suggest using "symlink+=" rather than forcing a name change with "NAME=" at least until you're sure you've got it right, lest you risk making your system unbootable.

When writing the udev rules, you can recognize the drive by any of its unique attributes, such as "ID_SERIAL_SHORT". To get a listing of all of a device's properties, run
Code:
udevadm info --query=property --name=/dev/sda
 
1 members found this post helpful.
Old 02-17-2013, 03:06 PM   #5
Absolon
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Ok, I didn't realize it was so complicated. I managed to assemble my 2 raids with mdadm, but the disks are not in order.

md1 : active raid5 sde1[4] sdb1[0] sdd1[2] sdc1[1]
8790402048 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md0 : active raid6 sdh1[2] sdj1[4] sdg1[1] sdf1[0] sdi1[3] sdk1[5]
7813527552 blocks super 1.2 level 6, 512k chunk, algorithm 2 [6/6] [UUUUUU]

It seems like they are working fine. I use dm-crypt on them but I don't know what will happen if I forget my usb-stick in the
machine since it seems like the usb-drive has precedence over SATA. If I plug it in after the bootup all is good, but that is
why I wanted to map a disk with its UUID to a /dev/sdX so it always would be the same. Guess I will have to set up through
UUID the next time I create a raid. The order that mdadm list the disks in worries me a bit especially if kernel decides to
enumerate them differently because of some hardware like the USB-port or my eSATA-card...

But this means that the disks etc that the kernel find en enumerate are static and I can only make symlinks to other names?
Wonder how it makes that decision when it traverse the disks?

Thank you for your reply!
 
Old 02-17-2013, 03:11 PM   #6
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,345

Rep: Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773
I thought that mdadm assembled RAIDs based upon the partition information on the disks? I know I've moved my RAID to another machine entirely and it just works without any modification. Surely mdadm won't try to add any partitions to the RAID that aren't marked as part of a RAID volume?
 
Old 02-17-2013, 03:23 PM   #7
Absolon
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
No, just that the order of the disks are 2,4,1,0,3,5. I hope that it's still ok, seems so, but I would rather have them 0-5 in order.

Since the only thing that I was to replace the systemdisk I didn't think it would rename my disks when I plugged them in after the
install. I even tried the old kernel but it was the same. I'm not a kernel-expert so I don't know how it decides what is what, but
it's kind of strange that it puts in the usb in the middle of it all if I forget to take it out etc. That is why I wanted and feel a
bit uneasy with the current display.

Maybe it's nitpicking but I want to know why it suddenly decides that a disk should be renamed to something else after a system
upgrade?
 
Old 02-17-2013, 03:31 PM   #8
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,345

Rep: Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773
I can well understand you being a bit uneasy especially when it's not clear why the system did it. I wouldn't worry too much but I can see why you'd like to know.
 
Old 02-17-2013, 03:37 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
It's just a matter of the order in which the drivers, all running in parallel, happen to detect the drives. The result is not necessarily repeatable, even with the same kernel booting on the same hardware.
 
Old 02-17-2013, 08:17 PM   #10
Absolon
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
I thought that it went throw the PCI-bus in order and then went and got the long pci-names (something like a Sun/Sparc) so it would be
the same all the time if it was on the same "number" but if you are saying that it is just picking the first disk this might very well
happen. Doesn't mean that I like it though. Would prefer thing to be consistent and have some repeatably


I was very happy and surprised that the assemble command worked so great in mdadm though!

I remembered now that I disconnected the "old" disk that I had placed on the last port on the motherboard (sdj) so the other
array should have shifted one step down. Now I'm not sure if I can plug in a new disk there in the future? Can I run mdadm assemble
again?

Sorry for all this questions; well it's @LinuxQuestions so maybe this IS the right place to ask them

Thank you!
 
  


Reply


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
reset/remove udev persistent-net-rules cccc Debian 3 06-29-2012 11:46 AM
cloning server, issue with udev 70-persistent-network drManhattan Linux - Server 1 06-18-2012 03:28 PM
correcting udev network persistent-net rules Skaperen Linux - Networking 2 09-19-2011 04:11 PM
cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or directory rcg1984 Linux From Scratch 2 09-17-2008 07:02 AM
Changing UDEV persistent naming schemes orbit Slackware 5 04-21-2008 09:22 PM


All times are GMT -5. The time now is 08:29 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration