Bug#666974: installs to /dev/sda when grub-installer/bootdev = /dev/sdb

2014-02-19 Thread Guilhem Moulin
Package: grub-installer
Version: 1.85
Followup-For: Bug #666974
Tags: patch

Dear Maintainer,

The bug is still present in Wheezy's installer.  The enclosed (naive)
patch makes sure grub-installer jumps to state 2 (hence ignores
$default_bootdev) if grub-installer/bootdev is known.  It has been
successfully tested on manual and automated installations with and
without preseeding grub-installer/bootdev.


-8--8-

diff -ru a/grub-installer b/grub-installer
--- a/grub-installer
+++ b/grub-installer
@@ -599,7 +599,7 @@
exit 10
fi
db_get $q
-   if [ $RET = true ]; then
+   if [ $RET = true ]  ! db_get grub-installer/bootdev; then
bootdev=$default_bootdev
break
else

-8--8-


Cheers,
-- 
Guilhem.


signature.asc
Description: Digital signature


Bug#666974: installs to /dev/sda when grub-installer/bootdev = /dev/sdb

2014-02-19 Thread Dimitri John Ledkov
On 19 February 2014 20:02, Guilhem Moulin guil...@guilhem.org wrote:
 Package: grub-installer
 Version: 1.85
 Followup-For: Bug #666974
 Tags: patch

 Dear Maintainer,

 The bug is still present in Wheezy's installer.  The enclosed (naive)
 patch makes sure grub-installer jumps to state 2 (hence ignores
 $default_bootdev) if grub-installer/bootdev is known.  It has been
 successfully tested on manual and automated installations with and
 without preseeding grub-installer/bootdev.



I agree with below patch. I've had to deal with a few support cases
where this was the end goal.

Similarly, a very comparable patch was proposed to me not so long ago

https://launchpadlibrarian.net/165315548/lp1012629.trusty.debdiff

With essentially the same spirit - if grub-installer/bootdev is
preseeded it must be used and nothing else.

I'll compare the logic of the two, but by memory, they appear
equivalent to me. I'd be inclined to take the Guilhem's version as I
prefer one-liners better ;-)

 -8--8-

 diff -ru a/grub-installer b/grub-installer
 --- a/grub-installer
 +++ b/grub-installer
 @@ -599,7 +599,7 @@
 exit 10
 fi
 db_get $q
 -   if [ $RET = true ]; then
 +   if [ $RET = true ]  ! db_get grub-installer/bootdev; then
 bootdev=$default_bootdev
 break
 else

 -8--8-



Thanks a lot.

-- 
Regards,

Dimitri.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#666974: installs to /dev/sda when grub-installer/bootdev = /dev/sdb

2012-11-21 Thread Faidon Liambotis
On Tue, Apr 03, 2012 at 11:24:25AM +1000, Vincent McIntyre wrote:
 When I specify in my preseeding file:
   d-i partman-auto/disk  string  /dev/sdb
   d-i grub-installer/bootdev string  /dev/sdb
 
 grub-installer ignores me and installs to /dev/sda.
 partman-auto does the right thing.
 
 In some cases this can result in an unbootable system.

Indeed, I've experienced this and can confirm the bug. It can also lead
in errors in the installation process: I had a preseeding configuration
in which sda should stay empty and the operating system should be
installed in an entirely different disk; grub-installer tried to install
grub on sda, but sda had no partioning table or MBR whatsoever, which
made it fail with an error.

I've read grub-installer's source though and realized I can work around
it if I set grub-installer/only_debian to false, as this skips directly
to step 2 which then obeys the preseeded bootdev properly.

Regards,
Faidon


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#666974: installs to /dev/sda when grub-installer/bootdev = /dev/sdb

2012-04-02 Thread Vincent McIntyre
Package: grub-installer
Version: 1.60+squeeze3
Severity: important

*** Please type your report below this line ***

When I specify in my preseeding file:
  d-i partman-auto/disk  string  /dev/sdb
  d-i grub-installer/bootdev string  /dev/sdb

grub-installer ignores me and installs to /dev/sda.
partman-auto does the right thing.

In some cases this can result in an unbootable system.

Attached is a syslog excerpt for the execution of grub-installer,
with DEBCONF_DEBUG=5 set in the boot line. You can see that it
reads in the right disk name from the preseeding file, but somewhere
in the step_os_probe .. step_bootdev .. step_install_loader sequence it
changes $bootdev to /dev/sda.

