Skip to content

dracut: add EFI kernel hook#22484

Merged
sgn merged 1 commit into
void-linux:masterfrom
ericonr:dracut
Aug 3, 2020
Merged

dracut: add EFI kernel hook#22484
sgn merged 1 commit into
void-linux:masterfrom
ericonr:dracut

Conversation

@ericonr

@ericonr ericonr commented Jun 1, 2020

Copy link
Copy Markdown
Member

Also made some small formatting changes.

@ahesford

@ericonr ericonr force-pushed the dracut branch 5 times, most recently from 298ab48 to 51d137a Compare June 1, 2020 07:32

@ahesford ahesford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ericonr

ericonr commented Jul 20, 2020

Copy link
Copy Markdown
Member Author

@sgn could you take a look at this one?

@sgn sgn assigned sgn and unassigned sgn Jul 20, 2020
fi

if [ -z "${KERNEL_CMDLINE}" ] && [ "x${SKIP_KERNEL_CMDLINE}" != x1 ]; then
echo "ERROR: You need to set the kernel command line in /etc/default/dracut-uefi-hook"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this logic necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's solving the issue that if dracut doesn't find a kernel_cmdline entry in a dracut.conf file and isn't passed a cmdline in the command line argumets, it will prompt the user for a cmdline.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't think of another way of solving this particular issue.

@ericonr ericonr Jul 20, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other way of solving this would be always passing at least an empty string to the command line parameter. But it doesn't protect the user from dumb mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good option, provided it has no unanticipated side effects.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still prefer erroring out, but if you think it's fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm there's also the use case without secure boot that allows the bundle to use the cmdline from refind/grub, so the command line could be empty.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just write a warning in the configuration file, and let the user see the boot failure 🤷
Don't bother with it, I would say.

Comment thread srcpkgs/dracut/files/kernel-uefi-hook-postinst Outdated
Comment thread srcpkgs/dracut/files/kernel-uefi-hook-postinst Outdated
Comment thread srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated
Comment thread srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated
Comment thread srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated
exit 1
fi

OPTIONS="${OPTIONS} --force --uefi ${UEFI_BUNDLE_DIR:=boot/efi/EFI/Void}/linux-${VERSION}.efi ${VERSION}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdir -p "$UEFI_BUNDLE_DIR"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe void lowercase v is better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'm thinking about supporting this in sbsigntool and refind hooks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'm thinking about supporting this in sbsigntool and refind hooks.

How would this look?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force them read this hooks if exists, maybe.
Rather messy but I don't like different parts of system refusing co-operating with each others. Just make sure variable introduced by this change doesn't overlap with them, I can make it works.
I like this idea, (so I can sign the whole efi, my initrd is unsigned, now) but I don't use gummiboot, for example.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this to prepare for it
sgn@9bbcb81

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I like the idea.

Comment thread srcpkgs/dracut/files/kernel-uefi-hook-postinst Outdated
DRACUT_OPTIONS="${DRACUT_OPTIONS} --force --uefi ${UEFI_BUNDLE_DIR:=boot/efi/EFI/void}/linux-${VERSION}.efi ${VERSION}"
mkdir -p "${UEFI_BUNDLE_DIR}"

dracut -q --kernel-cmdline="${KERNEL_CMDLINE}" ${DRACUT_OPTIONS}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dracut -q ${KERNEL_CMDLINE:+--kernel-cmdline="${KERNEL_CMDLINE}"} ${DRACUT_OPTIONS}

looks better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that, if you don't set kernel_cmdline in the config file or the dracut command line, the user will be prompted for a value, which will stall the hook. @ericonr, is this correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah I hadn't seen @ahesford's comment.

So, that one does look better, and if I add the -q argument to dracut it simply plows ahead and gets an empty cmdline. So it should be fine.

fi

if [ -z "${KERNEL_CMDLINE}" ] && [ "x${SKIP_KERNEL_CMDLINE}" != x1 ]; then
echo "ERROR: You need to set the kernel command line in /etc/default/dracut-uefi-hook"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just write a warning in the configuration file, and let the user see the boot failure 🤷
Don't bother with it, I would say.

sgn pushed a commit to sgn/void-packages that referenced this pull request Jul 21, 2020
Also made some small formatting changes.

Close: void-linux#22484
@ericonr

ericonr commented Jul 21, 2020

Copy link
Copy Markdown
Member Author

Updated again.

