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

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



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 2>&1

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 INFO grub-installer/progress/step_bootdev
+ IFS=  printf %s\n PROGRESS INFO grub-installer/progress/step_bootdev
+ IFS=
 read -r _db_internal_line
	Determining GRUB boot device...       RET=OK
+ return 0
+ :
+ [ 1 = 1 ]
+ db_input high grub-installer/only_debian
+ _db_cmd INPUT high grub-installer/only_debian
+ IFS=  printf %s\n INPUT high grub-installer/only_debian
+ IFS=
 read -r _db_internal_line
+ RET=30 question skipped
+ return 30
+ true
+ db_go
+ _db_cmd GO
+ IFS=
 read -r _db_internal_line
+ RET=ok
+ return 0
+ db_get grub-installer/only_debian
+ _db_cmd GET grub-installer/only_debian
+ IFS=  printf %s\n GET grub-installer/only_debian
+ IFS=
 read -r _db_internal_line
+ RET=true
+ return 0
+ [ true = true ]
+ bootdev=/dev/sda
+ break
+ db_progress STEP 1
+ _db_cmd PROGRESS STEP 1
+ IFS=  printf %s\n PROGRESS STEP 1
+ IFS=
 read -r _db_internal_line
	5	 RET=OK
+ return 0
+ db_subst grub-installer/progress/step_install_loader BOOTDEV /dev/sda
+ _db_cmd SUBST grub-installer/progress/step_install_loader BOOTDEV /dev/sda
+ IFS=  printf %s\n SUBST grub-installer/progress/step_install_loader BOOTDEV /dev/sda
+ IFS=
 read -r _db_internal_line
+ RET=0
+ return 0
+ db_progress INFO grub-installer/progress/step_install_loader
+ _db_cmd PROGRESS INFO grub-installer/progress/step_install_loader
+ IFS=  printf %s\n PROGRESS INFO grub-installer/progress/step_install_loader
+ IFS=
 read -r _db_internal_line
	Running "grub-install /dev/sda"...	 RET=OK
+ return 0
+ info Installing grub on '/dev/sda'
+ log info: Installing grub on '/dev/sda'
+ logger -t grub-installer info: Installing grub on '/dev/sda'


preseeding details:

d-i partman-auto/method                string  lvm
d-i partman-auto/disk                  string  /dev/sdb
d-i grub-installer/bootdev             string  /dev/sdb

d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/grub2_instead_of_grub_legacy boolean true

d-i partman-auto-lvm/no_boot           boolean true

d-i partman-md/device_remove_md        boolean true
d-i partman-md/confirm boolean true

d-i partman-lvm/device_remove_lvm      boolean true
d-i partman-lvm/confirm                boolean true

d-i partman/choose_partition           select  finish
d-i partman/confirm                    boolean true

d-i partman/mount_style select uuid

d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/confirm_nooverwrite boolean true

d-i partman-auto/expert_recipe         string  my_server : \
    2048 2000 2048 ext3        \
        $primary{ }            \
        $bootable{ }           \
        method{ format }       \
        format{ }              \
        use_filesystem{ }      \
        filesystem{ ext3 }     \
        label{ root }          \
        mountpoint{ / }        \
    .                          \
    100% 2000 200% linux-swap  \
        $defaultignore{ }      \
        $lvmok{ }              \
        method{ swap }         \
        format{ }              \
    .                          \
    10240 1000 10240 ext3      \
        $defaultignore{ }      \
        $lvmok{ }              \
        method{ format }       \
        format{ }              \
        use_filesystem{ }      \
        filesystem{ ext3 }     \
        mountpoint{ /usr }     \
    .                          \
.. etc...

It happens that /dev/sda has a software raid signature, but from the
discussion above I think it is not causing the bug.

# fdisk -l /dev/sda

Disk /dev/sda: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002eb77

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         125      999424   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sda2             125       36473   291968000   fd  Linux raid autodetect

After installation this is the state of /dev/sdb
# fdisk -l /dev/sdb

Disk /dev/sdb: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000de478

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         249     1998848   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2             250       36473   290967553    5  Extended
/dev/sdb5             250       36473   290967552   8e  Linux LVM


I would really like to see this fixed in the stable release, how can I help?


-- System Information:
Debian Release: 6.0.4
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Attachment: syslog.grub-installer.gz
Description: Binary data


Reply to: