├── linux-modules-cleanup.conf ├── linux-modules-cleanup.service ├── kernel-modules-hook.install ├── .gitignore ├── 10-linux-modules-pre.hook ├── 70-linux-modules-post.hook ├── .SRCINFO ├── README.md ├── UNLICENSE └── PKGBUILD /linux-modules-cleanup.conf: -------------------------------------------------------------------------------- 1 | R! /usr/lib/modules/.old/* - - - 4w 2 | -------------------------------------------------------------------------------- /linux-modules-cleanup.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Clean up modules from old kernels 3 | 4 | [Service] 5 | Type=oneshot 6 | ExecStart=/bin/bash -exc 'for i in /usr/lib/modules/[0-9]*; do if [[ $${i##*/} = \'%v\' ]] || pacman -Qo "$${i}"; then continue; fi; mv "$${i}" /usr/lib/modules/.old/; done' 7 | 8 | [Install] 9 | WantedBy=basic.target 10 | -------------------------------------------------------------------------------- /kernel-modules-hook.install: -------------------------------------------------------------------------------- 1 | post_install() { 2 | cat << EOF 3 | 4 | Please execute 5 | 6 | $ sudo systemctl daemon-reload 7 | $ sudo systemctl enable linux-modules-cleanup 8 | 9 | Report any issues to: 10 | https://github.com/lideming/kernel-modules-hook/issues 11 | 12 | This package is forked from: 13 | https://github.com/saber-nyan/kernel-modules-hook 14 | 15 | 16 | ~arigatou 17 | 18 | EOF 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore everything 2 | * 3 | !.gitignore 4 | 5 | # except PKGBUILD needed files 6 | !PKGBUILD 7 | !.SRCINFO 8 | !*.install 9 | 10 | # common wing-man files 11 | !*.diff 12 | !*.patch 13 | 14 | # add files that don't have an online source 15 | kernel-modules-hook.install 16 | linux-modules-cleanup.conf 17 | linux-modules-cleanup.service 18 | 70-linux-modules-post.hook 19 | 10-linux-modules-pre.hook 20 | UNLICENSE 21 | -------------------------------------------------------------------------------- /10-linux-modules-pre.hook: -------------------------------------------------------------------------------- 1 | [Trigger] 2 | Operation = Install 3 | Operation = Upgrade 4 | Type = Path 5 | Target = usr/lib/modules/*/vmlinuz 6 | 7 | [Action] 8 | Description = Saving Linux kernel modules... 9 | When = PreTransaction 10 | Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -d "/usr/lib/modules/${KVER}"; then mkdir -p /usr/lib/modules/backup ; cp -an --reflink=auto "/usr/lib/modules/${KVER}" /usr/lib/modules/backup/; fi' 11 | -------------------------------------------------------------------------------- /70-linux-modules-post.hook: -------------------------------------------------------------------------------- 1 | [Trigger] 2 | Operation = Install 3 | Operation = Upgrade 4 | Type = Path 5 | Target = usr/lib/modules/*/vmlinuz 6 | 7 | [Action] 8 | Description = Restoring Linux kernel modules... 9 | When = PostTransaction 10 | Depends = coreutils 11 | Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -d "/usr/lib/modules/backup/${KVER}" && ! test -f "/usr/lib/modules/${KVER}/vmlinuz"; then cp -an --reflink=auto "/usr/lib/modules/backup/${KVER}" /usr/lib/modules/; fi; rm -rf /usr/lib/modules/backup' 12 | -------------------------------------------------------------------------------- /.SRCINFO: -------------------------------------------------------------------------------- 1 | pkgbase = kernel-modules-hook-reflink 2 | pkgdesc = Keeps your system fully functional after a kernel upgrade (forked version using `cp --reflink`, maybe better for btrfs) 3 | pkgver = 0.1.11 4 | pkgrel = 1 5 | url = https://github.com/lideming/kernel-modules-hook 6 | install = kernel-modules-hook.install 7 | arch = any 8 | license = UNLICENSE 9 | depends = coreutils 10 | conflicts = kernel-modules-hook 11 | source = linux-modules-cleanup.conf 12 | source = linux-modules-cleanup.service 13 | source = 70-linux-modules-post.hook 14 | source = 10-linux-modules-pre.hook 15 | source = UNLICENSE 16 | sha256sums = 4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf 17 | sha256sums = 023464fbc648365d64b96626eeef2628bb10cae757a00db3a2624b0a61d0e41e 18 | sha256sums = 53c0f59a1934d5a3ff5a3e7f9a22971832bf2ce7685210238fe2a92bea80663f 19 | sha256sums = c11ca188aef5c4de0a416708c0a944af48f068724edae8a19abb081fd945849b 20 | sha256sums = 7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c 21 | 22 | pkgname = kernel-modules-hook-reflink 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #
kernel-modules-hook-reflink
2 | 3 | **-reflink** is forked from [the original hook](https://github.com/saber-nyan/kernel-modules-hook). 4 | It uses `cp --reflink` to copy modules, saving time and space for Btrfs. 5 | 6 | --- 7 | 8 | Tired of missing modules when updating the kernel?