Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
admin_grundlagen:bootloader [2019/11/09 22:14] ingo_wichmann [grubby] |
admin_grundlagen:bootloader [2025/07/23 12:57] (aktuell) sacha_kerres |
||
|---|---|---|---|
| Zeile 9: | Zeile 9: | ||
| ''/boot/grub2/grub.cfg'' neu erstellen: | ''/boot/grub2/grub.cfg'' neu erstellen: | ||
| + | grub2-mkconfig | grub2-script-check | ||
| grub2-mkconfig --output=/boot/grub2/grub.cfg | grub2-mkconfig --output=/boot/grub2/grub.cfg | ||
| Zeile 54: | Zeile 55: | ||
| ==== Grub2 mit Passwort absichern ==== | ==== Grub2 mit Passwort absichern ==== | ||
| === Root Passwort ändern === | === Root Passwort ändern === | ||
| - | Grub Bootprompt: ''init=/bin/bash'' als Parameter zum Linux Kernel hinzufügen | + | Grub Bootprompt: ''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 | Kernel mit ''strg+x'' booten | ||
| Zeile 61: | Zeile 64: | ||
| passwd | passwd | ||
| + | ++++ bei Systemem mit SELinux | | ||
| touch /.autorelabel | touch /.autorelabel | ||
| + | ++++ | ||
| - | ((nur bei Systemen mit aktiviertem SELinux notwendig)) | ||
| - | |||
| - | mount -o remount,ro / | ||
| exec /sbin/init | exec /sbin/init | ||
| === Grub absichern === | === Grub absichern === | ||
| - | == Passwort Hash erzeugen == | + | (( Unter Rocky Linux (ab 9) geht das einfacher: |
| - | Debian 6, CentOS 7: | + | 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 | grub2-mkpasswd-pbkdf2 | ||
| Zeile 76: | Zeile 96: | ||
| grub-mkpasswd-pbkdf2 | grub-mkpasswd-pbkdf2 | ||
| - | == Passwort Hash eintragen == | + | == Grub-Configdatei mit Passwort Hash anlegen == |
| <file txt /etc/grub.d/45_password> | <file txt /etc/grub.d/45_password> | ||
| #!/bin/sh | #!/bin/sh | ||
| Zeile 89: | Zeile 109: | ||
| chmod +x /etc/grub.d/45_password | chmod +x /etc/grub.d/45_password | ||
| - | == grub Konfigurationsdatei neu erzeugen == | + | == Auswahl ermöglichen, editieren absichern (Standard auf Rocky)== |
| - | Debian (ab 6), Ubuntu (14.04): | + | |
| - | grub-mkconfig -o /boot/grub/grub.cfg | + | |
| - | + | ||
| - | CentOS (7): | + | |
| - | grub2-mkconfig -o /boot/grub2/grub.cfg | + | |
| - | oder | + | |
| - | grub2-mkconfig -o "$(readlink -e /etc/grub2.conf)" | + | |
| - | oder für UEFI-Systeme: | + | |
| - | grub2-mkconfig -o "$(readlink -e /etc/grub2-efi.cfg)" | + | |
| - | + | ||
| - | == Auswahl ermöglichen, editieren absichern == | + | |
| <file txt /etc/grub.d/10_linux> | <file txt /etc/grub.d/10_linux> | ||
| ... | ... | ||
| Zeile 106: | Zeile 115: | ||
| ... | ... | ||
| </file> | </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 == | == testen == | ||
| - | Debian (ab 6), Ubuntu (14.04): | + | Debian (ab 6), Ubuntu (14.04), CentOS (ab 7): |
| - | grep password /boot/grub/grub.cfg | + | grep -E 'superusers|password_pbkdf2' /boot/grub*/grub.cfg |
| - | reboot | + | |
| - | CentOS (7): | + | |
| - | grep password /boot/grub2/grub.cfg | + | |
| reboot | reboot | ||
| Zeile 118: | Zeile 145: | ||
| * https://www.gnu.org/software/grub/manual/html_node/Security.html | * 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 ==== | ||