You are not logged in.

#1 2022-03-05 09:13:58

goldmund
Member
Registered: 2021-02-15
Posts: 73

[SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

Hi!

I am using snapper to create btrfs snapshots of / and because /boot has fat32 filesystem, /boot snapshots aren't included.

Therefore I've turned to the ArchWiki and found the section Snapshots and /boot partition. However, I've got a problem with this setup.

Directory /.bootbackup gets created, however, it is incomplete as inside /.bootbackup/boot there is only:

$ ls -lA /.bootbackup/boot
total 4596
drwxr-xr-x 1 root root       8 Jan  1 16:21 EFI
drwxr-xr-x 1 root root      84 Feb  3 19:59 grub
-rwxr-xr-x 1 root root 4706304 Feb  8 22:07 intel-ucode.img

While inside /boot there is:

$ ls -lA /boot
total 86788
drwxr-xr-x 3 root root     4096 Jan  1 16:21 EFI
drwxr-xr-x 6 root root     4096 Feb  3 19:59 grub
-rwxr-xr-x 1 root root 49316328 Mar  2 17:18 initramfs-linux-fallback.img
-rwxr-xr-x 1 root root 24356061 Mar  2 17:18 initramfs-linux.img
-rwxr-xr-x 1 root root  4706304 Feb  8 22:07 intel-ucode.img
-rwxr-xr-x 1 root root 10477568 Mar  2 17:18 vmlinuz-linux

I used the pacman hook exactly as stated on the Wiki which creates incomplete backups. However, when I ran rsync manually to test it, backups were complete. So the pacman hook must somehow interrupt the rsync process.

I am definitely not an expert on systemd, but in order to daemonize the process I created:

# /etc/pacman.d/hooks/50-bootbackup.hook
[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/systemctl restart bootbackup.service
# /etc/systemd/system/bootbackup.service
[Unit]
Description=Backup /boot into /.bootbackup

[Service]
TimeoutStartSec=600
ExecStartPre=/usr/bin/sleep 180
ExecStart=/usr/bin/rsync -a --delete /boot /.bootbackup

My idea was for the service to wait 3 minutes (enough time for the linux upgrade to finish) and then launch. But that doesn't work as it just waits 3 minutes during the time pacman runs and creates an incomplete backup again.

I am out of ideas. Do you have any? Thanks!

Last edited by goldmund (2022-03-05 13:05:54)

Offline

#2 2022-03-05 09:45:30

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

goldmund wrote:

My idea was for the service to wait 3 minutes (enough time for the linux upgrade to finish)

If by this you mean 90-mkinitcpio-install.hook, couldn't you change the 50 to something > 90 so your hook runs after mkinitcpio?

But that doesn't work as it just waits 3 minutes during the time pacman runs

ExecStartPre is part of the start-up phase and systemctl waits for start-up to complete unless you use --no-block.

Offline

#3 2022-03-05 10:13:02

goldmund
Member
Registered: 2021-02-15
Posts: 73

Re: [SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

Raynman wrote:
goldmund wrote:

My idea was for the service to wait 3 minutes (enough time for the linux upgrade to finish)

If by this you mean 90-mkinitcpio-install.hook, couldn't you change the 50 to something > 90 so your hook runs after mkinitcpio?

But that doesn't work as it just waits 3 minutes during the time pacman runs

ExecStartPre is part of the start-up phase and systemctl waits for start-up to complete unless you use --no-block.

Thanks, both of your suggestions helped me solve the issue. Complete backups are now being created.

Should the ArchWiki be changed to include a systemd service which daemonizes the rsync process or which increases the number inside filename (/etc/pacman.d/hooks/50-bootbackup.hook) > 90? The current setup doesn't seem to be working.

Will mark as solved if there are no answers within a day.

Last edited by goldmund (2022-03-05 10:18:08)

Offline

#4 2022-03-05 10:59:47

goldmund
Member
Registered: 2021-02-15
Posts: 73

Re: [SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

Just tested this and changing the filename to 95-bootbackup.hook does the job, no need for a systemd service.

I've never changed the Wiki, would you advise changing:
/etc/pacman.d/hooks/50-bootbackup.hook > /etc/pacman.d/hooks/95-bootbackup.hook
?

Last edited by goldmund (2022-03-05 11:00:35)

Offline

#5 2022-03-05 12:40:13

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

Sure, it seems broken right now, so you could at least make a minimal edit to get something that works. It might be good to explicitly mention the reason for the 95.

Offline

#6 2022-03-05 13:05:40

goldmund
Member
Registered: 2021-02-15
Posts: 73

Re: [SOLVED] pacman hook not working properly (btrfs snapshots of /boot)

Raynman wrote:

Sure, it seems broken right now, so you could at least make a minimal edit to get something that works. It might be good to explicitly mention the reason for the 95.

Will do. Thanks! Marking as solved.

Offline

Board footer

Powered by FluxBB