RFC: new/changed udev rules - Part 1

Alexander E. Patrakov patrakov at ums.usu.ru
Sun May 14 20:39:45 PDT 2006

Jim Gifford wrote:
> Alexander E. Patrakov wrote:
>> NAK: racy. The helper script assumes that new devices don't appear in 
>> /sys during operation.
> So far in the testing we have had done, no issues have come up, we have 
> tried it with older hardware along with newer hardware.

Testing alone is insufficient. All scripts must be mathematically proved when it 
is possible.

> So far my system that has 4 ide cd drives and 4 scsi devices, hasn't 
> seen any problems. From what I can see there has to be some way in sysfs 
> that we can use instead of using the Debian method, which something 
> about that script bugs me(a script that writes rules for itself doesn't 
> seem right to me)

Think about this: udev processes uevents in _random_ order. Thus, to ensure that 
each "cdromX" symlink will always point to the same drive, some on-disk database 
has to be invented. A natural form of this database is a file with generated rules.

And this is not Debian-specific, Mandriva also does this, and not only for CD-ROMs.

However, bugs are being reported against the script, see, e.g., 
http://bugs.debian.org/367265 (was never present in LFS, because I modified the 
Debian script by adding ENV{ID_CDROM}=="1" to all rules). And the script is 
definitely too complex and uneducational.

Moreover, invalid bugs like the following will certainly be filed:

The CD symlinks are wrong on my LFS system:

/dev/cdrom -> sr1
/dev/cdrom1 -> sr0

On the host (that doesn't use udev or uses old udev), the order is natural:

/dev/cdrom -> sr0
/dev/cdrom1 -> sr1

so the bug is somewhere in your book.

(that's just because the uevent for sr1 happened to be processed before sr0 on 
the reporter's [aka: my] system)

So I propose to ditch the script from LFS and optionally move it to BLFS or to a 
hint. LFS should provide readers with instructions to create the relevant rules 

# Begin 82-persistent-cd.rules

# SAMSUNG_CD-ROM_SC-148F (pci-0000:00:07.1-ide-0:1)
ACTION=="add", BUS=="ide", ID=="0.1", SYMLINK+="cdrom"
# PHILIPS_CDD5301 (pci-0000:00:07.1-ide-1:1)
ACTION=="add", BUS=="ide", ID=="1.1", SYMLINK+="cdrom1"
ACTION=="add", BUS=="ide", ID=="1.1", SYMLINK+="cdrw1"
ACTION=="add", BUS=="ide", ID=="1.1", SYMLINK+="dvd1"

# End 82-persistent-cd.rules

Alexander E. Patrakov

More information about the lfs-dev mailing list