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

Writing "root" entry into /etc/kernel/cmdline which is needed by sdbootutil #701

Merged
merged 7 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions package/yast2-bootloader.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri May 3 13:07:26 UTC 2024 - Stefan Schubert <schubi@localhost>

- Writing "root" entry into /etc/kernel/cmdline which is needed by
sdbootutil. (still for bsc#1220892)
- 5.0.10

-------------------------------------------------------------------
Fri Apr 26 13:07:51 UTC 2024 - Stefan Schubert <schubi@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 5.0.9
Version: 5.0.10
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
26 changes: 9 additions & 17 deletions src/lib/bootloader/systemdboot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,10 @@ def read
def write(etc_only: false)
super
log.info("Writing settings...")
if Yast::Stage.initial # while new installation only (currently)
install_bootloader
create_menue_entries
end
install_bootloader if Yast::Stage.initial # while new installation only (currently)
create_menue_entries
write_menue_timeout

File.open(File.join(Yast::Installation.destdir, CMDLINE), "w+") do |fw|
fw.puts(kernel_params.serialize)
end
true
end

Expand Down Expand Up @@ -205,17 +200,15 @@ def write_sysconfig(prewrite: false)
SDBOOTUTIL = "/usr/bin/sdbootutil"

def create_menue_entries
cmdline_file = File.join(Yast::Installation.destdir, CMDLINE)
if Yast::Stage.initial
# sdbootutil script needs the "root=<device>" entry in kernel parameters.
# This will be written to CMDLINE which will be used in an
# installed system by the administrator only. So we can use it because
# the system will be installed new. This file will be deleted after
# calling sdbootutil.
File.open(cmdline_file, "w+") do |fw|
fw.puts("root=#{Yast::BootStorage.root_partitions.first.name}")
# writing kernel parameter to /etc/kernel/cmdline
File.open(File.join(Yast::Installation.destdir, CMDLINE), "w+") do |fw|
if Yast::Stage.initial # while new installation only
fw.puts("root=#{Yast::BootStorage.root_partitions.first.name} #{kernel_params.serialize}")
else # root entry is already available
fw.puts(kernel_params.serialize)
end
end

begin
Yast::Execute.on_target!(SDBOOTUTIL, "--verbose", "add-all-kernels")
rescue Cheetah::ExecutionFailed => e
Expand All @@ -227,7 +220,6 @@ def create_menue_entries
), command: e.commands.inspect, stderr: e.stderr)
)
end
File.delete(cmdline_file) if Yast::Stage.initial # see above
Copy link
Contributor

Choose a reason for hiding this comment

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

Has the file to be kept?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes :-)

end

def read_menue_timeout
Expand Down
4 changes: 2 additions & 2 deletions test/systemdboot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# Checking written kernel parameters
subject.read
expect(subject.cpu_mitigations.to_human_string).to eq "Off"
expect(subject.kernel_params.serialize).to eq cmdline_content
expect(subject.kernel_params.serialize).to include cmdline_content
end

it "creates menue entries" do
Expand Down Expand Up @@ -137,7 +137,7 @@
expect(subject.secure_boot).to eq true
expect(subject.menue_timeout).to eq 12
expect(subject.cpu_mitigations.to_human_string).to eq "Auto"
expect(subject.kernel_params.serialize).to eq "security=apparmor splash=silent quiet mitigations=auto"
expect(subject.kernel_params.serialize).to include "security=apparmor splash=silent quiet mitigations=auto"
end
end

Expand Down