You are not logged in.

#1 2021-10-12 07:53:14

Soroshi
Member
Registered: 2016-01-27
Posts: 8

mkinitcpio + resume hook. Do other hooks run after resume?

When using the resume hook provided by mkinitcpio to resume after a suspend to disk, do hooks placed after resume still run, or does it short-circuit the process with the kernel immediately loading the swap partition contents into memory?

In addition to hooks placed after resume I am also wondering what happens to "late hooks" and "cleanup hooks" from hooks placed before resume. I have a few of my own hooks that use late and cleanup hooks and I want to know if they will still work correctly if I start using suspend to disk.

My guess is nothing runs after resume, as that would break the idea of restoring to the exact state the system was in before. I would test all of this to find out but it's fairly cumbersome to setup and test in a controlled way just to have it not work.

Offline

#2 2021-10-12 08:42:56

frostschutz
Member
Registered: 2013-11-15
Posts: 1,417

Re: mkinitcpio + resume hook. Do other hooks run after resume?

Resume is a bit like time travel. It zaps the entire state of the machine to whatever it was right before it suspended. You're travelling into parallel universe where the machine was never shut down in the first place. Well, not really but that's kind of the idea.

This is also why you are not supposed to touch anything on your filesystems between suspend and resume. Because resume travels back in time (for ram state) but data on disk can not travel back, so data corruption would occur if you changed things there.

So no, the other stuff does not run anymore. It only runs if resume was not successful.

That is not to say you can't run stuff after resume, there's probably an event handler for that somewhere in the depths of systemd/udev, so if you want to run things after resume, you can probably do so. It's just not part of initramfs anymore.

Offline

#3 2021-10-12 20:32:03

Soroshi
Member
Registered: 2016-01-27
Posts: 8

Re: mkinitcpio + resume hook. Do other hooks run after resume?

This is more or less what I expected. Thank you for the detailed reply!

One follow up question: What happens with the resume hook/kernel when you don't suspend to disk? Does the kernel leave some sort of flag in the swap partition to tell it if it can resume from the contents? This would make sense to me, as otherwise I would need different boot entries (one with resume and one without) and I would have to make sure to select the right one.

My custom hooks with "late hooks" revolve around updating the policy on a TPM sealed disk decryption key on kernel updates, so I can just not suspend to disk when I need to update that.

Offline

Board footer

Powered by FluxBB