Skip to content

Commit

Permalink
Writing "root" entry into /etc/kernel/cmdline which is needed by sdbo…
Browse files Browse the repository at this point in the history
…otutil (#701)

* writing /etc/kernel/cmdline before calling sdbootutil
* set root in cmdline only while new installation
  • Loading branch information
schubi2 committed May 3, 2024
1 parent d5388e6 commit eda6950
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
7 changes: 7 additions & 0 deletions package/yast2-bootloader.changes
@@ -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
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
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
end

def read_menue_timeout
Expand Down
4 changes: 2 additions & 2 deletions test/systemdboot_test.rb
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

0 comments on commit eda6950

Please sign in to comment.