* Re: udev questions
2005-07-17 17:24 udev questions F. Heitkamp
@ 2005-07-17 18:49 ` Greg KH
2009-05-21 7:46 ` Alan Jenkins
2009-05-21 10:21 ` Alan Jenkins
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2005-07-17 18:49 UTC (permalink / raw)
To: linux-hotplug
On Sun, Jul 17, 2005 at 01:24:11PM -0400, F. Heitkamp wrote:
>
> I am trying to get udev working. I am using Linux kernel 2.6.12.2. I
> have a sort of my own "Linux from scratch" distro based on Debian. I am
> trying to get udev version 0.63 working.
>
> The most pressing question concerns the order and way the configuration
> files get read. I grepped through the sources but it is difficult to see
> which and which order the files get read. I've noticed on the fully
> Debian alternate set up on the same machine that there are "rules" files
> in the /etc/udev directory, but only one or so rules file in the rules.d
> directory. Can someone explain to me the hierarchy of the configuation
> files, which are essential, and what order they get read?
/etc/udev/udev.conf is the main config file. The rules file (or the
rules file directory) is specified in that file.
That's it :)
thanks,
greg k-h
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: udev questions
2005-07-17 17:24 udev questions F. Heitkamp
2005-07-17 18:49 ` Greg KH
@ 2009-05-21 7:46 ` Alan Jenkins
2009-05-21 10:21 ` Alan Jenkins
2 siblings, 0 replies; 4+ messages in thread
From: Alan Jenkins @ 2009-05-21 7:46 UTC (permalink / raw)
To: linux-hotplug
David A. Roth wrote:
> Hello Alan.
>
> I hope I have the right Alan Jenkins. I've seen your name while
> Googling regarding udev. If you aren't the right person, please
> forgive the error.
>
Well, you're not very specific about who you're looking for :-). I'm
not the maintainer, if that's what you mean.
You certainly have the wrong email address. I've CC'd linux-hotplug,
which is the mailing list for Udev.
> I have some udev questions and was wondering if you could shed any
> light on the problems I'm having. Here is a posting of mine to the
> CentOS forum concerning udev, udevinfo and udevtest.
>
> Thanks in advance,
>
> David A. Roth
> davidalanroth@gmail.com
>
> Background:
>
> I have two external USB drives (Maxtor and LaCie), and I want them to
> be assigned the same device at boot. /dev/sda for the Maxtor and
> /dev/sdb for the LaCie.
>
> With a default rules installation of CentOS 5.3 the LaCie gets
> assigned /dev/sda and the Maxtor /dev/sdb, which is the reverse order
> of what I want.
>
That sounds like a really bad idea.
> So it was suggested to me that I look into udev and write some rules.
> I looked at two web pages for help with udev being:
>
> http://www.axllent.org/docs/data_storage/udev_and_external_devices
> http://reactivated.net/writing_udev_rules.html
>
> I added the file 10-local.rules to /etc/udev/rules.d with these two lines:
>
> KERNEL="sd*",SYSFS{manufacturer}="Maxtor",NAME:="sda%n",SYMLINK+="usbmaxtor%n"
> KERNEL="sd*",SYSFS{manufacturer}="LaCie",NAME:="sdb%n",SYMLINK+="usblacie%n"
>
> After booting, a 'df' shows that sda and /dev/usbmaxtor is indeed
> assigned to the Maxtor.
>
> Problem:
>
> While the 'df' shows that the sda is assigned to the Maxtor
> (/dev/usbmaxtor), udevinfo -a -p /sys/block/sda indicated that sda is
> the LaCie drive. When doing dmesg, it has a remark that fsck should be
> run on sdb3, but sdb only has one partition of sdb1. It's the Maxtor
> which has sda3.
>
> Questions:
>
> Is the problem here with my rules statement above? If so, what do I
> need to change?
>
There's no way change the name printed in kernel messages (dmesg) or
under /sys. Udev only controls the name in /dev. (The exception is
networking devices, which don't appear in /dev; I think they can have
their kernel names changed). I hope that clears things up.
If you only use the links, it should be fine. Btw, if you don't mind
long link names, you may find udev already creates useful links under
/dev/disk/by-id/.
> I constructed the above from examples, but wasn't able to find
> documentation that goes into detail. For example, what is the
> different between NAME:= vs. NAME= ?
>
I think you're right that udev isn't comprehensively documented. But I
this particular one is covered in the manual page ("man udev"). ":="
assignment is final, and cannot be overridden by an assignment in a
subsequent rule.
Alan
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: udev questions
2005-07-17 17:24 udev questions F. Heitkamp
2005-07-17 18:49 ` Greg KH
2009-05-21 7:46 ` Alan Jenkins
@ 2009-05-21 10:21 ` Alan Jenkins
2 siblings, 0 replies; 4+ messages in thread
From: Alan Jenkins @ 2009-05-21 10:21 UTC (permalink / raw)
To: linux-hotplug
David A. Roth wrote:
> Hi Alan.
>
> Thanks very much for your kind and helpful reply. I wasn't aware of
> this mailing list you mentioned, thanks. Please see my comments
> below.
>
> On Thu, May 21, 2009 at 3:46 AM, Alan Jenkins
> <alan-jenkins@tuffmail.co.uk> wrote:
>
>> David A. Roth wrote:
>>
>>> Hello Alan.
>>>
>>> I hope I have the right Alan Jenkins. I've seen your name while
>>> Googling regarding udev. If you aren't the right person, please
>>> forgive the error.
>>>
>>>
>> Well, you're not very specific about who you're looking for :-). I'm not
>> the maintainer, if that's what you mean.
>> You certainly have the wrong email address. I've CC'd linux-hotplug, which
>> is the mailing list for Udev.
>>
>
> No, I saw a bunch of postings of yours with udev in them, figured
> you'd know more than most. :-)
>
>>> I have some udev questions and was wondering if you could shed any
>>> light on the problems I'm having. Here is a posting of mine to the
>>> CentOS forum concerning udev, udevinfo and udevtest.
>>>
>>> Thanks in advance,
>>>
>>> David A. Roth
>>> davidalanroth@gmail.com
>>>
>>> Background:
>>>
>>> I have two external USB drives (Maxtor and LaCie), and I want them to
>>> be assigned the same device at boot. /dev/sda for the Maxtor and
>>> /dev/sdb for the LaCie.
>>>
>>> With a default rules installation of CentOS 5.3 the LaCie gets
>>> assigned /dev/sda and the Maxtor /dev/sdb, which is the reverse order
>>> of what I want.
>>>
>>>
>> That sounds like a really bad idea.
>>
>>
>>> So it was suggested to me that I look into udev and write some rules.
>>> I looked at two web pages for help with udev being:
>>>
>>> http://www.axllent.org/docs/data_storage/udev_and_external_devices
>>> http://reactivated.net/writing_udev_rules.html
>>>
>>> I added the file 10-local.rules to /etc/udev/rules.d with these two lines:
>>>
>>>
>>> KERNEL="sd*",SYSFS{manufacturer}="Maxtor",NAME:="sda%n",SYMLINK+="usbmaxtor%n"
>>>
>>> KERNEL="sd*",SYSFS{manufacturer}="LaCie",NAME:="sdb%n",SYMLINK+="usblacie%n"
>>>
>>> After booting, a 'df' shows that sda and /dev/usbmaxtor is indeed
>>> assigned to the Maxtor.
>>>
>>> Problem:
>>>
>>> While the 'df' shows that the sda is assigned to the Maxtor
>>> (/dev/usbmaxtor), udevinfo -a -p /sys/block/sda indicated that sda is
>>> the LaCie drive. When doing dmesg, it has a remark that fsck should be
>>> run on sdb3, but sdb only has one partition of sdb1. It's the Maxtor
>>> which has sda3.
>>>
>>> Questions:
>>>
>>> Is the problem here with my rules statement above? If so, what do I
>>> need to change?
>>>
>>>
>> There's no way change the name printed in kernel messages (dmesg) or under
>> /sys. Udev only controls the name in /dev. (The exception is networking
>> devices, which don't appear in /dev; I think they can have their kernel
>> names changed). I hope that clears things up.
>>
>> If you only use the links, it should be fine. Btw, if you don't mind long
>> link names, you may find udev already creates useful links under
>> /dev/disk/by-id/.
>>
>
> I see, wow, that's great! I wasn't aware of that.
>
>>> I constructed the above from examples, but wasn't able to find
>>> documentation that goes into detail. For example, what is the
>>> different between NAME:= vs. NAME= ?
>>>
>>>
>> I think you're right that udev isn't comprehensively documented. But I this
>> particular one is covered in the manual page ("man udev"). ":=" assignment
>> is final, and cannot be overridden by an assignment in a subsequent rule.
>>
>
> Thanks again, Alan.
>
> After reviewing your reply, I believe this makes more sense to me. I
> shouldn't care if the drive is sda or sdb, since I should be
> referencing the symlink? In the past, I am use to doing backups and
> with rsync, for example and would mount /dev/sda3 to /mnt/maxtor, for
> example. After I adding the second USB external drive, sda was no
> longer the Maxtor drive but the Lacie. So I felt I needed to force the
> maxtor to always be sda in order for my scripts to work. My real goal,
> is that the correct drive and partition is being reference to it's
> ultimate mount point after boot time regardless of which drive is
> assigned to sda or sdb.
>
> Sounds like I should remove NAME:= altogether from the rules here so I
> shouldn't be forcing sda or sdb on the drives?
>
Yes, remove NAME:= and use symlinks.
I mentioned "by-id" since that was closest to what you were trying.
This is not word of god, but I would recommend trying "by-uuid" instead.
Modern distributions use links under "/dev/disk/by-uuid", which are
generated based on filesystem serial numbers. This has the advantage of
not hard-coding the partition number (or the device). The filesystem
UUID will remain stable even if you resize it or re-order the partition
table for some reason. You can generally expect UUIDs to be unique, so
long as you aren't copying raw parition images around.
You can use "ls -l /dev/disk/by-uuid" to see which UUID link corresponds
to the desired partition.
> Thanks in advance for allow me pester you. I will check out the
> mailing list you mentioned as well.
>
> Best regards,
>
> David
>
^ permalink raw reply [flat|nested] 4+ messages in thread