Changeset bf58c1e for chapter07/symlinks.xml
- Timestamp:
- 04/21/2014 09:44:04 PM (10 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 5af3f9e
- Parents:
- c65dd23e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/symlinks.xml
rc65dd23e rbf58c1e 9 9 <?dbhtml filename="symlinks.html"?> 10 10 11 <title>Creating Custom Symlinks to Devices</title> 11 <title>Managing Devices</title> 12 13 <sect2> 14 15 <title>Network Devices</title> 16 17 <para>Udev, by default, names network devices according to Firmware/BIOS 18 data or physical characteristics like the bus, slot, or MAC address. The 19 purpose of this naming convention is to ensure that network devices are 20 named consistently and not based on the time the network card was 21 discovered. For example, on a computer having two network cards made by 22 Intel and Realtek, the network card manufactured by Intel may become eth0 23 and the Realtek card becomes eth1. In some cases, after a reboot the cards 24 get renumbered the other way around.</para> 25 26 <para>In the new naming scheme, typical network device names would then 27 be something like enp5s0 or wlp3s0. If this naming convention is not 28 desired, the traditional naming scheme or a custom scheme can be 29 implemented.</para> 30 31 <sect3> 32 <title>Disabling Persistent Naming on the Kernel Command Line</title> 33 34 <para>The traditional naming scheme using eth0, eth1, etc can be 35 restored by adding <userinput>net.ifnames=0</userinput> on the 36 kernel command line. This is most appropriate for those systems 37 that have only one ethernet device of the same type. Laptops 38 often have multiple ethernet connections that are named eth0 and 39 wlan0 and are also candidates for this method. The command line 40 is passed in the GRUB configuration file. 41 See <xref linkend="grub-cfg"/>.</para> 42 </sect3> 43 44 <sect3> 45 <title>Creating Custom Udev Rules</title> 46 47 <para>The naming scheme can be customized by creating custom Udev 48 rules. A script has been included that generates the initial rules. 49 Generate these rules by running:</para> 50 51 <screen role="nodump"><userinput>bash /lib/udev/init-net-rules.sh</userinput></screen> 52 53 <para> Now, inspect th 54 <filename>/etc/udev/rules.d/70-persistent-net.rules</filename> file, to 55 find out which name was assigned to which network device:</para> 56 57 <screen role="nodump"><userinput>cat /etc/udev/rules.d/70-persistent-net.rules</userinput></screen> 58 59 <note><para>In some cases such as when MAC addresess have been assigned to 60 a network card manually or in a virtual environment such as Qemu or Xen, 61 the network rules file may not have been generated because addresses 62 are not consistently assigned. In these cases, this method cannot 63 be used.</para></note> 64 65 <para>The file begins with a comment block followed by two lines for each 66 NIC. The first line for each NIC is a commented description showing its 67 hardware IDs (e.g. its PCI vendor and device IDs, if it's a PCI card), 68 along with its driver in parentheses, if the driver can be found. Neither 69 the hardware ID nor the driver is used to determine which name to give an 70 interface; this information is only for reference. The second line is the 71 Udev rule that matches this NIC and actually assigns it a name.</para> 72 73 <para>All Udev rules are made up of several keys, separated by commas and 74 optional whitespace. This rule's keys and an explanation of each of them 75 are as follows:</para> 76 77 <itemizedlist> 78 <listitem> 79 <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore 80 devices that are not network cards.</para> 81 </listitem> 82 <listitem> 83 <para><literal>ACTION=="add"</literal> - This tells Udev to ignore this 84 rule for a uevent that isn't an add ("remove" and "change" uevents also 85 happen, but don't need to rename network interfaces).</para> 86 </listitem> 87 <listitem> 88 <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will 89 ignore VLAN or bridge sub-interfaces (because these sub-interfaces do 90 not have drivers). These sub-interfaces are skipped because the name 91 that would be assigned would collide with their parent devices.</para> 92 </listitem> 93 <listitem> 94 <para><literal>ATTR{address}</literal> - The value of this key is the 95 NIC's MAC address.</para> 96 </listitem> 97 <listitem> 98 <para><literal>ATTR{type}=="1"</literal> - This ensures the rule only 99 matches the primary interface in the case of certain wireless drivers, 100 which create multiple virtual interfaces. The secondary interfaces are 101 skipped for the same reason that VLAN and bridge sub-interfaces are 102 skipped: there would be a name collision otherwise.</para> 103 </listitem> 104 <listitem> 105 <para><literal>NAME</literal> - The value of this key is the name that 106 Udev will assign to this interface.</para> 107 </listitem> 108 </itemizedlist> 109 110 <para>The value of <literal>NAME</literal> is the important part. Make sure 111 you know which name has been assigned to each of your network cards before 112 proceeding, and be sure to use that <literal>NAME</literal> value when 113 creating your configuration files below.</para> 114 115 </sect3> 116 117 <sect3> 118 <title>Custom Naming in Systemd</title> 119 120 <para>Network interface names can also be customized with a set of 121 files spcific to systemd. A file with a name such as 10-eth0.link 122 in the /etc/systemd/network directory can set an interface name. All 123 files in the directory will be applied in lexical order. Files 124 in the /lib/systemd/network directory with the same name as those 125 in /etc/systemd/network will be overridden. See the man page 126 for systemd.link for a full explanation.</para> 127 128 <para>An example file looks like:</para> 129 130 <screen role="nodump">[Match] 131 MACAddress=12:34:56:78:9a:bc 132 Driver=brcmsmac 133 Path=pci-0000:02:00.0-* 134 Type=wlan 135 Virtualization=no 136 Host=my-laptop 137 Architecture=x86-64 138 139 [Link] 140 Name=wireless0 141 MTUBytes=1450 142 BitsPerSecond=10M 143 WakeOnLan=magic 144 MACAddress=cb:a9:87:65:43:21</screen> 145 146 <para>The [Match] section specifies when to apply the rule. In 147 the example above, the entries can be shortened to the minimum 148 needed to uniquely identify the network device. Similarly, 149 the [Link] section only needs to specify the changes from the 150 default that are desired. In many cases, the only thing needed is 151 the Name entry.</para> 152 153 </sect3> 154 155 </sect2> 12 156 13 157 <sect2> … … 109 253 after a reboot the order changes to the opposite one. 110 254 For all classes of hardware except sound cards and network cards, this is 111 fixable by creating udev rules for custom persistent symlinks.255 fixable by creating Udev rules for custom persistent symlinks. 112 256 The case of network cards is covered separately in 113 257 <xref linkend="ch-scripts-network"/>, and sound card configuration can
Note:
See TracChangeset
for help on using the changeset viewer.