saber-nyan / kernel-modules-hook Goto Github PK
View Code? Open in Web Editor NEWKeeps your Arch Linux fully functional after a kernel upgrade
License: The Unlicense
Keeps your Arch Linux fully functional after a kernel upgrade
License: The Unlicense
Not very significant since /lib
is a link to /usr/lib
, but I think it would be better to use /usr/lib
.
This does not work with selinux.
If I upgrade the kernel it is just stuck on Saving Linux kernel modules...
. If I there is some rsync stacktrace about selinux errors.
Realized old modules were junking up my system and that this service was not activated. Tried to start it manually which resulted in the following error. Confused by this since I thought check if a package owned the module was kind of the point of this script?
Oct 28 00:26:31 cole-pc systemd[1]: Starting Clean up modules from old kernels... Oct 28 00:26:31 cole-pc bash[103383]: + for i in /usr/lib/modules/[0-9]* Oct 28 00:26:31 cole-pc bash[103383]: + [[ 5.11.15-arch1-2 = \6\.\0\.\2\-\a\r\c\h\1\-\1 ]] Oct 28 00:26:31 cole-pc bash[103383]: + pacman -Qo /usr/lib/modules/5.11.15-arch1-2 Oct 28 00:26:31 cole-pc bash[103456]: error: No package owns /usr/lib/modules/5.11.15-arch1-2 Oct 28 00:26:31 cole-pc bash[103383]: + rsync -AHXal /usr/lib/modules/5.11.15-arch1-2 /usr/lib/modules/.old/ Oct 28 00:26:31 cole-pc bash[103688]: rsync: [Receiver] ERROR: cannot stat destination "/usr/lib/modules/.old/": Not a directory (20) Oct 28 00:26:31 cole-pc bash[103688]: rsync error: errors selecting input/output files, dirs (code 3) at main.c(770) [Receiver=3.2.7] Oct 28 00:26:31 cole-pc systemd[1]: linux-modules-cleanup.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Oct 28 00:26:32 cole-pc systemd[1]: linux-modules-cleanup.service: Failed with result 'exit-code'. Oct 28 00:26:32 cole-pc systemd[1]: Failed to start Clean up modules from old kernels.
Please add linux-mainline to the packages that this hook is executed on or another way where the linux-mainline kernel modules are backed up too, before an update, and restored afterwards.
hi! :D
there are currently no releases, any chance you could just tag the current master with 0.1.8
or similar? That would make it easier to package downstream.
Thanks!
Is this affected by https://www.archlinux.org/news/new-kernel-packages-and-mkinitcpio-hooks/
I am not well-versed in that matter, but I had the thought whether hardlinking the files would actually be a better idea.
From what I think I understand, hardlinks are directory entries that point to the same inode already referenced in another directory and/or entry. Inodes have a reference counter, so when deleting a file (path), the corresponding entry is removed and the actual inode is only really deleted if it has no more references. Does this behaviour differ in different file systems?
The only reason to use plain cp
or rsync
or otherwise creating new inodes with the same content then is to either then modify the independent copy, or when the two locations are on different file systems, right?
In case that all holds true, and if my assumption is correct that we expect the number of cases where /usr/lib/modules/backup/
somehow is a different file system to be negligible, then it would be a much better idea to just hardlink all the files with cp -lr
: It doesn't use more space and is much faster because only directory entries are written. Being deleted should not erase the data because of the reference counter and restoring the modules will be the same, just the other way around.
Can we make this work with DKMS? I believe all you need is to add another path target for:
usr/src/*/dkms.conf
Doing this will allow your script to save kernel modules that will be removed by dkms
.
Please consider doing this
I'm looking into a way to keep my last working kernel around in Arch Linux, so if an update breaks something I don't have to mess around with the rescue system. So I'll want to copy the bzImage &c to e.g. /boot/prev/vmlinuz-linux, and ensure that its modules are not deleted unless the new kernel boots successfully.
I don't have a very strong understanding of systemd, so this might sound kind of stupid, but: If I understand correctly, the cleanup service will attempt to run once we've successfully reached basic.target
, and will not run if we do not reach that target. Which sounds fine except that I'm not totally sure that basic.target
will meet the requirements for what every user considers as "booting successfully." Other options include
multi-user.target
graphical.target
boot-complete.target
Admittedly, I don't really understand that last one entirely.
In any case, maybe we should ship other versions of the cleanup service which depend on multi-user
or graphical
, and the user can enable whichever one best meets his needs.
Then again, I can see how you could make the case that these other versions of the cleanup service belong more in whatever keep-the-last-working-kernel package I find/create, and not here, but maybe not.
Have you asked if Arch Linux would be interested in incorporating your work into the official kernel packages?
This hook does stop kernel updates from breaking everything, but if the kernel and a module e.g. nvidia
are both updated in the same boot, the nvidia driver seems to stop working (can't start any new processes that use GPU acceleration, e.g. Alacritty). I'm not 100% sure of the exact circumstances that cause this to happen.
This also happens if you updated the kernel then you try to install a new kernel module. The other week I had a kernel update, then later I installed the wireguard module, but I could not load it with modprobe. This seems to be because it installs the module only in the new kernel, but not for the currently running kernel. When I installed wireguard-dkms instead, it installed it for both the running kernel and the new kernel, so I was able to load it.
Is there anything that can be done about this problem?
Hi,
if you are using DKMS modules (like e.g. wireguard or VirtualBox), then those are not saved by the hook. The DKMS hook is run before the kernel-modules-hook. It looks like this (sorry for the german text):
:: Starting pre-transaction hooks...
(1/2) Remove DKMS modules
==> dkms remove wireguard/0.0.20180809 -k 4.18.4-arch1-1-ARCH
(2/2) Save Linux kernel modules
[...]
Reading the man-page alpm-hooks(5)
you are not able to define an order systemd-style (Before=
, After=
). I'm not quite sure, if it's possible to order the alpm-hooks.
Do you have an idea?
BR,
Schrottfresse
I'm not sure but is the cleanup-service intended to get activated by hand? There is no hint do do so at installation, as far as I remember. Today I tried to figure out why my root-partition got bigger and bigger and analyzed it with filelight. This is what i got:
When I looked into named modules directory I saw what it was:
I looked into this repo and saw, that a system-service was intended to cleanup on startup. I looked for it, and saw, that it was not enabled. I triggered it by hand and of course, it took an eternity to copy - delete - copy -delete... and finally delete all copied directories.
Am I the only one who took that long to notice that? Either way, maybe it would be cool if the PKGBUILD could echo a hint to the console to activate the service.
Not a high-priority thing, but maybe a funny story and a suggestion.
Sometimes the hook stops on the keymap step and I have to stop the install with Ctrl + C. This does not happen always but just sometimes. Can I somehow provide more information about this?
(1/1) checking keys in keyring [---------------------------------------------------] 100%
(1/1) checking package integrity [---------------------------------------------------] 100%
(1/1) loading package files [---------------------------------------------------] 100%
(1/1) checking for file conflicts [---------------------------------------------------] 100%
(1/1) checking available disk space [---------------------------------------------------] 100%
:: Running pre-transaction hooks...
(1/1) Saving Linux kernel modules...
:: Processing package changes...
(1/1) reinstalling linux [---------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/6) Restoring Linux kernel modules...
++ uname -r
+ KVER=6.5.6-arch2-1
+ test -e /usr/lib/modules/backup/6.5.6-arch2-1
+ rsync -AHXal --ignore-existing /usr/lib/modules/backup/6.5.6-arch2-1 /usr/lib/modules/
+ rm -rf /usr/lib/modules/backup
(2/6) Arming ConditionNeedsUpdate...
(3/6) Updating module dependencies...
(4/6) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
==> Using configuration file: '/etc/mkinitcpio.conf'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: '6.5.7-arch1-1'
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
-> Running build hook: [keymap]
^C
Interrupt signal received
Sorry, I am bash newbie. I am confused about the if statement and $$ in the script above. Can you try to explain more of it?
This is just a suggestion, but how about copying the module files to /tmp and then just creating a symlink to it? That way a) it'll be faster and b) the files will automatically get cleaned on next boot and you won't need a separate service to do this.
No hook was triggered
❯ sudo pacman -Syu
:: Synchronisation des bases de données de paquets…
core est à jour
extra est à jour
community est à jour
archlinuxfr est à jour
multilib est à jour
:: Début de la mise à jour complète du système…
résolution des dépendances…
recherche des conflits entre paquets…
Paquets (18) bbswitch-dkms-0.8-261 chromium-78.0.3904.87-1 dkms-2.8.1-1 geoclue-2.5.5+6+gea52170-1 kmod-26-3 ldb-1:1.5.6-1 libwbclient-4.10.10-1 linux-5.3.8.1-1
linux-headers-5.3.8.1-1 linux-lts-4.19.81-1 mkinitcpio-27-1 nvidia-435.21-15 openvpn-2.4.8-1 perl-libwww-6.41-1 samba-4.10.10-1 smbclient-4.10.10-1
texlive-core-2019.52579-1 texlive-latexextra-2019.52575-1
Taille totale du téléchargement : 378,14 MiB
Taille totale installée : 974,30 MiB
Taille de mise à jour nette : -14,84 MiB
:: Procéder à l’installation ? [O/n] O
:: Récupération des paquets…
kmod-26-3-x86_64 113,9 KiB 2,10 MiB/s 00:00 [------------------------------------------------------------] 0%
mkinitcpio-27-1-any 154,5 KiB 1861 KiB/s 00:00 [------------------------------------------------------------] 0%
linux-5.3.8.1-1-x86_64 68,2 MiB 27,8 MiB/s 00:02 [------------------------------------------------------------] 18%
linux-headers-5.3.8.1-1-x86_64 86,1 MiB 27,0 MiB/s 00:03 [------------------------------------------------------------] 22%
linux-lts-4.19.81-1-x86_64 150,6 MiB 27,0 MiB/s 00:06 [------------------------------------------------------------] 39%
openvpn-2.4.8-1-x86_64 151,0 MiB 26,8 MiB/s 00:06 [------------------------------------------------------------] 39%
dkms-2.8.1-1-any 151,1 MiB 26,7 MiB/s 00:06 [------------------------------------------------------------] 39%
chromium-78.0.3904.87-1-x86_64 203,9 MiB 27,1 MiB/s 00:08 [------------------------------------------------------------] 53%
geoclue-2.5.5+6+gea52170-1-x86_64 204,1 MiB 27,0 MiB/s 00:08 [------------------------------------------------------------] 53%
ldb-1:1.5.6-1-x86_64 204,2 MiB 26,9 MiB/s 00:08 [------------------------------------------------------------] 54%
libwbclient-4.10.10-1-x86_64 204,3 MiB 26,8 MiB/s 00:08 [------------------------------------------------------------] 54%
nvidia-435.21-15-x86_64 217,5 MiB 26,8 MiB/s 00:08 [------------------------------------------------------------] 57%
perl-libwww-6.41-1-any 217,6 MiB 26,7 MiB/s 00:08 [------------------------------------------------------------] 57%
smbclient-4.10.10-1-x86_64 223,5 MiB 26,5 MiB/s 00:08 [------------------------------------------------------------] 59%
samba-4.10.10-1-x86_64 229,9 MiB 26,3 MiB/s 00:09 [------------------------------------------------------------] 60%
texlive-core-2019.52579-1-any 365,6 MiB 26,5 MiB/s 00:14 [------------------------------------------------------------] 96%
texlive-latexextra-2019.52575-1-any 378,1 MiB 26,2 MiB/s 00:14 [------------------------------------------------------------] 99%
bbswitch-dkms-0.8-261-x86_64 378,1 MiB 26,2 MiB/s 00:14 [------------------------------------------------------------] 100%
(18/18) vérification des clés dans le trousseau [------------------------------------------------------------] 100%
(18/18) vérification de l’intégrité des paquets [------------------------------------------------------------] 100%
(18/18) chargement des fichiers des paquets [------------------------------------------------------------] 100%
(18/18) analyse des conflits entre fichiers [------------------------------------------------------------] 100%
(18/18) vérification de l’espace disque disponible [------------------------------------------------------------] 100%
:: Exécution des crochets de pré-transaction…
(1/1) Remove DKMS modules
==> dkms remove bbswitch/0.8 -k 5.3.7-arch1-2-ARCH
==> dkms remove vboxhost/6.0.14_OSE -k 5.3.7-arch1-2-ARCH
:: Traitement des changements du paquet…
( 1/18) mise à jour de kmod [------------------------------------------------------------] 100%
( 2/18) mise à jour de dkms [------------------------------------------------------------] 100%
( 3/18) mise à jour de bbswitch-dkms [------------------------------------------------------------] 100%
( 4/18) mise à jour de chromium [------------------------------------------------------------] 100%
( 5/18) mise à jour de geoclue [------------------------------------------------------------] 100%
( 6/18) mise à jour de ldb [------------------------------------------------------------] 100%
( 7/18) mise à jour de libwbclient [------------------------------------------------------------] 100%
( 8/18) mise à jour de mkinitcpio [------------------------------------------------------------] 100%
( 9/18) mise à jour de linux [------------------------------------------------------------] 100%
(10/18) mise à jour de linux-headers [------------------------------------------------------------] 100%
(11/18) mise à jour de linux-lts [------------------------------------------------------------] 100%
(12/18) mise à jour de nvidia [------------------------------------------------------------] 100%
(13/18) mise à jour de openvpn [------------------------------------------------------------] 100%
avertissement : les permissions pour le répertoire /etc/openvpn/client/ sont différentes
système de fichiers : 755, paquet : 750
(14/18) mise à jour de perl-libwww [------------------------------------------------------------] 100%
(15/18) mise à jour de smbclient [------------------------------------------------------------] 100%
(16/18) mise à jour de samba [------------------------------------------------------------] 100%
avertissement : les permissions pour le répertoire /var/lib/samba/private/ sont différentes
système de fichiers : 755, paquet : 700
(17/18) mise à jour de texlive-core [------------------------------------------------------------] 100%
>>> updmap custom entries should go into /etc/texmf/web2c/updmap-local.cfg
>>> fmtutil custom entries should go into /etc/texmf/web2c/fmtutil-local.cnf
(18/18) mise à jour de texlive-latexextra [------------------------------------------------------------] 100%
:: Exécution des crochets de post-transaction…
( 1/14) Creating system user accounts...
( 2/14) Reloading system manager configuration...
( 3/14) Creating temporary files...
( 4/14) Arming ConditionNeedsUpdate...
( 5/14) Updating module dependencies...
( 6/14) Install DKMS modules
==> dkms install bbswitch/0.8 -k 5.3.8-arch1-1
==> dkms install vboxhost/6.0.14_OSE -k 5.3.8-arch1-1
==> Unable to install module bbswitch/0.8 for kernel 4.19.81-1-lts: Missing kernel headers.
==> Unable to install module vboxhost/6.0.14_OSE for kernel 4.19.81-1-lts: Missing kernel headers.
( 7/14) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux-lts.preset: 'default'
-> -k /boot/vmlinuz-linux-lts -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-lts.img
==> Starting build: 4.19.81-1-lts
-> Running build hook: [base]
-> Running build hook: [systemd]
-> Running build hook: [sd-plymouth]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [sd-vconsole]
-> Running build hook: [sd-encrypt]
-> Running build hook: [sd-lvm2]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [resume]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-lts.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux-lts.preset: 'fallback'
-> -k /boot/vmlinuz-linux-lts -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-lts-fallback.img -S autodetect
==> Starting build: 4.19.81-1-lts
-> Running build hook: [base]
-> Running build hook: [systemd]
-> Running build hook: [sd-plymouth]
-> Running build hook: [modconf]
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: aic94xx
==> WARNING: Possibly missing firmware for module: wd719x
-> Running build hook: [sd-vconsole]
-> Running build hook: [sd-encrypt]
-> Running build hook: [sd-lvm2]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [resume]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-lts-fallback.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 5.3.8-arch1-1
-> Running build hook: [base]
-> Running build hook: [systemd]
-> Running build hook: [sd-plymouth]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [sd-vconsole]
-> Running build hook: [sd-encrypt]
-> Running build hook: [sd-lvm2]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [resume]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 5.3.8-arch1-1
-> Running build hook: [base]
-> Running build hook: [systemd]
-> Running build hook: [sd-plymouth]
-> Running build hook: [modconf]
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: aic94xx
==> WARNING: Possibly missing firmware for module: wd719x
-> Running build hook: [sd-vconsole]
-> Running build hook: [sd-encrypt]
-> Running build hook: [sd-lvm2]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [resume]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img
==> Image generation successful
( 8/14) Reloading system bus configuration...
( 9/14) Warn about old perl modules
(10/14) Updating icon theme caches...
(11/14) Updating TeXLive filename database...
(12/14) Updating TeXLive format files...
(13/14) Updating TeXLive font maps...
(14/14) Updating the desktop file MIME type cache...
~ 3m 47s
❯ sudo modprobe kvm_intel
modprobe: FATAL: Module kvm_intel not found in directory /lib/modules/5.3.7-arch1-2-ARCH
~
❯ ls /lib/modules/
4.19.81-1-lts/ 5.3.8-arch1-1/
~
❯ pacman -Qs kernel-modules-hook
local/kernel-modules-hook 0.1.5-1
Keeps your system fully functional after a kernel upgrade
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.