• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[solved] grub-install in root-Partition schlägt fehl

AlGaN

Newbie
Hallo,

entsprechend der Anweisung von haveaniceday mache ich zu meinem Problem ein neues Thema auf (s. http://www.linux-club.de/ftopic86190.html )

Situation: Installation von grub in Boot-Sektor der /boot-Partition von openSuse 10.3 (liegt auf /dev/sda6), bisher hatte ich es immer so eingerichtet, dass durch Kopieren des Bootsektors von /dev/sda6 in eine Datei bootsek.lin, die nach C:\ kopiert wird, der XP-Bootloader grub lädt.

Wie gesagt, grub-install.unsupported gibt einen Fehler nach dem Aufruf:
Code:
/usr/sbin/grub-install.unsupported /dev/sda6

Die von haveaniceday gewünschte Ausgabe:
core2:~ # bash -x usr/sbin/grub-install.unsupported /dev/sda6
+ prefix=/usr
+ exec_prefix=/usr
+ sbindir=/usr/sbin
+ libdir=/usr/lib
+ PACKAGE=grub
+ VERSION=0.97
+ host_cpu=i386
+ host_os=linux-gnu
+ host_vendor=suse
+ pkglibdir=/usr/lib/grub/
+ grub_shell=/usr/sbin/grub
+ grub_set_default=/usr/sbin/grub-set-default
+ log_file=/tmp/grub-install.log.6348
+ img_file=/tmp/grub-install.img.6348
+ rootdir=
+ grub_prefix=/boot/grub
+ install_device=
+ no_floppy=
+ force_lba=
+ recheck=no
+ debug=no
+ test -x /bin/tempfile
+ test -x /bin/mktemp
+ mklog='/bin/mktemp /tmp/grub-install.log.XXXXXX'
+ mkimg='/bin/mktemp /tmp/grub-install.img.XXXXXX'
+ for option in '"$@"'
+ case "$option" in
+ test x '!=' x
+ install_device=/dev/sda6
+ test x/dev/sda6 = x
+ test no = yes
+ case "$host_os" in
+ bootdir=/boot
+ grubdir=/boot/grub
+ device_map=/boot/grub/device.map
+ set /usr/sbin/grub dummy
+ test -f /usr/sbin/grub
+ :
+ test -f /usr/lib/grub//stage1
+ :
+ test -f /usr/lib/grub//stage2
+ :
+ test -d /boot
+ test -d /boot/grub
+ test no = yes
+ test -f /boot/grub/device.map
+ :
++ sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' /boot/grub/device.map
++ sort
++ uniq -d
++ sed -n 1p
+ tmp=
+ test -n ''
+ case "$install_device" in
++ resolve_symlink /dev/sda6
++ tmp_fname=/dev/sda6
++ test -L /dev/sda6
++ echo /dev/sda6
+ install_device=/dev/sda6
++ convert /dev/sda6
++ test -e /dev/sda6
++ :
++ case "$host_os" in
+++ echo /dev/sda6
+++ sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' -e 's%\(d[0-9]*\)p[0-9]*$%\1%' -e 's%\(fd[0-9]*\)$%\1%' -e 's%/part[0-9]*$%/disc%' -e 's%\(c[0-7]d[0-9]*\).*$%\1%'
++ tmp_disk=/dev/sda
+++ echo /dev/sda6
+++ sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' -e 's%.*d[0-9]*p%%' -e 's%.*/fd[0-9]*$%%' -e 's%.*/floppy/[0-9]*$%%' -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' -e 's%.*c[0-7]d[0-9]*p%%'
++ tmp_part=6
+++ grep -v '^#' /boot/grub/device.map
+++ grep '/dev/sda *$'
+++ sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'
++ tmp_drive='(hd0)'
++ test 'x(hd0)' = x
++ test x6 '!=' x
++ case "$host_os" in
++ echo '(hd0)'
+++ expr 6 - 1
++ sed 's%)$%,5)%'
+ install_drive='(hd0,5)'
+ test 'x(hd0,5)' = x
++ find_device
+++ df /
+++ awk '/\/dev\/|LABEL=|UUID=/{ print $1 }'
++ tmp_fname=/dev/sda7
++ grep -q LABEL=
++ grep -q UUID=
++ test -z /dev/sda7
+++ resolve_symlink /dev/sda7
+++ tmp_fname=/dev/sda7
+++ test -L /dev/sda7
+++ echo /dev/sda7
++ tmp_fname=/dev/sda7
++ echo /dev/sda7
+ root_device=/dev/sda7
++ find_device /boot
+++ df /boot/
+++ awk '/\/dev\/|LABEL=|UUID=/{ print $1 }'
++ tmp_fname=/dev/sda6
++ grep -q LABEL=
++ grep -q UUID=
++ test -z /dev/sda6
+++ resolve_symlink /dev/sda6
+++ tmp_fname=/dev/sda6
+++ test -L /dev/sda6
+++ echo /dev/sda6
++ tmp_fname=/dev/sda6
++ echo /dev/sda6
+ bootdir_device=/dev/sda6
+ test x/dev/sda7 '!=' x/dev/sda6
+ root_device=/dev/sda6
+ grub_prefix=/grub
++ convert /dev/sda6
++ test -e /dev/sda6
++ :
++ case "$host_os" in
+++ echo /dev/sda6
+++ sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' -e 's%\(d[0-9]*\)p[0-9]*$%\1%' -e 's%\(fd[0-9]*\)$%\1%' -e 's%/part[0-9]*$%/disc%' -e 's%\(c[0-7]d[0-9]*\).*$%\1%'
++ tmp_disk=/dev/sda
+++ echo /dev/sda6
+++ sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' -e 's%.*d[0-9]*p%%' -e 's%.*/fd[0-9]*$%%' -e 's%.*/floppy/[0-9]*$%%' -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' -e 's%.*c[0-7]d[0-9]*p%%'
++ tmp_part=6
+++ grep -v '^#' /boot/grub/device.map
+++ grep '/dev/sda *$'
+++ sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'
++ tmp_drive='(hd0)'
++ test 'x(hd0)' = x
++ test x6 '!=' x
++ case "$host_os" in
++ echo '(hd0)'
+++ expr 6 - 1
++ sed 's%)$%,5)%'
+ root_drive='(hd0,5)'
+ test 'x(hd0,5)' = x
++ find_device /boot/grub
+++ df /boot/grub/
+++ awk '/\/dev\/|LABEL=|UUID=/{ print $1 }'
++ tmp_fname=/dev/sda6
++ grep -q LABEL=
++ grep -q UUID=
++ test -z /dev/sda6
+++ resolve_symlink /dev/sda6
+++ tmp_fname=/dev/sda6
+++ test -L /dev/sda6
+++ echo /dev/sda6
++ tmp_fname=/dev/sda6
++ echo /dev/sda6
+ grubdir_device=/dev/sda6
+ test x/dev/sda6 '!=' x/dev/sda6
+ /usr/sbin/grub-set-default --root-directory= default
+ test -n '/bin/mktemp /tmp/grub-install.img.XXXXXX'
++ /bin/mktemp /tmp/grub-install.img.XXXXXX
+ img_file=/tmp/grub-install.img.Ba6413
+ test -n '/bin/mktemp /tmp/grub-install.log.XXXXXX'
++ /bin/mktemp /tmp/grub-install.log.XXXXXX
+ log_file=/tmp/grub-install.log.dA6414
+ for file in '${grubdir}/stage1' '${grubdir}/stage2' '${grubdir}/*stage1_5'
+ count=5
++ echo /boot/grub/stage1
++ sed 's|^/boot/grub|/grub|'
+ tmp=/grub/stage1
+ test 5 -gt 0
+ /usr/sbin/grub --batch --device-map=/boot/grub/device.map
+ grep 'Error [0-9]*: ' /tmp/grub-install.log.dA6414
+ :
+ sleep 1
++ expr 5 - 1
+ count=4
+ test 4 -gt 0
+ /usr/sbin/grub --batch --device-map=/boot/grub/device.map
+ grep 'Error [0-9]*: ' /tmp/grub-install.log.dA6414
+ :
+ sleep 1
++ expr 4 - 1
+ count=3
+ test 3 -gt 0
+ /usr/sbin/grub --batch --device-map=/boot/grub/device.map
+ grep 'Error [0-9]*: ' /tmp/grub-install.log.dA6414
+ :
+ sleep 1
++ expr 3 - 1
+ count=2
+ test 2 -gt 0
+ /usr/sbin/grub --batch --device-map=/boot/grub/device.map
+ grep 'Error [0-9]*: ' /tmp/grub-install.log.dA6414
+ :
+ sleep 1
++ expr 2 - 1
+ count=1
+ test 1 -gt 0
+ /usr/sbin/grub --batch --device-map=/boot/grub/device.map
+ grep 'Error [0-9]*: ' /tmp/grub-install.log.dA6414
+ :
+ sleep 1
++ expr 1 - 1
+ count=0
+ test 0 -gt 0
+ test 0 -eq 0
+ echo 'The file /boot/grub/stage1 not read correctly.'
The file /boot/grub/stage1 not read correctly.
+ exit 1

Und ja, ich war root beim Aufruf.

Danke für alle Hinweise,
AlGaN
 
Kannst du bitte noch die Ausgaben von folgenden Kommandos (als root) posten:
Code:
df
cat /boot/grub/device.map
ls -l /boot/grub/stage1
cho "dump (hd0,5)/grub/stage1 /tmp/grub-install.img.test
quit" | /usr/sbin/grub --batch --device-map=/boot/grub/device.map

Das folgende Kommando schlägt aus meiner Sicht fehl:
Code:
echo "dump (hd0,5)/grub/stage1 /tmp/grub-install.img.test
quit" | /usr/sbin/grub --batch --device-map=/boot/grub/device.map
wobei /tmp/grub-install.img.test ein beliebiger ungenutzter temporärer Filename ist.
Ist dein Filesystem /boot ( mit /boot/grub/stage1 ) auf einem nicht von grub unterstütztem Filesystem ? Oder fehlt /boot/grub/stage1 ?

Haveaniceday
 
OP
A

AlGaN

Newbie
Hallo haveaniceday,

core2:~ # df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda7 5044156 407192 4380732 9% /
udev 1037916 100 1037816 1% /dev
/dev/sda6 806368 27112 738292 4% /boot
/dev/sda9 8064272 160604 7494016 3% /home
/dev/sda10 10080488 620728 8947692 7% /opt
/dev/sda11 25205252 2355952 21568924 10% /usr
/dev/sr1 4302582 4302582 0 100% /media/SU1030.001

core2:~ # cat /boot/grub/device.map
(hd0) /dev/sda

core2:~ # ls -l /boot/grub/stage1
-rw-r--r-- 1 root root 512 Sep 21 23:59 /boot/grub/stage1

echo "dump (hd0,5)/grub/stage1 /tmp/grub-install.img.test quit" | /usr/sbin/grub --batch --device-map=/boot/grub/device.map


GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> dump (hd0,5)/grub/stage1 /tmp/grub-install.img.test quit

Error 17: Cannot mount selected partition

Zum Abschluss noch ein fdisk -l:
core2:~ # fdisk -l
omitting empty partition (5)

Disk /dev/sda: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfbd6fbd6

Device Boot Start End Blocks Id System
/dev/sda1 * 1 6374 51199123+ 7 HPFS/NTFS
/dev/sda2 6375 48641 339509677+ f W95 Ext'd (LBA)
/dev/sda5 6375 12748 51199123+ 7 HPFS/NTFS
/dev/sda6 12749 12850 819283+ 83 Linux
/dev/sda7 12851 13488 5124703+ 83 Linux
/dev/sda8 13489 13743 2048256 82 Linux swap / Solaris
/dev/sda9 13744 14763 8193118+ 83 Linux
/dev/sda10 14764 16038 10241406 83 Linux
/dev/sda11 16039 19226 25607578+ 83 Linux
/dev/sda12 42267 48641 51207156 b W95 FAT32

Aus meiner Sicht ist die /boot-Partition eine ganz normale logische mit ext3 formatierte Linux-Partition, keine Ahnung warum er die nicht mounten kann??

Danke für alle Hinweise,
AlGaN
 
Von der Konfiguration sieht das gut aus.
Nur bei "dump..." findet /usr/sbin/grub --batch --device-map=/boot/grub/device.map
die stage 1 nicht.
Im Moment kann ich mir das Problem nicht erklären.

Geht das schreiben in /dev/sda7 ?
 
OP
A

AlGaN

Newbie
Hallo,

hab gerade mittels
Code:
touch /tmp/test
den Schreibzugriff als root auf dem /-Filesystem getestet, geht einwandfrei, sonst könnte ich ja wohl auch nicht in das installierte System von der Suse-DVD booten...
 
Das sieht für mich so aus, als wenn grub das Filesystem von /boot nicht oder nicht
richtig (z.B. vorher reiserfs) erkennt.

Error 17: Cannot mount selected partition

Folgende Versuche würde ich noch machen:
- geht das schreiben auf der / partition
grub-install.unsupported /dev/sda7
- geht es mit Angebe root-directory
grub-install.unsupported --root-directory=/boot /dev/sda6

Ansonsten würde ich versuchen /boot nicht als extra Partition.
- mountpoint umbenennen z.B. /boot in /boot.gehtnich + in /etc/fstab nicht vergessen
- mkdir /boot (Also das Verzeichnis auf / neu anlegen )
- den Inhalt von /boot.gehtnich in das neue Verzeichnis /boot kopieren
=> neuer Versuch

Wenn das geht: die Partition /dev/sda6 überschreiben ( von /dev/zero ), Filesytem
neu anlegen (mit /dev/zero werden alte Daten sicher entfernt...)
=> noch'n Versuch mit /boot als eigener Partition.

Ansonsten hab ich keine Idee mehr. Aus der Ferne würde ich auf einen harten
grub-error tippen.

Haveaniceday
 
OP
A

AlGaN

Newbie
Hallo haveaniceday,

danke für Deine Tipps, ich werd wohl Suse nochmal neu installieren, parallel dazu versuch ich's mal mit Kubuntu, vll. macht das weniger Probleme...

AlGaN
 
OP
A

AlGaN

Newbie
Hallo, sorry, dass ich diesen alten Thread nochmals ausgrabe... habe jetzt erst wieder Zeit gefunden, mich mit den Bootproblemen von Suse 10.3 zu beschäftigen.

In der Zwischenzeit hatte ich grub als Workaround in den MBR installiert, ist aber nicht so geschickt für manche System-Tools von Windows, die eine extra Boot-Routine mitbringen (Partitions-Tools etc.)

Auf jeden Fall hab ich Suse 10.3 jetzt neu installiert, dieses Mal allerdings keine extra Boot-Partition erzeugt, sondern das Verzeichnis /boot mit auf die Root-Partition geschrieben.

Meine Partitionstabelle:
Code:
core2:~ # fdisk -l
omitting empty partition (5)

Disk /dev/sda: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfbd6fbd6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        6374    51199123+   7  HPFS/NTFS
/dev/sda2            6375       48641   339509677+   f  W95 Ext'd (LBA)
/dev/sda5            6375       12748    51199123+   7  HPFS/NTFS
/dev/sda6           12749       13401     5245191   83  Linux
/dev/sda7           13402       13663     2104483+  82  Linux swap / Solaris
/dev/sda8           13664       14708     8393931   83  Linux
/dev/sda9           14709       16797    16779861   83  Linux
/dev/sda10          16798       20714    31463271   83  Linux
/dev/sda11          40993       48641    61440561    b  W95 FAT32

Code:
core2:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6             5.0G  409M  4.3G   9% /
udev                 1014M  112K 1014M   1% /dev
/dev/sda8             7.9G  159M  7.4G   3% /home
/dev/sda9              16G  629M   15G   5% /opt
/dev/sda10             30G  2.3G   26G   9% /usr
/dev/sr1              4.2G  4.2G     0 100% /media/SU1030.001

Grub wollte ich jetzt in den Bootsektor der Root-Partition schreiben, mit YaST funktionierts mal wieder gar nicht...


Meine grub-Konfig:

Code:
core2:/boot/grub # cat device.map
(hd0)   /dev/sda

Code:
core2:/boot/grub # cat menu.lst
# Modified by YaST2. Last modification on Do Dez  6 21:41:47 CET 2007
default 0
timeout 8
gfxmenu (hd0,5)/boot/message

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 10.3
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD401LJS0HVJ1CP300054-part6 vga=0x31a resume=/dev/sda7 splash=silent showopts
    initrd /boot/initrd-2.6.22.5-31-default

###Don't change this comment - YaST2 identifier: Original name: windows###
title Windows
    rootnoverify (hd0,5)
    chainloader (hd0,0)+1

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 10.3
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD401LJS0HVJ1CP300054-part6 vga=normal showopts ide=nodma apm=off acpi=off noresume nosmp noapic maxcpus=0 edd=off 3

Code:
core2:/boot/grub # cat /etc/grub.conf
setup --stage2=/boot/grub/stage2 (hd0,5) (hd0,5)
quit

Grub sollte also so konfiguriert sein, dass er sich in den Bootsektor von der root-Partition schreibt (/dev/sda6 = (hd0,5) ).

grub-install geht wieder nicht:
Code:
core2:~ # grub-install /dev/sda6


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> setup --stage2=/boot/grub/stage2 (hd0,5) (hd0,5)

Error 17: Cannot mount selected partition
grub> quit

Also habe ich es mal mit der Grub-Kommandozeile versucht:

Code:
grub


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> find /boot/grub/stage2
find /boot/grub/stage2
 (hd0,6)
grub>
zeigt an, dass grub die Stage-Dateien auf (hd0,6) findet, obwohl sie nach der Zählweise von grub eigentlich auf (hd0,5) = /dev/sda6 liegen müssten! D.h. die grub-interne Zählweise (Beginn bei 0) stimmt bei meiner Platte nicht??

Ein nachfolgendes
Code:
root (hd0,6)
setup (hd0,6)

bringt auch keine Fehler, aber nach Rausschreiben des Bootsektors von /dev/hda6 in eine Datei mit dd mittels
Code:
dd if=/dev/sda6 of=/pfad/zu/bootsek.lin bs=512 count=1
liefert nach dem Booten mit dem XP-Bootloader nur einen schwarzen Bildschirm.

Ein (nach der Zählweise korrektes) Einbinden der root-Partition als (hd0,5) liefert wieder einen Fehler:


Code:
grub> root (hd0,5)
root (hd0,5)
 Filesystem type unknown, partition type 0x7
grub>

D.h. er kann die Partition nicht erkennen, da sie einen falschen Partitionstyp hat, nämlich den von NTFS, da /dev/hda5 die WinXP-Datenpartition ist, die aber nach grub eigentlich (hd0,4) sein müsste (1. logische Partition auf der Platte).

Bin hier mit meinem Latein am Ende und deshalb für jeden Tipp dankbar,

AlGaN

P.S.: Habe vergessen zu erwähnen, dass es sich um eine SATA-Platte handelt, dürfte aber wohl keinen Unterschied machen...

2. Eintrag: Nach tagelangem Suchen nach diesem Fehler hab ich es jetzt hinbekommen, das Problem war diese unscheinbare Meldung beim Befehl fdisk:

core2:~ # fdisk -l
omitting empty partition (5)
[...]
was soviel heißt, wie dass fdisk eine Partition in der Liste auslässt, die er als nicht lesbar kennzeichnet... bei mir lag diese wohl zwischen der root/boot-Partition von Linux und der 1. logischen Partition von WinXP... ein Listing mit cfdisk brachte die Partition ans Tageslicht...

Nach neuem Partitionieren und Neuinstallation von Suse Linux funktionierte auch der grub-install Aufruf problemlos, weil er diesmal die richtige Partition als Boot-Partition gefunden hatte, grub schert sich ja nicht um Device-Namen, sondern sieht nur das physikalische Partitionslayout der Platte...

Die Frage, was/welches Programm diese versteckte Partition erzeugt hat, hab ich dagegen nicht lösen können... vermutl. irgendein Windows-Partitionstool, das ich mal genutzt hatte...
 
Oben