sgn pushed a commit to sgn/void-packages that referenced this pull request Jul 22, 2020
Also made some small formatting changes.

Close: void-linux#22484
sgn pushed a commit to sgn/void-packages that referenced this pull request Jul 22, 2020
Also made some small formatting changes.

Close: void-linux#22484
sgn pushed a commit to sgn/void-packages that referenced this pull request Jul 23, 2020
Also made some small formatting changes.

Close: void-linux#22484
sgn pushed a commit to sgn/void-packages that referenced this pull request Jul 23, 2020
Also made some small formatting changes.

Close: void-linux#22484
@sgn

sgn commented Jul 27, 2020

Copy link
Copy Markdown
Member

Is this ready?

Or are we better to split the uefi bundle hook and gummiboot?

If this is ready, I'll merge this in, without worrying about other option.

@ericonr

ericonr commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

I don't think it's fully ready, the post remove hook isn't using -z to detect if it should do anything. Btw, how do we deal with

if [ ! -x bin/dracut ]; then
	exit 0
fi

? Should it exit with 1 and show an error, since having the hook installed but not dracut is an issue?

Comment thread srcpkgs/dracut/files/kernel-uefi-hook-postrm Outdated
exit 0
fi

: "${UEFI_BUNDLE_DIR:=boot/efi/EFI/Void}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowercase V in Void.
Since grub will create this very same directory with lowercase void.
I'm not sure what they will do if they're conflicting now.
And I couldn't say about their future.

@ericonr ericonr force-pushed the dracut branch 2 times, most recently from 53da9d8 to fb548b7 Compare July 27, 2020 12:52
@sgn

sgn commented Jul 27, 2020

Copy link
Copy Markdown
Member

I don't think it's fully ready, the post remove hook isn't using -z to detect if it should do anything.
Btw, how do we deal with

if [ ! -x bin/dracut ]; then
	exit 0
fi

If this hook is included with dracut, this check is likely unnecessary.
Albeit, we should use usr/bin/dracut instead?

But, this hook depends on both dracut and an efi file provided by gummiboot.
I'm not sure if it's better to split it out and explicitly depends on gummiboot?

? Should it exit with 1 and show an error, since having the hook installed but not dracut is an issue?

I, myself, don't care about the broken system if their owners choose to break it

@ericonr

ericonr commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

If this hook is included with dracut, this check is likely unnecessary.

I agree. It is mostly following the style of the other hook, that's why it has the check.

I'm not sure if it's better to split it out and explicitly depends on gummiboot?

Hmm that might be a better way of doing it. We mention the dependency in the config file, at least. Would it be okay to have a subpackage only for the hook and the conf file?

@sgn

sgn commented Jul 27, 2020 via email

Copy link
Copy Markdown
Member

@ericonr

ericonr commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

Heh, ok! Will split it off.

@ericonr

ericonr commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

Done.

@sgn

sgn commented Jul 27, 2020

Copy link
Copy Markdown
Member

Looks good. I hope you don't mind to wait for few days to let other people complain :D

@ericonr

ericonr commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

No worries, I'm not even using it any more :p

Thanks!

Edit: I am not using on my main device, I am indeed using it on my old one.

Comment thread srcpkgs/dracut/template
@ericonr

ericonr commented Aug 2, 2020

Copy link
Copy Markdown
Member Author

Added binutils to dracut-uefi, it needs it for the objcopy step.

Comment thread srcpkgs/dracut/template Outdated
Comment on lines +30 to +32
i686*|x86_64*|aarch64*) # EFI bundle config and hooks
_efi_bundle=1
subpackages+=" dracut-uefi"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uefi-bundle is not supported in aarch64. (/usr/bin/dracut:1140)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good find. Wonder if they forgot to add aarch64 or if it doesn't work.

@sgn sgn Aug 3, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's ready, I'll pull this patch in dracutdevs/dracut@6184c7a


It seems like it's already there? But, somehow wasn't pulled in

Restricted to i686* and x86_64* for now.

Other changes:

- small formatting changes
- use relative path in kernel-hook-postrm
@sgn sgn merged commit 77489be into void-linux:master Aug 3, 2020
@ericonr ericonr deleted the dracut branch August 3, 2020 04:15
Comment thread srcpkgs/dracut/template
}

dracut-uefi_package() {
depends="binutils gummiboot dracut-${version}_${revision}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dracut UEFI bundle requires a separate UEFI stub provided (in our case) by gummiboot.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants