Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


admin_grundlagen:bootloader

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
admin_grundlagen:bootloader [2013/11/15 16:22] – [Grub installieren] ingo_wichmannadmin_grundlagen:bootloader [2026/05/02 13:04] (aktuell) – ingo_wichmann
Zeile 1: Zeile 1:
 ====== Bootloader ====== ====== Bootloader ======
-===== Bootloader löschen ===== +===== Kernel Bootparameter ändern ===== 
-  dd if=/dev/zero of=/dev/sda bs=446 count=1+Z.B. Kernel Argument ''nomodeset'' setzen: 
 +==== grub2-mkconfig ==== 
 +=== openSuSE 12.3 === 
 +''/etc/default/grub'' : 
 + 
 +Zeile ''GRUB_CMDLINE_LINUX_DEFAULT'' anpassen 
 + 
 +''/boot/grub2/grub.cfg'' neu erstellen: 
 +  grub2-mkconfig | grub2-script-check 
 +  grub2-mkconfig --output=/boot/grub2/grub.cfg 
 + 
 +=== Debian (ab 13) === 
 +<file txt /etc/default/grub.d/local.cfg> 
 +GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT neuer_parameter" 
 +GRUB_GFXMODE=1024x768 
 +</file> 
 + 
 +''/boot/grub/grub.cfg'' neu erstellen: 
 +  grub-mkconfig --output=/boot/grub/grub.cfg 
 + 
 +==== grubby ==== 
 +=== CentOS (bis 7) === 
 +Anzeigen der Konfiguration des Bootmanagers 
 +  grubby --info=ALL 
 + 
 +Eine Option zum Default-Kernel hinzufügen (hier: SELinux ausschalten) 
 +  grubby --args="enforcing=0" --update-kernel="$(grubby --default-kernel)" 
 + 
 +Optionen vom Default-Kernel entfernen (hier: Unterdrückung der Kernel-Meldungen ausschalten) 
 +  grubby --remove-args="rhgb quiet" --update-kernel="$(grubby --default-kernel)" 
 + 
 +=== CentOS (8) === 
 +Unter Centos 8 aktualisiert ''grubby'' nur noch die Konfigurationsdateien von Fedoras Variante der BootLoaderSpec (BLS) in ''/boot/loader/entries''. Das bedeutet, dass die Änderungen keine Auswirkung haben, wenn 
 +<file txt /etc/default/grub> 
 +… 
 +GRUB_ENABLE_BLSCFG=false 
 +… 
 +</file> 
 +gesetzt ist. (( siehe auch https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault )) 
 +===== grub2 ===== 
 +==== Grub2 in den MBR installieren ==== 
 +=== CentOS 7 === 
 +  yum install grub2 
 + 
 +=== Debian (ab 6.0) Ubuntu (ab 14.04) === 
 +  apt-get install grub-pc 
 +  update-grub2 
 +  grub-install /dev/sda 
 + 
 +=== openSuSE 12.2 === 
 +  update-bootloader 
 +  grub2-install /dev/sda 
 + 
 +==== Grub2 mit Passwort absichern ==== 
 +=== Root Passwort ändern === 
 +Grub Bootprompt:  
 +  * ''single systemd.debug_shell'' als Parameter zum Linux Kernel hinzufügen 
 +oder 
 +  * ''init=/bin/bash'' als Parameter zum Linux Kernel hinzufügen, evtl. ''ro'', ''quiet'' und ''splash=silent'' entfernen. (( siehe 
 +  man bootparam  
 +)) 
 + 
 +Kernel mit ''strg+x'' booten 
 + 
 +  mount -o remount,rw / 
 +  passwd 
 + 
 +++++ bei Systemem mit SELinux | 
 +  touch /.autorelabel 
 +++++ 
 + 
 +  exec /sbin/init 
 + 
 +=== Grub absichern === 
 +(( Unter Rocky Linux (ab 9) geht das einfacher: 
 +  grub2-setpassword 
 + 
 +Bei anderen Distributionen: 
 + 
 +<file txt /boot/grub/custom.cfg> 
 +set superusers="root" 
 +password_pbkdf2 root grub.pbkdf2.sha512.10000.FF73A777C6793E117430446F4D12F00D25DA53515B5048B1DAAA0688743550226CD05AD661EBDCA2AA1997AEBDC0C35C74CA48C9309FBED1C201C5875E3AD2E8.292A1642CB109860054562756A5AE950975B586A8DFDE535F566D1ADDCC6747349406E84862FFD9258F64268A36E63EF25A41A3CC0CD6291E63D98CEDDF00FE6 
 +</file> 
 + 
 +In diesem Fall muss danach kein update-grub ausgeführt werden 
 + 
 + 
 + 
 +Weitere Absicherungsmöglichkeiten: 
 +  http://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html 
 +)) 
 + 
 +== Passwort-Hash erzeugen == 
 +CentOS (ab 7), Rocky, openSuSE Leap (ab 15.1): 
 +  grub2-mkpasswd-pbkdf2 
 + 
 +Debian (ab 7), Ubuntu (ab 14.04): 
 +  grub-mkpasswd-pbkdf2 
 + 
 +== Grub-Configdatei mit Passwort Hash anlegen == 
 +<file txt /etc/grub.d/45_password> 
 +#!/bin/sh 
 +exec tail -n +3 $0 
 +# This file provides an easy way to add custom menu entries.  Simply type the 
 +# menu entries you want to add after this comment.  Be careful not to change 
 +# the 'exec tail' line above. 
 +set superusers="root" 
 +password_pbkdf2 root grub.pbkdf2.sha512.10000.FF73A777C6793E117430446F4D12F00D25DA53515B5048B1DAAA0688743550226CD05AD661EBDCA2AA1997AEBDC0C35C74CA48C9309FBED1C201C5875E3AD2E8.292A1642CB109860054562756A5AE950975B586A8DFDE535F566D1ADDCC6747349406E84862FFD9258F64268A36E63EF25A41A3CC0CD6291E63D98CEDDF00FE6 
 +</file> 
 + 
 +  chmod +x /etc/grub.d/45_password 
 + 
 +== Auswahl ermöglichen, editieren absichern (Standard auf Rocky)== 
 +<file txt /etc/grub.d/10_linux> 
 +... 
 +CLASS="--class gnu-linux --class gnu --class os --unrestricted" 
 +... 
 +</file> 
 + 
 +== grub Konfigurationsdatei neu erzeugen == 
 +Für BIOS-Systeme: 
 + 
 +Debian (ab 6), Ubuntu (ab 14.04): 
 +  grub-mkconfig -o /boot/grub/grub.cfg 
 +  # oder 
 +  update-grub 
 + 
 +CentOS (ab 7), Rocky, openSuSE (ab Leap 15.1): 
 +  grub2-mkconfig | grub2-script-check 
 +  grub2-mkconfig -o /boot/grub2/grub.cfg 
 + 
 +Für UEFI-Systeme: 
 + 
 +Debian, Ubuntu, openSuSE: wie bei BIOS-Systemen 
 + 
 +Rocky (ab 9) (( 
 +''--update-bls-cmdline'' passt ''/etc/kernel/cmdline'' und ''/boot/loader/entries/*.conf'' an 
 +)) 
 +  grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline 
 + 
 +== testen == 
 +Debian (ab 6), Ubuntu (14.04), CentOS (ab 7): 
 +  grep -E 'superusers|password_pbkdf2' /boot/grub*/grub.cfg 
 +  reboot 
 + 
 +=== Doku === 
 +  * https://www.gnu.org/software/grub/manual/html_node/Security.html 
 + 
 +==== Grub2 ohne Konfigurationsdatei von Hand starten ==== 
 +Notfall: der Rechner bootet nicht, sondern begrüßt uns mit einem freundlichen ''grub> _'' 
 + 
 +Weist Du noch, welche Dateisysteme Dein System verwendet? (Im Zweifel einfach alle Dateisystem-Module laden) 
 +  insmod ext2 
 +  insmod xfs 
 + 
 +Welche Storage Verwaltung verwendet Dein System? (Im Zweifel einfach alle laden) 
 +  insmod lvm 
 +  insmod mdraid09 
 +  insmod mdraid1x 
 + 
 +Laufwerke anzeigen, die grub jetzt sieht: 
 +  ls 
 + 
 +Partition/Laufwerk finden, auf dem Kernel (''vmlinuz…'') und Initrd liegen. Tab-Taste hilft ... 
 +  ls (hd0,msdos1)/ 
 + 
 +Grub-root setzen: 
 +  set root=(hd0,msdos1) 
 + 
 +Partition/Laufwerk finden, auf dem das Linux root-Dateisystem liegt (''etc/'', ''bin/'', …). Tab-Taste hilft ... 
 +  ls (lvm/centos-root)/ 
 + 
 +Kernel zum Boot vorbereiten: 
 +  linux /vmlinuz-… root=/dev/mapper/centos-root ro 
 + 
 +Initrd zum Boot vorbereiten: 
 +  initrd /initramfs-…
  
 +Booten:
 +  boot
 ===== grub ===== ===== grub =====
 ==== Grub in den MBR installieren ==== ==== Grub in den MBR installieren ====
Zeile 9: Zeile 187:
 oder oder
   grub   grub
 +  device (hd0) /dev/sda
   root (hd0,0)   root (hd0,0)
   setup (hd0)   setup (hd0)
Zeile 19: Zeile 198:
 oder oder
   grub   grub
 +  device (hd0) /dev/sda
   root (hd0,0)   root (hd0,0)
   setup (hd0)   setup (hd0)
Zeile 51: Zeile 231:
 </file> </file>
  
-===== grub2 ===== +===== Bootloader im MBR löschen ===== 
-==== Grub installieren ==== +  dd if=/dev/zero of=/dev/sda bs=$((512-64)) count=1
-=== Debian 6.0 === +
-  apt-get install grub-pc +
-  update-grub2 +
- +
-=== openSuSE 12.2 === +
-  update-bootloader +
-  grub2-install /dev/sda +
- +
-==== Kernel Bootparameter ändern ==== +
-Z.B. Kernel Argument ''nomodeset'' setzen: +
-=== openSuSE 12.3 === +
-''/etc/default/grub'' : +
-Zeile ''GRUB_CMDLINE_LINUX_DEFAULT'' anpassen+
  
-''/boot/grub2/grub.cfg'' neu erstellen: 
-  grub2-mkconfig --output=/boot/grub2/grub.cfg 
- 
-==== Grub2 mit Passwort absichern ==== 
-Debian 6.0 
- 
-=== Root Passwort ändern === 
-Grub Bootprompt: ''init=/bin/bash'' hinzufügen 
- 
-Kernel mit ''strg+x'' booten 
- 
-  mount -o remount,rw / 
-  passwd 
-  mount -o remount,ro / 
-  exec /sbin/init 
- 
-=== Grub absichern === 
-Debian 6.0: 
-  grub2-mkpasswd-pbkdf2 
- 
-Debian 7: 
-  grub-mkpasswd-pbkdf2 
- 
-''/etc/grub.d/45_password'' : 
-<file> 
-#!/bin/sh 
-exec tail -n +3 $0 
-# This file provides an easy way to add custom menu entries.  Simply type the 
-# menu entries you want to add after this comment.  Be careful not to change 
-# the 'exec tail' line above. 
-set superusers="root" 
-password_pbkdf2 root grub.pbkdf2.sha512.10000.FF73A777C6793E117430446F4D12F00D25DA53515B5048B1DAAA0688743550226CD05AD661EBDCA2AA1997AEBDC0C35C74CA48C9309FBED1C201C5875E3AD2E8.292A1642CB109860054562756A5AE950975B586A8DFDE535F566D1ADDCC6747349406E84862FFD9258F64268A36E63EF25A41A3CC0CD6291E63D98CEDDF00FE6 
-</file> 
- 
-  chmod +x /etc/grub.d/45_password 
-  update-grub 
-== testen == 
-  grep password /boot/grub/grub.cfg 
-  reboot 
-   
 ===== Dokus & Links ===== ===== Dokus & Links =====
   * http://wiki.ubuntuusers.de/grub_2/konfiguration   * http://wiki.ubuntuusers.de/grub_2/konfiguration
 +
admin_grundlagen/bootloader.1384532558.txt.gz · Zuletzt geändert: 2013/11/15 16:22 von ingo_wichmann