From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev questions
Date: Thu, 21 May 2009 10:21:13 +0000 [thread overview]
Message-ID: <4A152B19.9020608@tuffmail.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.60.0507171252510.21434@pc1lin.fred.org>
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
>
prev parent reply other threads:[~2009-05-21 10:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A152B19.9020608@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).