7 Commits

Author SHA1 Message Date
9c22feadfa initramfs/initcpio: create MOUNT_FOLDER if it doesn't exist
/usr/lib/kdumpst/kdump-mkinitcpio-hook.sh is run by the kernel hook
when using mkinitcpio and a new kernel is installed.

If MOUNT_FOLDER does not exist it will fail with the following error
message:

==> ERROR: Invalid option -g -- '<MOUNT_FOLDER>/<IMG_FILE>' must be writable
2025-12-15 11:54:37 +01:00
92afdc48d6 initramfs: Effectively disable GPU drivers from kdump kernel
The gitlab issue https://gitlab.freedesktop.org/gpiccoli/kdumpst/-/issues/19
was first reported by Saurabh, regarding GPU drivers getting included on
the kdump initrd. We've managed to improve the code a bit, but the solution
we proposed there was both wrong (for initcpio) *and* incomplete.

The user Ethanell reopened the issue, mentioning that even after the
patch that allegedly fixed the problem, they were getting amdgpu driver
included in the kdump initrd. That was the "wrong" portion of the fix:
in my naivety, I thought we could just remove the modules in the kdump
install hook. But...happens that initcpio works with a lazy approach: some
install hooks execute add_module(), and that signals to the later effective
inclusion of the modules by mkinitcpio; so in other words, the kdump
install hook was deleting no modules at all.

Special thanks to Foxboron and noclaf for the discussion about that on
IRC, which was very enlightening.

Now, the proper approach is simple: just to skip hooks that add the GPU
drivers, like plymouth and kms. Also took the opportunity to include the
microcode hook in the ban list, since we don't want kernel updating CPU
ucode in case of the microcode packages were updated (would be rare, but
why not save a bit of space dropping that?). Finally, I've removed the
GPU drivers delete code from the initcpio kdump install hook, since it
was a nop in the end.

That's it, right? No. Still there's the part two of my statement above:
the prior approach was wrong, but not only, it was also *incomplete*. That
is due to cases like Ethanell's: users that manually include GPU drivers
in their initramfs images, for things like crypto or splash screen. It's
also hard or better saying, *impossible*, to guess all hooks that add GPU
drivers to the initramfs.

So to cover manual inclusions or other hooks, we also add hereby extra
kdump command-line flags to avoid the DRM and some GFX drivers probe
during the kdump kernel boot. In order to not grow the drivers ban list
too much, my attempt was to add common in-tree GPU drivers, but also block
the DRM init call. Hopefully this time this is enough to disable GFX on kdump!

Fixes: 4767b8095f ("initramfs: Fix the removal of GPU drivers from the minimal initrd")
Reported-by: Ethanell (@flifloo)
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2024-08-08 10:17:18 -03:00
4767b8095f initramfs: Fix the removal of GPU drivers from the minimal initrd
Thanks to the great report from Saurabh Charde, we noticed that the
removal command used in the minimal initrd creation for deleting the
GPU/DRM drivers wasn't working. Fix that so now GPU drivers aren't
included for real (both for space and boot "issue-prone" criteria).

Closes: https://gitlab.freedesktop.org/gpiccoli/kdumpst/-/issues/19
Reported-by: Saurabh Charde (@schardev)
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2024-05-06 15:20:38 -03:00
c83ad9a83e initramfs/initcpio: Fix minimal initrd creation
Due to a brainfart, forgot the "-k" modifier on mkinitcpio call. It
happened to work by coincidence - without this flag, "uname -r" was
used and worked most of times, but that's clearly a bug.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2024-01-05 17:08:16 -03:00
acd5a64652 all: Add LICENSE (and fix SPDX deprecated header)
Thanks to the heads-up from Foxboron (on Arch Linux IRC channel)
add hereby a LICENSE file to the project that matches the SPDX
headers. While at it, fix the SPDX short identifier on headers,
that was deprecated (as per [0]).

The license file was a pure copy obtained today from [1].

[0] https://spdx.org/licenses/LGPL-2.1+.html
[1] https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2023-04-02 12:26:00 -03:00
4b5746a60e all: Rename the tool to kdumpst
Big but self-explanatory commit: rename the tool. The name choice was
kdumpst, since it's a tool to enable both kdump and pstore setting, also
it's a silly wordplay with the superlative of kdump, as in "kdumpest".

It's an invasive change (touches most of the files), but should
offer no functional change other than logging messages showing
kdumpst now, instead of kdump, and some filenames.

Notice it doesn't touch documentation, which will be done in
a subsequent commit.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2023-03-31 15:34:42 -03:00
b834754cf9 initramfs: Switch to the alpm-hooks approach, supporting both initcpio/dracut
This is one of the major changes/refactors so far, touches a lot of
files, and more important, it completely changes some premises.
With this patch, we now support fully both dracut-based and initcpio
initramfs systems.

For that to happen, we needed to decouple the initramfs creation from
scripts, by using alpm-hooks. These hooks allow scripts to be run on
events like kernel package installation or in the installation of the very
package responsible to create the initramfs image. We still have the
"kdump-load create-initrd" command though.

One of the biggest modifications here was in the Makefile, that now
composes multiple files by changing keywords (like INITRD) to the
respective initramfs system (dracut or mkinitcpio). Notice that this
brought some extra complexity to the package.

The logic used for supporting both initramfs systems was basically
de-duplicate all possible code (having dup code in common files),
using Makefile tricks to merge such files and have the unique
bits in dracut/initcpio specific files. We currently support dracut
and both mkinitcpio and mkinitcpio-git packages.

Caveats: currently the initramfs specific package removal is not handled
here. So, if the user has dracut and installs kdump, we install the
dracut hooks. In case this user decides to remove dracut and installs
mkinitcpio, we install the mkinitcpio hooks and all should work, but
the previous dracut hooks installed are not unistalled by us; likely
the dracut package removal would drop the files itself.

This was a deliberate move to avoid even more alpm-hooks, should be
a rare case and as said, the package removal should clear the files
itself, without requiring our interaction. Also, by using the
alpm-hooks, we see "errors" (warnings really) about the other
initramfs package not being present - not sure if it's possible to
disable this behavior.

Finally, while at it:

* Added a new approach to dracut initramfs creation to pick the most
common block drivers - since it's hostonly, it doesn't add the ones
that aren't loaded, hence image is not bloated by that.

* Chenged the "command -v makedumpfile" validation to something
more elegant - thanks for the suggestion Clayton (@craftyguy).

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2023-03-31 15:34:42 -03:00