• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

Grub2 auf zweiter HDD installieren

elias5000

Site Reliability Engineer
Ich habe ein kleines Problem. Ich habe eine Kiste, die läuft auf einem RAIS1 aus einer SSD und einer HDD. Jetzt ist die SSD ausgefallen und müsste ersetzt werden. Wie das geht ist mir klar, mein Problem ist ein anderes:

Die Kiste läuft auf einem Ubuntu 14.04 und bootet mit Grub2. Die SSD ist /dev/sda und die HDD ist /dev/sdb. Beide laufen als Kernel-RAID mit level 1.

Unter dem alten Grub hatte ich den Bootloader immer auf beiden Devices eines RAID1 installiert. Da das mit Grub2 irgendwie komplizierter (anders) war, habe ich das bisher vor mir her geschoben. Und jetzt hat es mich erwischt.

Die Kiste läuft noch und das stabil. Ich komme per SSH drauf. Mein Problem ist, dass sie nicht mehr booten wird und ich auch keinen Monitor habe, den ich anschließen kann. (Ist kaputt gegangen und sonst habe ich nur Laptop, wurde also nicht ersetzt.)

Ich muss jetzt also nicht nur irgendwie einen Grub auf /dev/sdb installieren sondern auch noch den Grub2 davon überzeugen, dass er das tun soll obwohl /dev/sda ausgefallen ist.

