From daf8670c08e54ac64407f7f209aaf9b460abdcc6 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 4 Feb 2017 23:46:14 +0000 Subject: Fix auto-allocation of BIOS boot partitions (mga#20161, mga#19888). This adds a specific subroutine, fsedit::auto_allocate_boot_bios_parts that detects if a BIOS boot partition is needed and allocates it if so. This allows us to relax the rules in fs::any::is_boot_bios_part_needed to allow the user to manually allocate the BIOS boot partition on a different device if they so wish. In the normal case that installation is confined to a single disk, this will allocate a single BIOS boot partition on that disk. In the rare case that installation is spread over multiple disks, it will allocate a BIOS boot partition on every disk. Given that the BIOS boot partitions are very small and that this is not a normal use case (see mga#16055), this seems an acceptable quirk - and does allow the user to then choose any disk when installing the boot loader. --- perl-install/fsedit.pm | 21 ++++++++++++++++++--- perl-install/partition_table.pm | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 114039baf..cfde46dd6 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -56,9 +56,6 @@ sub init_mntpnt_suggestions { if (!any { isESP($_) } @$fstab) { $mntpoint = { mntpoint => "/boot/EFI", size => MB(100), pt_type => 0xef, ratio => 1, maxsize => MB(300) }; } - } elsif (fs::any::is_boot_bios_part_needed($all_hds, $fstab)) { - # suggests a Boot BIOS partition if none is present and if needed (aka !UEFI but disk is GPT partitionned) - $mntpoint = { mntpoint => "", size => MB(1), pt_type => 'BIOS_BOOT', ratio => 1, maxsize => MB(2) }; } return if !$mntpoint; foreach (keys %suggestions) { @@ -518,6 +515,8 @@ sub auto_allocate { my ($all_hds, $o_suggestions, $o_target) = @_; my $before = listlength(fs::get::fstab($all_hds)); + auto_allocate_bios_boot_parts($all_hds, $o_target) if !is_uefi(); + my $suggestions = $o_suggestions || $suggestions{simple}; allocatePartitions($all_hds, $suggestions, $o_target); @@ -545,6 +544,22 @@ sub auto_allocate { fs::mount_point::suggest_mount_points_always(\@fstab); } +sub auto_allocate_bios_boot_parts { + my ($all_hds, $o_hd) = @_; + foreach my $hd (@{$all_hds->{hds}}) { + # skip if not the selected device + next if $o_hd && ($o_hd->{device} ne $hd->{device}); + # skip non-GPT disks + next if ($hd->{pt_table_type} || partition_table::default_type($hd)) ne 'gpt'; + # check if a BIOS boot partition already exists + my @parts = map { partition_table::get_normal_parts($_) } $hd; + next if any { isBIOS_GRUB($_) } @parts; + # try to allocate a BIOS boot partition + my $suggest = { mntpoint => "", size => MB(1), pt_type => 'BIOS_GRUB', ratio => 1, maxsize => MB(2) }; + allocatePartitions($all_hds, [ $suggest ], $hd); + } +} + sub auto_allocate_raids { my ($all_hds, $suggestions) = @_; diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index f0cfc0ec2..4b357abb0 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -310,6 +310,7 @@ sub read_primary { bless $hd, "partition_table::$_"; if ($hd->read_primary) { log::l("found a $_ partition table on $hd->{file} at sector 0"); + $hd->{pt_table_type} = $_ if $_ ne 'empty'; return 1; } } -- cgit v1.2.1