I have also observed (on other installations, using software RAID-1) that
  d-i grub-installer/bootdev string  /dev/sda /dev/sdb
is read in but also ultimately ignored and grub-installer only installs to
/dev/sda.



This installation was on a machine with two hard disks of identical size,
but only one was intended to be used in the installation.
The partioning was one ext3 partition for /, and one LVM for everything else.
No separate /boot partition. No software raid is specified.

I was able to stop the installer at the end and ran grub-installer again
on one of the installer consoles:

  sh -vx /usr/bin/grub-installer /target 1/target/var/log/gi 21

This shows the problem comes when parsing the grub-mkdevicemap output.

+ os-prober
+ db_settitle debian-installer/grub-installer/title
+ _db_cmd SETTITLE debian-installer/grub-installer/title
+ IFS=  printf %s\n SETTITLE debian-installer/grub-installer/title
+ IFS=
 read -r _db_internal_line
+ RET=OK
+ return 0
+ tmpfile=/tmp/menu.lst.extras
+ [ -s /tmp/os-probed ]
+ q=grub-installer/only_debian
+ state=1
+ [  ]
+ chroot /target grub-mkdevicemap --no-floppy -m+  -head -n1
+ cut -f2
+ default_bootdev_os=/dev/disk/by-id/scsi-35000c50017a6040b
+ [ /dev/disk/by-id/scsi-35000c50017a6040b ]
+ chroot /target readlink -f /dev/disk/by-id/scsi-35000c50017a6040b
+ default_bootdev=/dev/sda

when I run that grub-mkdevicemap on the host after installation, I get:

# grub-mkdevicemap --no-floppy -m -
(hd0)   /dev/disk/by-id/scsi-35000c50017a6040b
(hd1)   /dev/disk/by-id/scsi-35000c50017a7843b

so it seems that there is a disconnect here from the specification
of $bootdev and the attempt to guess $default_bootdev_os.

The consequences are as follows.

A little further down the script there is this, er, dense if statement:

case $ARCH:$grub_package in
*:grub|*:grub-pc|sparc:grub-ieee1275)
if [ $(device_to_disk $cdsrc) = $default_bootdev ] || \
   ([ -n $hdsrc ]  [ $(device_to_disk $hdsrc) = 
$default_bootdev ]) || \
   ([ $default_bootdev = '(hd0)' ]  \
(([ -n $cdfs ]  [ $cdfs != iso9660 ]) || \
 [ $hybrid = true ])) || \
   ([ $default_bootdev != '(hd0)' ]  \
! partmap $default_bootdev /dev/null  \
! grub_probe -t fs -d $default_bootdev /dev/null); then
db_fget grub-installer/bootdev seen
if [ $RET != true ]; then
bootfs=$(findfs /boot)
[ $bootfs ] || bootfs=$(findfs /)
disk=$(device_to_disk $bootfs)
db_set grub-installer/bootdev $disk
state=2
fi
fi
;;
...

This fails out at the $default_bootdev = '(hd0)' comparison.
+ device_to_disk
+ echo
+ sed 
s:\(/dev/\(cciss\|ida\|rs\)/c[0-9]d[0-9][0-9]*\|/dev/mmcblk[0-9]\|/dev/\(ad\|da\)[0-9]\+\|/dev/[a-z]\+\).*:\1:
+ [  = /dev/sda ]
+ [ -n  ]
+ [ /dev/sda = (hd0) ]

Then we come to step_bootdev, a loop that continues until we have a suitable
value of $state. There $default_bootdev supercedes what I set $bootdev to.
$state is already set to 1 and $q to grub-installer/only_debian (see above).

db_progress STEP 1
db_progress INFO grub-installer/progress/step_bootdev

while : ; do
if [ $state = 1 ]; then
db_input high $q || true
if ! db_go; then
# back up to menu
db_progress STOP
exit 10
fi
db_get $q
if [ $RET = true ]; then
bootdev=$default_bootdev
break
else
# Exit to menu if /boot is on SATA RAID/multipath; we
# don't support device selection in that case
if [ $frdev ]; then
db_progress STOP
exit 10
fi
state=2
fi
...

+ db_progress STEP 1
+ _db_cmd PROGRESS STEP 1
+ IFS=  printf %s\n PROGRESS STEP 1
+ IFS=
 read -r _db_internal_line
   RET=OK
+ return 0
+ db_progress INFO grub-installer/progress/step_bootdev
+ _db_cmd PROGRESS