Ich habe es versucht mit:
Code:
root@vbox:~# grub-install /dev/sdb
Installing for i386-pc platform.
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
grub-install: error: disk `lvmid/Qiyofc-Zyp2-fos1-Y951-566U-4WWw-JTFlrJ/VLiXQW-uKrO-K2Hw-sBQP-fUha-2tBF-vneD2m' not found.
Das schaut nicht so gut aus. Bei Grub1 gab es eine konsole in der ich das Device-Mapping überschreiben konnte und /dev/sdb als hd0 definieren und dann den bootloader schreiben. Ein äquivalent konnte ich bei Grub2 nicht finden.

Vielleicht kennt sich ja jemand gut genug mit Grub2 aus oder ich sehe einfach die offensichtliche Lösung nicht.

TL;DR: Erste Platte meines RAID1 futsch, muss jetzt den Bootloader auf /dev/sdb installieren wobei ich etwas Hilfe gebrauchen könnte.
 
Das ist die fstab:
Code:
/dev/mapper/rootvg-rootfs /               ext4    errors=remount-ro 0       1
/dev/mapper/rootvg-home /home           ext4    defaults        0       2
/dev/mapper/rootvg-var /var            ext4    defaults        0       2
/dev/mapper/rootvg-swap none            swap    sw              0       0

rootvg ist ein ein LVM auf /dev/md1 welches aus /dev/sda1 und /dev/sdb1 besteht:
Code:
  VG     #PV #LV #SN Attr   VSize   VFree
  rootvg   1   4   0 wz--n- 117.28g    0

  PV         VG     Fmt  Attr PSize   PFree
  /dev/md1   rootvg lvm2 a--  117.28g    0

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[1] sda1[0](F)
      1950656 blocks super 1.2 [2/1] [_U]

md1 : active raid1 sdb2[1] sda2[0](F)
      122981248 blocks super 1.2 [2/1] [_U]
md0 ist ungenutzt. Ich glaube das hatte ich bei der Installation angelegt weil ich es für /boot vorgesehen hatte aber dann konnte Grub2 doch mit LVM umgehen und ich habe doch kein separates /boot angelegt.

Edit: Ich habe gerade die Idee, dass ich mal versuchen könnte das faulty device aus dem RAID zu entfernen. Es ist ja eh hinüber. Vielleicht gehen dann diese ewigen I/O errors weg. Da hab ich bisher noch gar nicht dran gedacht.
 
Edit: Ich habe gerade die Idee, dass ich mal versuchen könnte das faulty device aus dem RAID zu entfernen. Es ist ja eh hinüber. Vielleicht gehen dann diese ewigen I/O errors weg. Da hab ich bisher noch gar nicht dran gedacht.

Leider immer noch Fehler aber eine neue Meldung:
Code:
root@vbox:~# grub-install /dev/sdb
Installing for i386-pc platform.
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: error: embedding is not possible, but this is required for RAID and LVM install.

Ich schaue mich wohl lieber schonmal auf ebay-kleinanzeigen nach einem Monitor um, den ich mit schnell irgendwo holen kann. :-(
Das System enthält nichts Wichtiges außer einen Backup-Mirror aber es wäre schon schick, wenn es einfach wäre. Und auch akademisch finde ich das interessant, da ich bisher noch nichts wirklich auf das Szenario passendes ergooglen konnte.
 
Ok. du müsstest eine bios_grub Partition anlegen..

sdb1 war ja als Boot gedacht.. Ist aber nicht im Einsatz..

Daten sichern daraus nach /boot_backup zb.

Aus dem Raid aushängen am besten mit mdadm -r /dev/md0 /dev/sdb1
sdb1 löschen
und an der Stelle anlegen.
1M bios_grub (kein Raid, am besten mit parted)

Das sollte eigentlich reichen, dann kannste auf sdb Grub installieren..
 
Last edited by a moderator:
Bekomme ich da nicht das Problem dass ohne reboot die veränderte Partitionierung von /dev/sdb nicht aktiv wird?

Und habe ich das richtig verstanden, dass grub nicht nach /dev/sdb installieren kann, weil da eine GPT partition table drin ist und kein MBR?
 
Vielen Dank für den Hinweis.
Ich habe jetzt das md0 gestoppt, mit parted für Partition 1 das raid-Flag entfernt und das bios_grub-Flag gesetzt und dann mit partprobe /dev/sdb die table neu eingelesen.

Danach kam das:
Code:
Installing for i386-pc platform.
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
  /dev/sda: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035586048: Input/output error
  /dev/sda: read failed after 0 of 4096 at 128035667968: Input/output error
  /dev/sda: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998520320: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 1998577664: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035623936: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 126035681280: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 0: Input/output error
  /dev/sda2: read failed after 0 of 4096 at 4096: Input/output error
Installation finished. No error reported.
Wenn man mal die ganzen I/O-Errors nicht beachtet (die gelten ja der kaputten sda) scheint es geklappt zu haben. Wenn ich sdb und sdb1 mit hexdump anschaue sieht das auch schon deutlich mehr nach einem Bootloader aus. :)
Jetzt muss es nur noch tun, wenn ich die HDD auf den ersten SATA-Port stecke und die Replacement-HDD auf den zweiten.
 
Last edited by a moderator:
Zur Info nebenbei:

"blockdev --rereadpt" macht das gleiche wie partprobe, ist aber im Gegensatz zu letzterem als Teil von util-linux standardmaessig installiert.
 
Kurzes Update: Die Kiste hat gebootet aber irgendwie das LVM nicht zusammen bekommen und ist dann beim booten hängen geblieben.
Da ich nicht unendlich viel Zeit drauf werfen kann und da keine unwiederbringlichen Daten drauf waren (und weil mein Monitor nach gefühlt hundert mal aus- und einschalten doch nochmal ein Bild gezeigt hat) habe ich das Teil kurzerhand neu aufgesetzt.
Aber immerhin habe ich noch was über GPT und Grub gelernt. :)
 
Last edited by a moderator:
initramfs Update machen beim nächsten mal ;)

Wird oft vergessen, ist aber bei manchen Konstellationen erforderlich..
 
Ich verstehe die Frage nicht. Das RAID sorgt für Redundanz und das LVM für dynamische Partitionierbarkeit. Das sind doch zwei völlig verschiedene Sachen.
 
Das RAID sorgt für Redundanz und das LVM für dynamische Partitionierbarkeit. Das sind doch zwei völlig verschiedene Sachen.

Ganz genau. Und (SW-)RAID+LVM ist IMHO eine exzellente Kombi. Falls keine Hardware getauscht werden muss, erlaubt es LVM alles im laufenden Betrieb zu ändern.

LVM hat zwar auch noch die Möglichkeit selbst Redundanz(Mirror aka RAID-1) zu schaffen, aber ich verwende das lieber auch auf einer anderen Schicht, weil das einfach flexibler ist.
 
Back
Top