]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man/udevadm: add examples to get predictable interface name and persistent device... 36284/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 4 Feb 2025 04:26:25 +0000 (13:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Feb 2025 16:39:35 +0000 (01:39 +0900)
Closes #23661.

man/udevadm.xml

index c9e58e9cf57a787b722aa69110b3dcd4bbffd03d..4e1255bf4d67db4fbcb76521984c7d60e1d656c4 100644 (file)
       <optional><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></optional>
       </title>
 
-      <para>Simulate a udev event run for the given device, and print debug output.</para>
+      <para>
+        Simulate a udev event run for the given device, and print debug output. The option
+        <option>--json=</option> may be useful for parsing the final result. See also Example section.
+      </para>
 
       <variablelist>
         <varlistentry>
 
       <programlisting># udevadm lock -d /dev/sda1 dd if=fs.raw of=/dev/sda1</programlisting>
     </example>
+
+    <example>
+      <title>Predict Network Interface Renaming</title>
+
+      <para>To predict a network interface name, <command>udevadm test</command> can be used:</para>
+
+      <programlisting>$ udevadm test /sys/class/net/wlan0 --json=pretty 2>/dev/null | jq .networkInterface.name
+"wlp59s0"</programlisting>
+    </example>
+
+    <example>
+      <title>Predict Symbolic links of a Device Node</title>
+
+      <para>To predict symbolic links to a device node, <command>udevadm test</command> can be used:</para>
+
+      <programlisting>$ udevadm test /dev/nvme0n1p1 --json=pretty 2>/dev/null | jq .node.symlinks
+[
+  "/dev/disk/by-diskseq/1-part1",
+  "/dev/disk/by-id/nvme-WDC_PC_SN720_SDAQNTW-512G-1001_192290802247-part1",
+  "/dev/disk/by-id/nvme-WDC_PC_SN720_SDAQNTW-512G-1001_192290802247_1-part1",
+  "/dev/disk/by-id/nvme-eui.1922908022470001001b448b44ccb9d6-part1",
+  "/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part/by-partnum/1",
+  "/dev/disk/by-path/pci-0000:3c:00.0-nvme-1-part1"
+]
+$ udevadm test /dev/input/event3 --json=pretty 2>/dev/null | jq .node.symlinks
+[
+  "/dev/input/by-path/platform-i8042-serio-0-event-kbd"
+]</programlisting>
+    </example>
+
   </refsect1>
 
   <refsect1>