Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd mkinitcpio hook support #14

Open
langri-sha opened this issue Dec 30, 2017 · 9 comments
Open

Systemd mkinitcpio hook support #14

langri-sha opened this issue Dec 30, 2017 · 9 comments

Comments

@langri-sha
Copy link

langri-sha commented Dec 30, 2017

If we're using systemd-boot, should the udev and shutdown hooks be replaced with systemd and sd-shutdown?

@langri-sha langri-sha changed the title Using suspend mode with systemd Using suspend mode with systemd-boot Dec 30, 2017
@Vincent43
Copy link
Collaborator

systemd-boot is bootloader, it should load every initramfs image that's available just fine.

I didn't test systemd specific hooks for mkinitcpio but I think they aren't compatible with ykfde so it's better to stay with udev and shutdown unless you want to do some testing.

@langri-sha
Copy link
Author

Yes, I was migrating to systemd-boot and can confirm that the systemd and sd-shutdown hooks do not work.

I'm at the moment keeping two configurations and using a separate LUKS key slot for loading with systemd-boot. I haven't ever written any hooks, but I have a setup to try and make the ykfde hook working properly.

@Vincent43 Vincent43 changed the title Using suspend mode with systemd-boot Systemd mkinitcpio hook support Feb 9, 2018
@VGrol
Copy link
Contributor

VGrol commented Aug 25, 2018

I've done some testing on this end,
The ykfde hood is effecitvely a hijacked encrypt hook,
It only adds the following

add_binary "tr" add_binary "ykchalresp" add_binary "ykinfo" add_binary "date" add_binary "sleep" add_binary "printf" add_file "/etc/ykfde.conf" "/etc/ykfde.conf" add_file "/usr/lib/ykfde-suspend/initramfs-suspend" "/ykfde-suspend" 755

Adapting it to sd-encrypt still fails, since the script handling and extra binaries added in the ykfde hook don't seem to work with systemd out of box.
It ends up waiting for startjobs, required by ykfde.

I have found a different project that adapts yubikey to systemd init, but it appears to use an entirely seperate ykfde hook and it still requires the sd-encrypt hook.
It might be worth looking at, you can find it here.

That said, I think the while ykfde-hook might need a minor rewrite,
as the shutdown hook is still recommended for ykfde-suspend, but it has been depreciated for a long time.

@Vincent43
Copy link
Collaborator

Vincent43 commented Aug 25, 2018

The ykfde hood is effecitvely a hijacked encrypt hook,

"Hijacked" is a strange choice of wording. ykfde hook is build on top of Arch's encrypt hook - that sounds simpler.

It only adds the following

In other words - it only adds everything which is needed for it to work 😄. However I think that you missed the runtime part of the hook which is totally different.

Adapting it to sd-encrypt still fails, since the script handling and extra binaries added in the ykfde hook don't seem to work with systemd out of box.
It ends up waiting for startjobs, required by ykfde.

If that was only question of copy-pasting ykfde changes to sd-encrypt hook it would be already done. Arch itself recommends using non-systemd initramfs with encrypt hook. The only benefits of using sd-encrypt are support for multiple encrypted devices and detached luks header.

I have found a different project that adapts yubikey to systemd init, but it appears to use an entirely seperate ykfde hook and it still requires the sd-encrypt hook.
It might be worth looking at, you can find it here.

Yes, I'm aware of the project you linked 😄 . Unfortunately it's coded in C, not in shell scripting as we do.

That said, I think the while ykfde-hook might need a minor rewrite,
as the shutdown hook is still recommended for ykfde-suspend, but it has been depreciated for a long time.

It doesn't really matter if it's deprecated. It was used for different purpose in Arch and still fits for our usecase. When Arch decide to delete it we can bring it back in this repo.

@VGrol
Copy link
Contributor

VGrol commented Aug 25, 2018

Apologies if my phrasing might've come off as hostile,
it wasn't intended to be.

"Hijacked" is a strange choice of wording. ykfde hook is build on top of Arch's encrypt hook - that sounds simpler.

In other words - it only adds everything which is needed for it to work smile. However I think that you missed the runtime part of the hook which is totally different.

I was merely implying that it operates on the foundations of the encrypt hook, rather than being its own standalone hook. The contents that define the ykfde part of the hook are simply minimalistic.

If that was only question of copy-pasting ykfde changes to sd-encrypt hook it would be already done. Arch itself recommends using non-systemd initramfs with encrypt hook. The only benefits of using sd-encrypt are support for multiple encrypted devices and detached luks header

Yeah, I never expected my hack-job modifications to work out of the gate, I was merely interested in what would happen.
The reason I delved into it in the first place was because it seems that Arch is slowly moving into moving the boot and init process towards systemd, together with the recent push of systemd-boot (a boot loader, a different topic however).

It doesn't really matter if it's deprecated. It was used for different purpose in Arch and still fits for our usecase. When Arch decide to delete it we can bring it back in this repo.

I haven't looked into what ykfde uses in shutdown hook, could you point it out to me?
If I recall correctly, one of the two devices where ykfde-suspend is running, the shutdown hook was omitted and it seemed fine.

@Vincent43
Copy link
Collaborator

The reason I delved into it in the first place was because it seems that Arch is slowly moving into moving the boot and init process towards systemd, together with the recent push of systemd-boot (a boot loader, a different topic however).

What is the base for this assumptions? Let me quote Arch Wiki maintainer from January this year: There's no need to use systemd hooks unless you have a problem with the busybox hooks, or need functionality that busybox hooks don't provide . There wasn't any activity in Arch's mkinitcpio project this year.

I haven't looked into what ykfde uses in shutdown hook, could you point it out to me?
If I recall correctly, one of the two devices where ykfde-suspend is running, the shutdown hook was omitted and it seemed fine.

The shutdown hook copies initramfs content to /run/initramfs dir on running system. ykfde uses /run/initramfs for chroot directory. It isn't possible for ykfde-suspend to work if /run/initramfs doesn't exist or is empty.

@guyest
Copy link

guyest commented Jul 13, 2019

I think what would solve this issue of no compatibility with systemd-boot (which I still experience) is building on top of the sd-encrypt hook rather than the encrypt hook. Is the code structured in such a way where it is possible to create a second hook called sd-ykfde in addition to ykfde so that systemd-boot users can make use of this great tool?

I would be willing to help implement that if you would be kind enough to point me to the right places in the code that would need to be reworked to add that functionality.

@anatol
Copy link

anatol commented Dec 3, 2019

I tried to enable ykfde hook at systemd type of boot. I replaced sd-encrypt with ykfde and boot fails. I had to revert back to sd-encrypt hook.

+1 for having ykfde ported to systemd.

@B4b4u
Copy link

B4b4u commented Nov 23, 2022

+1 for having ykfde ported to systemd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants