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

dracut: add EFI kernel hook #22484

Merged
merged 1 commit into from
Aug 3, 2020
Merged

dracut: add EFI kernel hook #22484

merged 1 commit into from
Aug 3, 2020

Conversation

ericonr
Copy link
Member

@ericonr ericonr commented Jun 1, 2020

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
Copy link
Member

@ahesford ahesford left a comment

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
Copy link
Member Author

ericonr commented Jul 20, 2020

@sgn could you take a look at this one?

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
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
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
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.

Copy link
Member Author

@ericonr ericonr Jul 20, 2020

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
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
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
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
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.

srcpkgs/dracut/files/kernel-uefi-hook-postinst Outdated Show resolved Hide resolved
srcpkgs/dracut/files/kernel-uefi-hook-postinst Outdated Show resolved Hide resolved
srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated Show resolved Hide resolved
srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated Show resolved Hide resolved
srcpkgs/dracut/files/dracut-uefi-hook.confd Outdated Show resolved Hide resolved
exit 1
fi

OPTIONS="${OPTIONS} --force --uefi ${UEFI_BUNDLE_DIR:=boot/efi/EFI/Void}/linux-${VERSION}.efi ${VERSION}"
Copy link
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
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
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
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
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
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
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.

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
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
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
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
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
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
Copy link
Member Author

ericonr commented Jul 21, 2020

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
Copy link
Member

sgn commented Jul 27, 2020

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
Copy link
Member Author

ericonr commented Jul 27, 2020

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?

srcpkgs/dracut/files/kernel-uefi-hook-postrm Outdated Show resolved Hide resolved
exit 0
fi

: "${UEFI_BUNDLE_DIR:=boot/efi/EFI/Void}"
Copy link
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
Copy link
Member

sgn commented Jul 27, 2020

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
Copy link
Member Author

ericonr commented Jul 27, 2020

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
Copy link
Member

sgn commented Jul 27, 2020 via email

@ericonr
Copy link
Member Author

ericonr commented Jul 27, 2020

Heh, ok! Will split it off.

@ericonr
Copy link
Member Author

ericonr commented Jul 27, 2020

Done.

@sgn
Copy link
Member

sgn commented Jul 27, 2020

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

@ericonr
Copy link
Member Author

ericonr commented Jul 27, 2020

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.

@ericonr
Copy link
Member Author

ericonr commented Aug 2, 2020

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

Comment on lines 30 to 32
i686*|x86_64*|aarch64*) # EFI bundle config and hooks
_efi_bundle=1
subpackages+=" dracut-uefi"
Copy link
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
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.

Copy link
Member

@sgn sgn Aug 3, 2020

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
vmove usr/lib/dracut/modules.d/${f}
done
}
}

dracut-uefi_package() {
depends="binutils gummiboot dracut-${version}_${revision}"
Copy link
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.

None yet

4 participants