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

Using BLS bootloader as default. #1396

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions doc/boot-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
- **requires new partitions for /boot/efi and for /boot (Grub2 auto-config cannot handle LUKS2)**
- if there is already a suitable EFI partition in the boot disk
- **requires to reuse EFI and create a /boot partition (Grub2 auto-config cannot handle LUKS2)**
- when proposing a new EFI partition
- and BLS installation is not explicitly disabled
- when aiming for the recommended size
- **requires /boot/efi to use FAT32**
- **requires /boot/efi to have exactly 1 GiB (enough space for all BLS entries)**
- and BLS installation is explicitly disabled
- when aiming for the recommended size
- **does not enforce FAT32 or 16 for /boot/efi (FAT size will be decided by mkfs.vfat)**
- **requires /boot/efi to be exactly 128 MiB large**
- when aiming for the minimal size
- **does not enforce FAT32 or 16 for /boot/efi (FAT size will be decided by mkfs.vfat)**
- **requires /boot/efi to be exactly 128 MiB large**

## needed partitions in a PPC64 system
- in a non-PowerNV system (KVM/LPAR)
Expand Down Expand Up @@ -325,19 +337,24 @@
- **requires it to be a non-encrypted partition**
- when aiming for the recommended size
- **requires it to be at least 4 MiB (Grub2 stages 1+2, needed Grub modules and extra space)**
- **requires it to be at most 8 MiB (anything bigger would mean wasting space)**
- **requires it to be at most 8 MiB (or optimal I/O size, bsc#1192448) for firmware to load it**
- when aiming for the minimal size
- **requires it to be at least 2 MiB (Grub2 stages 1+2 and needed Grub modules)**
- **requires it to be at most 8 MiB (anything bigger would mean wasting space)**
- **requires it to be at most 8 MiB (or optimal I/O size, bsc#1192448) for firmware to load it**
- when proposing a new EFI partition
- **requires /boot/efi to be on the boot disk**
- **requires /boot/efi to be a non-encrypted vfat partition**
- **requires /boot/efi to be close enough to the beginning of disk**
- when aiming for the recommended size
- **requires /boot/efi to use FAT32**
- **requires it to be at least 256 MiB (min size for FAT32 in drives with 4-KiB-per-sector)**
- **requires it to be at most 512 MiB (enough space for several operating systems)**
- when aiming for the minimal size
- **does not enforce FAT32 or 16 for /boot/efi (FAT size will be decided by mkfs.vfat)**
- **requires it to be at least 128 MiB (MS Windows requires 100 MiB for itself)**
- **requires it to be at most 512 MiB (enough space for several operating systems)**
- and BLS installation is not explicitly disabled
- when aiming for the recommended size
- **requires /boot/efi to use FAT32**
- **requires /boot/efi to have exactly 1 GiB (enough space for all BLS entries)**
- and BLS installation is explicitly disabled
- when aiming for the recommended size
- **requires /boot/efi to use FAT32**
- **requires it to be at least 256 MiB (min size for FAT32 in drives with 4-KiB-per-sector)**
- **requires it to be at most 512 MiB (enough space for several operating systems)**
- when aiming for the minimal size
- **does not enforce FAT32 or 16 for /boot/efi (FAT size will be decided by mkfs.vfat)**
- **requires it to be at least 128 MiB (MS Windows requires 100 MiB for itself)**
- **requires it to be at most 512 MiB (enough space for several operating systems)**
6 changes: 6 additions & 0 deletions package/yast2-storage-ng.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Jan 9 14:43:14 UTC 2025 - Stefan Schubert <[email protected]>

- Reserve 1GiB boot partition for grub2-bls bootloader (jsc#PED-10703).
- 5.0.23

-------------------------------------------------------------------
Fri Nov 29 10:23:28 UTC 2024 - Josef Reidinger <[email protected]>

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

Name: yast2-storage-ng
Version: 5.0.22
Version: 5.0.23
Release: 0
Summary: YaST2 - Storage Configuration
License: GPL-2.0-only OR GPL-3.0-only
Expand Down
11 changes: 10 additions & 1 deletion src/lib/y2storage/boot_requirements_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
require "yast"
require "y2storage/boot_requirements_strategies"
require "y2storage/storage_manager"
require "y2storage/storage_env"

Yast.import "Arch"

module Y2Storage
#
Expand Down Expand Up @@ -137,7 +140,13 @@ def strategy_class
# @return [BootRequirementsStrategies::Base]
def arch_strategy_class
if arch.efiboot?
BootRequirementsStrategies::UEFI
if StorageEnv.instance.no_bls_bootloader ||
(!arch.x86? && !Yast::Arch.aarch64)
BootRequirementsStrategies::UEFI
else
# BLS is for x86_64 and aarch64 only
BootRequirementsStrategies::BLS
end
elsif arch.s390?
BootRequirementsStrategies::ZIPL
elsif arch.ppc?
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2storage/boot_requirements_strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
require "y2storage/boot_requirements_strategies/zipl"
require "y2storage/boot_requirements_strategies/nfs_root"
require "y2storage/boot_requirements_strategies/raspi"
require "y2storage/boot_requirements_strategies/bls"
47 changes: 47 additions & 0 deletions src/lib/y2storage/boot_requirements_strategies/bls.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) [2024] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2storage/boot_requirements_strategies/uefi"

module Y2Storage
module BootRequirementsStrategies
# Strategy to calculate boot requirements in BLS/UEFI systems
class BLS < UEFI
def initialize(*args)
textdomain "storage"
super
end

protected

# @return [VolumeSpecification]
def efi_volume
if @efi_volume.nil?
@efi_volume = volume_specification_for("/boot/efi")
# BLS suggests 1GiB for boot partition
# https://uapi-group.org/specifications/specs/boot_loader_specification/
@efi_volume.min_size = DiskSize.MiB(512)
@efi_volume.desired_size = DiskSize.GiB(1)
@efi_volume.max_size = DiskSize.GiB(1)
end
@efi_volume
end
end
end
end
11 changes: 10 additions & 1 deletion src/lib/y2storage/storage_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class StorageEnv

ENV_REUSE_LVM = "YAST_REUSE_LVM".freeze

ENV_NO_BLS_BOOT = "YAST_NO_BLS_BOOT".freeze

private_constant :ENV_MULTIPATH, :ENV_BIOS_RAID, :ENV_ACTIVATE_LUKS
private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS
private_constant :ENV_REUSE_LVM
private_constant :ENV_REUSE_LVM, :ENV_NO_BLS_BOOT

def initialize
reset_cache
Expand Down Expand Up @@ -93,6 +95,13 @@ def requested_lvm_reuse
env_str_to_bool(value)
end

# Whether YaST should not use bls bootloaders
#
# @return [Boolean]
def no_bls_bootloader
active?(ENV_NO_BLS_BOOT)
end

# Whether errors during libstorage probing should be ignored.
#
# See bsc#1177332:
Expand Down
10 changes: 10 additions & 0 deletions test/support/boot_requirements_uefi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,13 @@
end
end
end

RSpec.shared_context "BLS bootloader not disabled" do
context "and BLS installation is not explicitly disabled" do
before do
allow(Y2Storage::StorageEnv.instance).to receive(:no_bls_bootloader).and_return(false)
end

include_examples "EFI partition for BLS bootloaders"
end
end
17 changes: 17 additions & 0 deletions test/support/proposed_partitions_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,23 @@
end
end

RSpec.shared_examples "EFI partition for BLS bootloaders" do
using Y2Storage::Refinements::SizeCasts

context "when aiming for the recommended size" do
let(:target) { :desired }

it "requires /boot/efi to use FAT32" do
expect(efi_part.mkfs_options).to include "-F32"
end

it "requires /boot/efi to have exactly 1 GiB (enough space for all BLS entries)" do
expect(efi_part.min_size).to eq 1.GiB
expect(efi_part.max_size).to eq 1.GiB
end
end
end

RSpec.shared_examples "minimalistic EFI partition" do
using Y2Storage::Refinements::SizeCasts

Expand Down
14 changes: 14 additions & 0 deletions test/y2storage/boot_requirements_checker_aarch64_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,19 @@
end

include_context "plain UEFI"

context "when proposing a new EFI partition" do
let(:efi_part) { find_vol("/boot/efi", checker.needed_partitions(target)) }
let(:desired_efi_part) { find_vol("/boot/efi", checker.needed_partitions(:desired)) }

include_examples "BLS bootloader not disabled"
context "and BLS installation is explicitly disabled" do
before do
allow(Y2Storage::StorageEnv.instance).to receive(:no_bls_bootloader).and_return(true)
end

include_examples "minimalistic EFI partition"
end
end
end
end
10 changes: 9 additions & 1 deletion test/y2storage/boot_requirements_checker_x86_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@
let(:efi_partitions) { [] }

include_examples "proposed EFI partition basics"
include_examples "flexible size EFI partition"
include_examples "BLS bootloader not disabled"

context "and BLS installation is explicitly disabled" do
before do
allow(Y2Storage::StorageEnv.instance).to receive(:no_bls_bootloader).and_return(true)
end

include_examples "flexible size EFI partition"
end
end
end
end
Expand Down
Loading