Changeset 7923

Show
Ignore:
Timestamp:
02/17/07 16:30:52 (1 year ago)
Author:
bryan
Message:

Update CD symlinks section to use upstream rule_generator rules instead of generating our own. Fixes part of #1912.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/BOOK/chapter01/changelog.xml

    r7922 r7923  
    4141      <itemizedlist> 
    4242        <listitem> 
     43          <para>[bryan] - Change from writing CD symlink rules files directly 
     44          to configuring the file installed by Udev's rule_generator. Fixes 
     45          part of <ulink url="&lfs-ticket-root;1912">#1912</ulink>.</para> 
     46        </listitem> 
     47        <listitem> 
    4348          <para>[bryan] - Update contents of lfs-bootscripts.</para> 
    4449        </listitem> 
  • trunk/BOOK/chapter07/symlinks.xml

    r7854 r7923  
    1616 
    1717    <para>Some software that you may want to install later (e.g., various 
    18     media players) expect the /dev/cdrom and /dev/dvd symlinks to exist. 
    19     Also, it may be convenient to put references to those symlinks into 
    20     <filename>/etc/fstab</filename>. For each of your CD-ROM devices, 
    21     find the corresponding directory under 
     18    media players) expect the <filename class="symlink">/dev/cdrom</filename> 
     19    and <filename class="symlink">/dev/dvd</filename> symlinks to exist, and 
     20    to point to a CD-ROM or DVD-ROM device. Also, it may be convenient to put 
     21    references to those symlinks into <filename>/etc/fstab</filename>. Udev 
     22    comes with a script that will generate rules files to create these symlinks 
     23    for you, depending on the capabilities of each device, but you need to 
     24    decide which of two modes of operation you wish to have the script use.</para> 
     25 
     26    <para>First, the script can operate in <quote>by-path</quote> mode, where 
     27    the rules it creates depend on the physical path to the CD or DVD device. 
     28    Second, it can operate in <quote>by-id</quote> mode, where the rules it 
     29    creates depend on identification strings stored in the CD or DVD device 
     30    itself. The path is determined by Udev's <command>path_id</command> script, 
     31    and the identification strings are read from the hardware by its 
     32    <command>ata_id</command> or <command>scsi_id</command> programs, depending 
     33    on which type of device you have.</para> 
     34 
     35    <para>There are advantages to each approach; the correct approach to use 
     36    will depend on what kinds of device changes may happen. If you expect the 
     37    physical path to the device (that is, the ports and/or slots that it plugs 
     38    into) to change, for example because you plan on moving the drive to a 
     39    different IDE port or a different USB connector, then you should use the 
     40    <quote>by-id</quote> mode. On the other hand, if you expect the device's 
     41    identification to change, for example because it may die, and you would 
     42    replace it with a different device with the same capabilities and which 
     43    is plugged into the same connectors, then you should use the 
     44    <quote>by-path</quote> mode.</para> 
     45 
     46    <para>If either type of change is possible with your drive, then choose a 
     47    mode based on the type of change you expect to happen more often.</para> 
     48 
     49<!-- If you use by-id mode, the symlinks will survive even the transition 
     50     to libata for IDE drives, but that is not for the book. --> 
     51 
     52    <important>External devices (for example, a USB-connected CD drive) should 
     53    not use by-path persistence, because each time the device is plugged into a 
     54    new external port, its physical path will change. All externally-connected 
     55    devices will have this problem if you write Udev rules to recognize them 
     56    by their physical path; the problem is not limited to CD and DVD drives.</important> 
     57 
     58    <para>If you wish to see the values that the Udev scripts will use, then 
     59    for the appropriate CD-ROM device, find the corresponding directory under 
    2260    <filename class="directory">/sys</filename> (e.g., this can be 
    2361    <filename class="directory">/sys/block/hdd</filename>) and 
    2462    run a command similar to the following:</para> 
    2563 
    26 <screen role="nodump"><userinput>udevtest /block/hdd</userinput></screen> 
     64<screen role="nodump"><userinput>udevtest /sys/block/hdd</userinput></screen> 
    2765 
    28     <para>Look at the lines containing the output of various *_id programs.</para> 
     66    <para>Look at the lines containing the output of various *_id programs. 
     67    The <quote>by-id</quote> mode will use the ID_SERIAL value if it exists and 
     68    is not empty, otherwise it will use a combination of ID_MODEL and 
     69    ID_REVISION. The <quote>by-path</quote> mode will use the ID_PATH value.</para> 
    2970 
    30     <para>There are two approaches to creating symlinks. The first one is to 
    31     use the model name and the serial number, the second one is based on the 
    32     location of the device on the bus. If you are going to use the first 
    33     approach, create a file similar to the following:</para> 
     71    <para>If you choose the <quote>by-path</quote> mode, then the rules files 
     72    installed by default with Udev will work. If you choose the <quote>by-id</quote> 
     73    mode, then you will have to modify the 
     74    <filename>/etc/udev/rules.d/75-cd-aliases-generator.rules</filename> file, 
     75    as follows:</para> 
    3476 
    35 <screen role="nodump"><userinput>cat &gt; /etc/udev/rules.d/70-persistent-cd.rules &lt;&lt; EOF 
    36 <literal> 
    37 # Custom CD-ROM symlinks 
    38 SUBSYSTEM=="block", ENV{ID_MODEL}=="SAMSUNG_CD-ROM_SC-148F", \ 
    39     ENV{ID_REVISION}=="PS05", ENV{GENERATED}="1", SYMLINK+="cdrom" 
    40 SUBSYSTEM=="block", ENV{ID_MODEL}=="PHILIPS_CDD5301", \ 
    41     ENV{ID_SERIAL}=="5VO1306DM00190", ENV{GENERATED}="1", SYMLINK+="cdrom1 dvd" 
    42 </literal> 
    43 EOF</userinput></screen> 
     77<screen><userinput>sed -i -e 's/write_cd_aliases/&amp; by-id/' \ 
     78    /etc/udev/rules.d/75-cd-aliases-generator.rules</userinput></screen> 
    4479 
    45     <note> 
    46       <para>Be aware that Udev does not recognize the backslash for line 
    47       continuation.  The examples in this book work properly because both 
    48       the backslash and newline are ignored by the shell.  This makes the 
    49       shell send each rule to cat on only one line.  (The shell ignores 
    50       this sequence because the EOF string used in the here-document 
    51       redirection is not enclosed in either double or single quotes.  For 
    52       more details, see the bash(1) manpage, and search it for "Here 
    53       Documents".)</para> 
    54       <para>If modifying Udev rules with an editor, be sure to leave each 
    55       rule on one physical line.</para> 
    56     </note> 
    57  
    58     <para>This way, the symlinks will stay correct even if you move the drives 
    59     to different positions on the IDE bus, but the 
    60     <filename>/dev/cdrom</filename> symlink won't be created if you replace 
    61     the old SAMSUNG CD-ROM with a new drive.</para> 
    62 <!-- The symlinks in the first approach survive even the transition 
    63      to libata for IDE drives, but that is not for the book. --> 
    64  
    65     <para>The SUBSYSTEM==&quot;block&quot; key is needed in order to avoid 
    66     matching SCSI generic devices. Without it, in the case with SCSI 
    67     CD-ROMs, the symlinks will sometimes point to the correct 
    68     <filename>/dev/srX</filename> devices, and sometimes to 
    69     <filename>/dev/sgX</filename>, which is wrong.</para> 
    70  
    71     <para>The ENV{GENERATED}="1" key is needed to prevent the Udev 
    72     75-cd-aliases-generator.rules file from overriding your custom 
    73     rules.</para> 
    74  
    75     <para>The second approach yields:</para> 
    76  
    77 <screen role="nodump"><userinput>cat &gt; /etc/udev/rules.d/70-persistent-cd.rules &lt;&lt; EOF 
    78 <literal> 
    79 # Custom CD-ROM symlinks 
    80 SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", \ 
    81     ENV{ID_PATH}=="pci-0000:00:07.1-ide-0:1", \ 
    82     ENV{GENERATED}="1", SYMLINK+="cdrom" 
    83 SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", \ 
    84     ENV{ID_PATH}=="pci-0000:00:07.1-ide-1:1", \ 
    85     ENV{GENERATED}="1", SYMLINK+="cdrom1 dvd" 
    86 </literal> 
    87 EOF</userinput></screen> 
    88  
    89     <para>This way, the symlinks will stay correct even if you replace drives 
    90     with different models, but place them to the old positions on the IDE 
    91     bus. The ENV{ID_TYPE}==&quot;cd&quot; key makes sure that the symlink 
    92     disappears if you put something other than a CD-ROM in that position on 
    93     the bus.</para> 
    94  
    95     <para>Of course, it is possible to mix the two approaches.</para> 
     80    <para>Note that it is not necessary to create the rules files or symlinks 
     81    at this time, because you have bind-mounted the host's 
     82    <filename class="directory">/dev</filename> directory into the LFS system, 
     83    and we assume the symlinks exist and are correct on the host. The rules 
     84    will be created, along with the symlinks, the first time you boot your LFS 
     85    system.</para> 
    9686 
    9787  </sect2>