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

feat: add initramfs rebuilding with support for user defined initramfs args #586

Merged
merged 7 commits into from Nov 27, 2023
Merged

feat: add initramfs rebuilding with support for user defined initramfs args #586

merged 7 commits into from Nov 27, 2023

Conversation

HikariKnight
Copy link
Member

@HikariKnight HikariKnight commented Nov 26, 2023

This adds come needed flexibility to how bazzite-hardware-setup handles initramfs args.

Changes:

Added /etc/bazzite/initramfs/ as $INITRAMFS_DIR
Added /etc/bazzite/initramfs/args.d/ as $INITRAMFS_CUSTOM_ARGS_DIR

Rebuilding to load new modules or user args

Creating the file /etc/bazzite/initramfs/rebuild will now trigger a rebuild of initramfs on the next boot and then reboot when the build is done to then load the new initramfs.
This makes it possible for users to add dracut drivers and configs to /etc/dracut.d/ and then rebuild initramfs without jumping through hoops to trick bazzite-hardware-setup into thinking something is wrong with the initramfs args, rebuilding initramfs twice or manually do a rebuild which will have its args removed next time bazzite updates initramfs...

Initramfs argument configuration

bazzite-hardware-setup will now generate it's needed initramfs args like before (so no changes needed), but will write them to $INITRAMFS_DIR/hardware-setup.args for storage, this is because rpm-ostree has no good way to just give you the initramfs arguments you have used without parsing rpm-ostree status, which can lead to wrong results.
NOTE: some initramfs args requires you to pass --arg multiple times to rpm-ostree and rpm-ostree initramfs does not show you which args belong into their own --arg parameter, hence the need for this file.

Building initramfs

When bazzite-hardware-setup builds initramfs, it will get the generated hardware-setup args from the hardware-setup.args file and any custom arguments from $INITRAMFS_CUSTOM_ARGS_DIR/args.d/.
The files inside the args.d/ directory can have comments and can be written as single lines or as multiple lines, as bazzite-hardware-setup will combine all the files (excluding commented lines) into a single initramfs argument, this will be done alphabetically by filename.
For consistency and simplicity the initramfs arg files will follow the same syntax for initramfs arguments as rpm-ostree initramfs --help

This means the files will be 1:1 with the rpm-ostree initramfs --enable command and easy to parse and understand.

Added example file for user defined initramfs args

The example file can be found in $INITRAMFS_CUSTOM_ARGS_DIR/args.d/00-example.conf

hardware-setup.args

This file is currently generated by bazzite-hardware-setup and will always reflect whatever the last "hardcoded" initramfs args for the users system will be based on the last HW_VER bump, this file should not be edited by the user as any changes will be overwritten the next time bazzite-hardware-setup detects missing needed initramfs arguments.

@KyleGospo
Copy link
Member

Can't thank you enough, this is exactly what I wanted to do and you beat me to it!

@HikariKnight
Copy link
Member Author

Can't thank you enough, this is exactly what I wanted to do and you beat me to it!

No problem!
I just finally had time to sit down and work with it today as i already had notes with ideas sketched down on how to approach this from the older pull request 😄
Hopefully i will be less busy going forward as work is wrapping up and the current project finishes.

@fiftydinar
Copy link
Contributor

Would be nice to adopt this globally as a bling module, will look into implementing these changes as initramfs-etc instead for my usage

@KyleGospo KyleGospo merged commit 0a97588 into ublue-os:main Nov 27, 2023
1 of 21 checks passed
@HikariKnight HikariKnight deleted the initramfs-enhancement branch November 27, 2023 01:44
KyleGospo pushed a commit that referenced this pull request Nov 27, 2023
…s args (#586)

* feat: add support for  managing initramfs args
without disrupting bazzite-hardware-setup needed_initramfs args

* fix: make enable-vfio use new initramfs management

* fix: quote the initramfs to not bug rpm-ostree

* chore: sort argsfiles from args.d before parsing

* chore: bump hw version and cleanup

* chore: add missing indent for vfio section

* fix: add missing reboot on rebuild of initramfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants