diff options
-rw-r--r-- | perl-install/bootloader.pm | 33 | ||||
-rw-r--r-- | perl-install/install/NEWS | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index fee1d22e1..496ac1ee4 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -1685,12 +1685,45 @@ sub sync_partition_data_to_disk { } } +sub _dev_to_MBR_backup { + my ($dev) = @_; + $dev =~ s!/dev/!!; + $dev =~ s!/!_!g; + "$::prefix/boot/boot.backup.$dev"; +} + +sub save_previous_MBR_bootloader { + my ($dev) = @_; + my $t; + open(my $F, $dev); + CORE::read($F, $t, 0x1b8); #- up to disk magic + output(_dev_to_MBR_backup($dev), $t); +} + +sub restore_previous_MBR_bootloader { + my ($dev) = @_; + log::l("restoring previous bootloader on $dev"); + output($dev, scalar cat_(_dev_to_MBR_backup($dev))); +} + sub install_grub { my ($bootloader, $all_hds) = @_; write_grub($bootloader, $all_hds); if (!$::testing) { + if ($bootloader->{previous_boot} && $bootloader->{previous_boot} eq $bootloader->{boot}) { + # nothing to do + } else { + if ($bootloader->{previous_boot}) { + restore_previous_MBR_bootloader(delete $bootloader->{previous_boot}); + } + if (fs::get::device2part($bootloader->{boot}, [ fs::get::hds($all_hds) ])) { + save_previous_MBR_bootloader($bootloader->{boot}); + $bootloader->{previous_boot} = $bootloader->{boot}; + } + } + my @files = grep { /(stage1|stage2|_stage1_5)$/ } glob("$::prefix/lib/grub/*/*"); cp_af(@files, "$::prefix/boot/grub"); sync_partition_data_to_disk(fs::get::root([ fs::get::fstab($all_hds) ], 'boot')); diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS index 4287cfdcf..02ee14218 100644 --- a/perl-install/install/NEWS +++ b/perl-install/install/NEWS @@ -1,3 +1,5 @@ +- save bootloader on MBR when calling grub/install.sh, and restore it before + calling it again (#35255) (ie implement "lilo -u" for grub) - ensure /etc/sysconfig/console/default.kmap is generated with installed keymaps, not installer simplified (?) .bkmap (#35376) - add /etc/mke2fs.conf symlink so that mke2fs can use it (cf #27377) |