You are not logged in.

#1 2023-10-01 14:15:56

Neek
Member
Registered: 2023-09-24
Posts: 4

[SOLVED] Making a pacman hook to backup /boot (hook not running)

Hi everyone,

I have a BTRFS filesystem set up as described in the wiki to work with snapper which seems to be working, but now I am trying to also make a pacman hook to copy /boot as well.

I have tried to follow the description here:
https://wiki.archlinux.org/title/System … _partition

I think this did not work at first because I did now have a
/etc/pacman.d/hooks/
directory, and did not have pacman set up to use that directory.

Instead, I created the hook here:

sudo touch /usr/share/libalpm/hooks/95-bootbackup.hook

However, whenever I install, remove, or just update the programs with pacman, I do not see the "Backing up /boot..." text that I would expect. I also did not see a new directory at: /.bootbackup

to troubleshoot a bit, I tried the rsync command by itself:

sudo /usr/bin/rsync -a --delete /boot /.bootbackup

And that worked fine.

Do I need to activate a hook somehow?

Do you have any advice on how I can troubleshoot this hook further?
Thank you in advance!

Last edited by Neek (2023-10-03 04:38:30)

Offline

#2 2023-10-01 16:01:35

Neek
Member
Registered: 2023-09-24
Posts: 4

Re: [SOLVED] Making a pacman hook to backup /boot (hook not running)

Ok, I think I am making some progress.

I just made a very generic test hook that I do see when I run pacman -S tree or pacman -R tree

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
#Type = Path
Type = Package
#Target = usr/lib/modules/*/vmlinuz
Target = *

[Action]
#Depends = rsync
Depends = rsync
Description = Make a echo command write out test text to the terminal during pacman operations
When = PreTransaction
#Exec = /usr/bin/rsync -a --delete /boot /.bootbackup
Exec = /usr/bin/echo "TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_"

When I run pacman installations/etc, now I see these lines while pacman is running:

(2/3) Make a echo command write out test text to the terminal during pacman operations
TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_

So here was the original hook file text from the arch wiki page that I do not see running:

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz

[Action]
Depends = rsync
Description = Backing up /boot...
When = PostTransaction
Exec = /usr/bin/rsync -a --delete /boot /.bootbackup

So the two lines in that that I think are maybe causing me to not see the hook run are under [Trigger]:

Type = Path
Target = usr/lib/modules/*/vmlinuz

I am trying to read about those lines here:
https://archlinux.org/pacman/alpm-hooks.5.html, but I cannot understand what they are doing. Are they maybe trying to only run this hook when the kernel or something else like this are updated from the /boot partition?

Offline

#3 2023-10-01 18:52:20

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,727

Re: [SOLVED] Making a pacman hook to backup /boot (hook not running)

It's saying to run when the transaction includes usr/lib/modules/*/vmlinuz. Nothing to do with /boot at all.

Online

#4 2023-10-02 09:32:08

jl2
Member
From: 47° 18' N 8° 34' E
Registered: 2022-06-01
Posts: 1,386

Re: [SOLVED] Making a pacman hook to backup /boot (hook not running)

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz

This will tell it if it should run.
with 'Path' this will update when a file matching the criteria from Target gets changed/added/deleted, depending on the Operations defined.
and with 'Package' when a package matching Target is changed/added/deleted, depending on the Operations defined.

Here you want to use 'Path' and as scimmia has said, '/boot/*', and Operation is good.

This is only run when you change something matching your target, so a kernel or microcode.
you probably tried installing bash or something, right?
test it by reinstalling a _kernel_.

Also, you can create /etc/pacman.d/hooks and add  'HookDir = /etc/pacman.d/hooks' to /etc/pacman.conf, and move the hook there.

Last edited by jl2 (2023-10-02 09:37:47)


Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...

Upload longer text output like this

Offline

#5 2023-10-02 13:20:15

loqs
Member
Registered: 2014-03-06
Posts: 18,928

Re: [SOLVED] Making a pacman hook to backup /boot (hook not running)

jl2 wrote:

Here you want to use 'Path' and as scimmia has said, '/boot/*', and Operation is good.

This is only run when you change something matching your target, so a kernel or microcode.

It will not run on a kernel update as the kernel does not install anything to /boot see /usr/share/libalpm/hooks/90-mkinitcpio-install.hook.

Offline

#6 2023-10-03 04:38:07

Neek
Member
Registered: 2023-09-24
Posts: 4

Re: [SOLVED] Making a pacman hook to backup /boot (hook not running)

Thank you everyone for the help! I think you have helped me understand the original problem/my original confusion of why the /boot partition was not being copied with every pacman command, so I think I should mark this thread as [solved] for now.

I think I will have to (re)-read the wiki about the kernal and microcode processes to understand exactly when I want this hook to run. However, I think I will have to come back to this in a few days time. Maybe I can also propose that a few concise bits of description are added to:
https://wiki.archlinux.org/title/System … _partition
and that the pages on hooks, kernals, and microcodes are also linked from that section of the wiki.

In addition, for my own personal setup, I might just want this rsync command to run with every pacman command since I think that the rsync command will not actually have to (re)copy anything if no files on the /boot partition have been changed.

Offline

Board footer

Powered by FluxBB