`kdump-config load` calls `kdump_create_symlinks()` checks whether
`$KDUMP_DIR/initrd.img-${kernel_version}` exists. When it does not
(because we deleted it), it executes `$KDUMP_KERNEL_HOOK
"$kernel_version"`, which resolves to /etc/kernel/postinst.d/kdump-
tools.

The postinst hook (/etc/kernel/postinst.d/kdump-tools) overrides the
default MODULES=most with MODULES=dep to produce a smaller initramfs.

```
if test "${MODULES-most}" = most; then
    # Switch from "most" to "dep" to reduce the size of the initramfs.
    # "netboot" and "list" are expected to be already small enough.
    KDUMP_MODULES=dep
fi
```
It then invokes mkinitramfs with the custom config directory 
/var/lib/kdump/initramfs-tools.

When MODULES=dep is active, mkinitramfs calls `dep_add_modules()` in
/usr/share/initramfs-tools/hook-functions, which probes the live
system's sysfs to discover which kernel modules are needed, rather than
including a static set.

`dep_add_modules()` calls `dep_add_modules_mount()` for / and /usr. That
function resolves the root block device and calls `block_dev_mod_add()`,
which calls `block_dev_sys_walk_mod_add()`, which calls
`sys_walk_mod_add()`.

sys_walk_mod_add() takes a sysfs device path (e.g., 
/sys/devices/css0/.../block/sdd) and walks up the entire hierarchy using 
dirname, collecting every ancestor path up to /sys. It then iterates over all 
collected paths and executes:
```
driver_path="$(readlink -f "${device_path}/driver/module")"
```

Most intermediate sysfs nodes have no driver/module symlink.
The code correctly handles the missing case in the following line with an 
existence check:
```
driver_path="$(readlink -f "${device_path}/driver/module")"
if [ -e "$driver_path" ]; then
```
but the initial readlink call does not suppress stderr.
Every nonexistent path produces a "No such file or directory" message.

Moreover `dep_add_modules()` iterates over device classes:
```
# sys walk some important device classes 
for class in extcon gpio phy pwm regulator rtc; do 
    class_add_modules "$class"
done
```
`class_add_modules()` then iterates over /sys/class/$1/*.
On s390x, the classes extcon, phy, pwm, regulator, and rtc do not exist.
The shell glob `/sys/class/extcon/*` is passed literally to readlink,
which fails with "No such file or directory".

** No longer affects: kdump-tools (Ubuntu)

** Also affects: initramfs-tools (Ubuntu)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2142878

Title:
  While upgrading to kernel 7.0.0-2.2 on resolute snapshot4, I am seeing
  several readlink msg

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/2142878/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to