[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#666255: [grub-installer] Does not verify list of other operating systems when multiple targets (HDDs) detected



Package: grub-installer
Version: 1.70
Severity: normal

grub-installer generally prompts once, to confirm the list of other operating systems detected:

Template: grub-installer/with_other_os
Type: boolean
Default: true
# :sl1:
_Description: Install the GRUB boot loader to the master boot record?
  The following other operating systems have been detected on this
  computer: ${OS_LIST}
  .
  If all of your operating systems are listed above, then it should be safe to
  install the boot loader to the master boot record of your first hard
  drive. When your computer boots, you will be able to choose to load one of
  these operating systems or your new system.

This is not always the case however. When several possible target devices for installing GRUB are detected, grub-installer prompts:

Template: grub-installer/bootdev
Type: string
# :sl2:
_Description: Device for boot loader installation:
  You need to make the newly installed system bootable, by installing
  the GRUB boot loader on a bootable device. The usual way to do this is to
  install GRUB on the master boot record of your first hard drive. If you
  prefer, you can install GRUB elsewhere on the drive, or to another drive,
  or even to a floppy.
  .
  The device should be specified as a device in /dev. Below are some
  examples:
   - "/dev/sda" will install GRUB to the master boot record of your first
     hard drive;
   - "/dev/sda2" will use the second partition of your first hard drive;
   - "/dev/sdc5" will use the first extended partition of your third hard
     drive;
   - "/dev/fd0" will install GRUB to a floppy.

This prompt is good in this case, but it does not *replace* with_other_os. The list of other operating systems still needs to be confirmed.

When no other operating systems are detected, the prompt is phrased differently, but the idea is the same:

Template: grub-installer/only_debian
Type: boolean
Default: true
# :sl1:
_Description: Install the GRUB boot loader to the master boot record?
  It seems that this new installation is the only operating system
  on this computer. If so, it should be safe to install the GRUB boot loader
  to the master boot record of your first hard drive.
  .
  Warning: If the installer failed to detect another operating system that
  is present on your computer, modifying the master boot record will make
  that operating system temporarily unbootable, though GRUB can be manually
  configured later to boot it.

However, the phrasing here mixes a question about the target with a question whether to install GRUB in general. This should simply say "Install the GRUB boot loader?" Same for with_other_os, in fact.


Hum, there's a lot of cleanup to do here...
The code relevant to this specific problem is:

 574 while : ; do
 575         if [ "$state" = 1 ]; then
 576                 db_input high $q || true
 577                 if ! db_go; then
 578                         # back up to menu
 579                         db_progress STOP
 580                         exit 10
 581                 fi
 582                 db_get $q
 583                 if [ "$RET" = true ]; then
 584                         bootdev="$default_bootdev"
 585                         break
 586                 else
587 # Exit to menu if /boot is on SATA RAID/multipath; we
 588                         # don't support device selection in that case
 589                         if [ "$frdev" ]; then
 590                                 db_progress STOP
 591                                 exit 10
 592                         fi
 593                         state=2
 594                 fi
 595         elif [ "$state" = 2 ]; then
 596                 db_input critical grub-installer/bootdev || true
 597                 if ! db_go; then
 598                         if [ "$q" ]; then
 599                                 state=1
 600                         else
 601                                 # back up to menu
 602                                 db_progress STOP
 603                                 exit 10
 604                         fi
 605                 else
 606                         db_get grub-installer/bootdev
 607                         bootdev=$RET
 608                         if echo "$bootdev" | grep -qv '('; then
609 mappedbootdev=$(mapdevfs "$bootdev") || true
 610                                 if [ -n "$mappedbootdev" ]; then
 611                                         bootdev="$mappedbootdev"
 612                                 fi
 613                         fi
 614                         break
 615                 fi
 616         else
 617                 break
 618         fi
 619 done

This could be solved by setting state to 1 at the end of the else (line 613). But then, grub-installer would prompt for bootdev and only then for only_debian/with_other_os, which would mean asking where to install before asking whether to install. I think this loop should be simplified to 2 loops, a first that unconditionally (priority high) requests a confirmation of detected other OS-es, and a second that may prompt for GRUB's target. The state variable is too complicated. It should be replaced by a simple boolean, say $severalbootdevices, if nothing else needs to be stored.

The relevant variables are set above, basically:

 496         if [ -n "$unsupported_os_list" ]; then
497 # Unsupported OS, jump straight to manual boot device question.
 498                 state=2
 499         else
 500                 q=grub-installer/with_other_os
 501                 db_subst $q OS_LIST "$supported_os_list"
 502                 state=1
 503         fi
 504 else
 505         q=grub-installer/only_debian
 506         state=1
 507 fi
508


By the way, bootdev is not asked when a single boot device exists, but it allows to install to a partition rather than to the MBR, which is useful even if a single HDD is detected. It seems to me the question should be asked at lowest priority in any case, and at critical priority when several boot devices are detected.

This doesn't look too hard, but I'm not sure what the parts about frdev/multipath do.



Reply to: