From ff4d256a950648b12348a42ef11dea8dd19c7453 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 15 Jun 2020 16:37:15 +0100 Subject: When installing on a removable device, suggest an ESP on that device. We must update the suggestions each time the user selects a different target device. --- perl-install/fsedit.pm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'perl-install/fsedit.pm') diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 2fcd1f1ee..684d802d7 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -43,23 +43,27 @@ use fs; my %bck_suggestions = %suggestions; sub init_mntpnt_suggestions { - my ($all_hds, $o_force) = @_; - my $fstab = [ fs::get::fstab($all_hds) ]; - state $done; - return if $done && !$o_force; - $done++; + my ($all_hds, $o_target, $o_force) = @_; + + my $device = $o_target ? $o_target->{device} : 'all'; + state $last_device; + return if $device eq $last_device && !$o_force; + $last_device = $device; + + #- If installing on a removable device, assume that the user wants that device to be self-bootable. + my $is_removable = $o_target && $o_target->{is_removable}; + my @fstab = $is_removable ? partition_table::get_normal_parts($o_target) : fs::get::fstab($all_hds); my $mntpoint; # only suggests /boot/EFI if there's not already one: require fs::any; if (is_uefi()) { - if (!any { isESP($_) } @$fstab) { + if (!any { isESP($_) } @fstab) { $mntpoint = { mntpoint => "/boot/EFI", size => MB(100), pt_type => 0xef, ratio => 1, maxsize => MB(300) }; } } - return if !$mntpoint; foreach (keys %suggestions) { - $suggestions{$_} = [ $mntpoint, @{$bck_suggestions{$_}} ]; + $suggestions{$_} = [ if_($mntpoint, $mntpoint), @{$bck_suggestions{$_}} ]; } } @@ -515,6 +519,11 @@ sub auto_allocate { my ($all_hds, $o_suggestions, $o_target) = @_; my $before = listlength(fs::get::fstab($all_hds)); + #- Make sure we don't finish with more than one /boot/EFI mount point + if (is_uefi()) { + delete $_->{mntpoint} foreach grep { $_->{mntpoint} eq '/boot/EFI' } fs::get::fstab($all_hds); + } + auto_allocate_bios_boot_parts($all_hds, $o_target) if !is_uefi(); my $suggestions = $o_suggestions || $suggestions{simple}; @@ -540,6 +549,10 @@ sub auto_allocate { die N("Nothing to do"); } } + + #- Don't suggest mount points on other drives when installing on a removable disk + return if $o_target && $o_target->{is_removable}; + my @fstab = fs::get::fstab($all_hds); fs::mount_point::suggest_mount_points_always(\@fstab); } -- cgit v1.2.1