diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-03-21 16:49:14 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-03-21 16:49:14 +0000 |
commit | e219385e870764ee4a6b7f9d26e8617eec60f172 (patch) | |
tree | a63e34f728c7f83bc6fea4fb3b1f60eef40c0881 /perl-install | |
parent | 142593316e874567dfaa7164a6a7c36d46ea7f30 (diff) | |
download | drakx-e219385e870764ee4a6b7f9d26e8617eec60f172.tar drakx-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.gz drakx-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.bz2 drakx-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.xz drakx-e219385e870764ee4a6b7f9d26e8617eec60f172.zip |
- bootloader-config, drakboot:
o fix device.map if it is not consistent with the system
(eg: it says hd0 in sdb whereas it now is sda) (#39160)
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/NEWS | 3 | ||||
-rw-r--r-- | perl-install/bootloader.pm | 28 |
2 files changed, 29 insertions, 2 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS index 807eb181c..eeda0f57b 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,3 +1,6 @@ +- bootloader-config, drakboot: + o fix device.map if it is not consistent with the system + (eg: it says hd0 in sdb whereas it now is sda) (#39160) - diskdrake: o fix setting mount point of a /dev/mdX (#39142) (regression introduced in 10.8) diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 845674276..adca7a9d3 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -209,16 +209,40 @@ sub read_grub { my ($fstab) = @_; my $grub2dev = read_grub_device_map(); + my $boot_root = read_grub_install_sh(); + _may_fix_grub2dev($fstab, $grub2dev, $boot_root->{root}); my $bootloader = read_grub_menu_lst($fstab, $grub2dev) or return; - if (my $boot = read_grub_install_sh()->{boot}) { - $bootloader->{boot} = grub2dev($boot, $grub2dev); + if ($boot_root->{boot}) { + $bootloader->{boot} = grub2dev($boot_root->{boot}, $grub2dev); } $bootloader; } +sub _may_fix_grub2dev { + my ($fstab, $grub2dev, $root) = @_; + my $real_root_part = fs::get::root($fstab); + + if (my $prev_root_part = fs::get::device2part(grub2dev($root, $grub2dev), $fstab)) { # the root_device as far as grub config files say + $real_root_part == $prev_root_part and return; + } + + log::l("WARNING: we have detected that device.map is inconsistent with the system"); + + my $real_root_dev = $real_root_part->{rootDevice}; + + my ($hd_grub, undef, undef) = parse_grub_file($root); + if (my $prev_hd_grub = find { $grub2dev->{$_} eq $real_root_dev } keys %$grub2dev) { + $grub2dev->{$prev_hd_grub} = $grub2dev->{$hd_grub}; + log::l("swapping result: $hd_grub/$real_root_dev and $prev_hd_grub/$grub2dev->{$hd_grub}"); + } else { + log::l("argh... can't swap, setting $hd_grub to $real_root_dev anyway"); + } + $grub2dev->{$hd_grub} = $real_root_dev; +} + sub read_grub_install_sh() { my $s = cat_("$::prefix/boot/grub/install.sh"); my %h; |