From 84dbfdac1d61fe44174367240f3847ef4b1bad9e Mon Sep 17 00:00:00 2001 From: Bryan Kadzban Date: Sat, 17 Feb 2007 23:30:52 +0000 Subject: Update CD symlinks section to use upstream rule_generator rules instead of generating our own. Fixes part of #1912. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7923 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter07/symlinks.xml | 130 +++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 70 deletions(-) (limited to 'chapter07') diff --git a/chapter07/symlinks.xml b/chapter07/symlinks.xml index f3c4b17c5..ff96b4e87 100644 --- a/chapter07/symlinks.xml +++ b/chapter07/symlinks.xml @@ -15,84 +15,74 @@ CD-ROM symlinks Some software that you may want to install later (e.g., various - media players) expect the /dev/cdrom and /dev/dvd symlinks to exist. - Also, it may be convenient to put references to those symlinks into - /etc/fstab. For each of your CD-ROM devices, - find the corresponding directory under + media players) expect the /dev/cdrom + and /dev/dvd symlinks to exist, and + to point to a CD-ROM or DVD-ROM device. Also, it may be convenient to put + references to those symlinks into /etc/fstab. Udev + comes with a script that will generate rules files to create these symlinks + for you, depending on the capabilities of each device, but you need to + decide which of two modes of operation you wish to have the script use. + + First, the script can operate in by-path mode, where + the rules it creates depend on the physical path to the CD or DVD device. + Second, it can operate in by-id mode, where the rules it + creates depend on identification strings stored in the CD or DVD device + itself. The path is determined by Udev's path_id script, + and the identification strings are read from the hardware by its + ata_id or scsi_id programs, depending + on which type of device you have. + + There are advantages to each approach; the correct approach to use + will depend on what kinds of device changes may happen. If you expect the + physical path to the device (that is, the ports and/or slots that it plugs + into) to change, for example because you plan on moving the drive to a + different IDE port or a different USB connector, then you should use the + by-id mode. On the other hand, if you expect the device's + identification to change, for example because it may die, and you would + replace it with a different device with the same capabilities and which + is plugged into the same connectors, then you should use the + by-path mode. + + If either type of change is possible with your drive, then choose a + mode based on the type of change you expect to happen more often. + + + + External devices (for example, a USB-connected CD drive) should + not use by-path persistence, because each time the device is plugged into a + new external port, its physical path will change. All externally-connected + devices will have this problem if you write Udev rules to recognize them + by their physical path; the problem is not limited to CD and DVD drives. + + If you wish to see the values that the Udev scripts will use, then + for the appropriate CD-ROM device, find the corresponding directory under /sys (e.g., this can be /sys/block/hdd) and run a command similar to the following: -udevtest /block/hdd - - Look at the lines containing the output of various *_id programs. +udevtest /sys/block/hdd - There are two approaches to creating symlinks. The first one is to - use the model name and the serial number, the second one is based on the - location of the device on the bus. If you are going to use the first - approach, create a file similar to the following: - -cat > /etc/udev/rules.d/70-persistent-cd.rules << EOF - -# Custom CD-ROM symlinks -SUBSYSTEM=="block", ENV{ID_MODEL}=="SAMSUNG_CD-ROM_SC-148F", \ - ENV{ID_REVISION}=="PS05", ENV{GENERATED}="1", SYMLINK+="cdrom" -SUBSYSTEM=="block", ENV{ID_MODEL}=="PHILIPS_CDD5301", \ - ENV{ID_SERIAL}=="5VO1306DM00190", ENV{GENERATED}="1", SYMLINK+="cdrom1 dvd" - -EOF + Look at the lines containing the output of various *_id programs. + The by-id mode will use the ID_SERIAL value if it exists and + is not empty, otherwise it will use a combination of ID_MODEL and + ID_REVISION. The by-path mode will use the ID_PATH value. - - Be aware that Udev does not recognize the backslash for line - continuation. The examples in this book work properly because both - the backslash and newline are ignored by the shell. This makes the - shell send each rule to cat on only one line. (The shell ignores - this sequence because the EOF string used in the here-document - redirection is not enclosed in either double or single quotes. For - more details, see the bash(1) manpage, and search it for "Here - Documents".) - If modifying Udev rules with an editor, be sure to leave each - rule on one physical line. - - - This way, the symlinks will stay correct even if you move the drives - to different positions on the IDE bus, but the - /dev/cdrom symlink won't be created if you replace - the old SAMSUNG CD-ROM with a new drive. - - - The SUBSYSTEM=="block" key is needed in order to avoid - matching SCSI generic devices. Without it, in the case with SCSI - CD-ROMs, the symlinks will sometimes point to the correct - /dev/srX devices, and sometimes to - /dev/sgX, which is wrong. - - The ENV{GENERATED}="1" key is needed to prevent the Udev - 75-cd-aliases-generator.rules file from overriding your custom - rules. - - The second approach yields: - -cat > /etc/udev/rules.d/70-persistent-cd.rules << EOF - -# Custom CD-ROM symlinks -SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", \ - ENV{ID_PATH}=="pci-0000:00:07.1-ide-0:1", \ - ENV{GENERATED}="1", SYMLINK+="cdrom" -SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", \ - ENV{ID_PATH}=="pci-0000:00:07.1-ide-1:1", \ - ENV{GENERATED}="1", SYMLINK+="cdrom1 dvd" - -EOF + If you choose the by-path mode, then the rules files + installed by default with Udev will work. If you choose the by-id + mode, then you will have to modify the + /etc/udev/rules.d/75-cd-aliases-generator.rules file, + as follows: - This way, the symlinks will stay correct even if you replace drives - with different models, but place them to the old positions on the IDE - bus. The ENV{ID_TYPE}=="cd" key makes sure that the symlink - disappears if you put something other than a CD-ROM in that position on - the bus. +sed -i -e 's/write_cd_aliases/& by-id/' \ + /etc/udev/rules.d/75-cd-aliases-generator.rules - Of course, it is possible to mix the two approaches. + Note that it is not necessary to create the rules files or symlinks + at this time, because you have bind-mounted the host's + /dev directory into the LFS system, + and we assume the symlinks exist and are correct on the host. The rules + will be created, along with the symlinks, the first time you boot your LFS + system. -- cgit v1.2.3-54-g00ecf