titel: "systemd-boot met bootctl"
beschrijving: "bootloader van systemd"
screenshot: https://en.wikipedia.org/wiki/Systemd-boot#/media/File:Arch_Linux_UEFI_loader_screenshot.png
categoriën:
Vereisten
Check je bootorder met het efibootmgr commando
# uitvoeren van commando efibootmgr
efibootmgr
De BootCurrent order zal normaal als eerste boot om je huidig systeem op te starten op een nummer staan zoals 000n met Boot000n verwijzend naar Debian .
Om de bootloader te installeren moet het pakket systemd-boot geïnstalleerd zijn !
Installeer bootloader met het bootctl commando (let op : root rechten zijn vereist!)
# installeer bootctl
# sudo apt install systemd-boot
bootctl install --esp-path=/boot/efi
Als de installatie van bootctl succesvol is moet je efibootmgr nu verwijzen naar Linux Boot Manager als je eerste boot en debian als je tweede boot selectie.
Creëer het bestand zz-update-system-boot binnen de map /etc/kernel/postinst.d/ (root rechten vereist !)
#!/bin/sh
set -e
/usr/bin/kernel-install -v add "$1" "$2"
exit 0
Deze procedure creëert kernel en initramfs images met de kernel-install tool van het systemd pakket (voor meer: man kernel-install)
Noot : de
-vin/usr/bin/kernel-install -v addmag eruit
met -v optie wordt de werking getoond in /var/log/apt/term.log !
# maak het bestand uitvoerbaar
chmod a+x /etc/kernel/postinst.d/zz-update-systemd-boot
Creëer het bestand zz-update-system-boot binnen de map /etc/kernel/postrm.d/ (root rechten vereist !)
#!/bin/sh
set -e
/usr/bin/kernel-install -v remove "$1"
exit 0
# maak het bestand uitvoerbaar
chmod a+x /etc/kernel/postrm.d/zz-update-systemd-boot
/boot/efi/loader/loader.conf
# als voorbeeld
default debian
timeout 3
editor 1
Voer uit :
# voer uit om te zien wat je machine-id is op je systeem
cat /etc/machine-id
uitvoer is een hexadecimaal getal van 32 karakters en ziet eruit als volgt:
(dit als voorbeeld !)
# als voorbeeld
2af230c8d6464a7d8e64657bf5584ee3
Creëer de map /boot/efi/je-machine-id met het mkdir commando
# met als <je-machine-id> bovenstaand hexadecimaal getal van 32 karakters
mkdir /boot/efi/2af230c8d6464a7d8e64657bf5584ee3
Doe een 'kernel-install add' van je kernel versie
# dit is de kernel-install voor versie 5.10.0-15-amd64
kernel-install -v add 5.10.0-15-amd64 initrd.img-5.10.0-15-amd64 vmlinuz-5.10.0-15-amd64
#
Doe hetzelfde voor al je andere kernel versies (zoals hierboven)
indien bovenstaand 'kernel-install add' faalt , doe dan eerst een 'kernel-install remove' vooraleer de 'kernel-install add' opnieuw te doen , dit als volgt
# dit is de kernel-install voor versie 5.10.0-15-amd64
kernel-install remove 5.10.0-15-amd64
De map /boot/efi/loader/ bevat de bestanden :
loader.confrandom-seedDe map /boot/efi/loader/ bevat een map :
entriesdeze map entries bevat al de configuratiebestanden voor al je kernel versies
als voorbeeld:
# reboot
reboot
Je bent nu klaar
h,7,F1 help
e edit
d make entry default
+,t increase timeout
-,T decrease timeout
f reboot
Esc
ctrl+k clear command line in edit mode
1,2,3,4,... entry member
l linux
w windows
bootctl is een procedure meegeleverd met het systemd pakket
status
# bootctl status
bootctl status
'bootctl status' ziet er zo uit (als voorbeeld):
System:
Firmware: UEFI 2.40 (American Megatrends 5.11)
Secure Boot: disabled
Setup Mode: user
Boot into FW: supported
Current Boot Loader:
Product: systemd-boot 247.3-6
Features: ✓ Boot counting
✓ Menu timeout control
✓ One-shot menu timeout control
✓ Default entry control
✓ One-shot entry control
✓ Support for XBOOTLDR partition
✓ Support for passing random seed to OS
✓ Boot loader sets ESP partition information
ESP: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182
File: └─/EFI/systemd/systemd-bootx64.efi
Random Seed:
Passed to OS: yes
System Token: set
Exists: yes
Available Boot Loaders on ESP:
ESP: /boot/efi (/dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21>
File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot 247.3-6)
File: └─/EFI/BOOT/BOOTX64.EFI (systemd-boot 247.3-6)
Boot Loaders Listed in EFI Variables:
Title: Linux Boot Manager
ID: 0x0007
Status: active, boot-order
Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182
File: └─/EFI/systemd/systemd-bootx64.efi
Title: debian
ID: 0x0002
Status: active, boot-order
Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182
File: └─/EFI/debian/shimx64.efi
Title: usb
ID: 0x0004
Status: active, boot-order
Partition: /dev/disk/by-partuuid/bf5282d8-e895-439e-8595-d4580486b17f
File: └─/EFI/Boot/bootx64.efi
Title: test
ID: 0x0001
Status: active, boot-order
Partition: /dev/disk/by-partuuid/1cb0011a-3c55-4a8c-9437-11c6254f6f3e
File: └─/EFI/debian/shimx64.efi
Title: UEFI: ST2000LM003 HN-M201RAD, Partition 1
ID: 0x0016
Status: active, boot-order
Partition: /dev/disk/by-partuuid/6b44c434-5196-49d8-b29a-31de8a4bbe34
File: └─EFI/Microsoft/Boot/bootmgfw.efi
Title: Windows Boot Manager
ID: 0x0000
Status: active, boot-order
Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182
File: └─/EFI/Microsoft/Boot/bootmgfw.efi
Title: UEFI: CT500MX500SSD1, Partition 1
ID: 0x0017
Status: active, boot-order
Partition: /dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21c5182
File: └─EFI/Microsoft/Boot/bootmgfw.efi
Title: debian2
ID: 0x0006
Status: active
Partition: /dev/disk/by-partuuid/bf5282d8-e895-439e-8595-d4580486b17f
File: └─/EFI/debian/shimx64.efi
Title: UEFI: ST2000LM003 HN-M201RAD, Partition 1
ID: 0x000A
Status: active
Partition: /dev/disk/by-partuuid/6b44c434-5196-49d8-b29a-31de8a4bbe34
File: └─EFI/Microsoft/Boot/bootmgfw.efi
Boot Loader Entries:
$BOOT: /boot/efi (/dev/disk/by-partuuid/21d6d264-bbac-4c1a-b628-2e97a21>
Default Boot Loader Entry:
title: Debian GNU/Linux 11 (bullseye) (5.10.0-15-amd64)
id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf
source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0>
version: 5.10.0-15-amd64
machine-id: 2af230c8d6464a7d8e64657bf5584ee3
linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/linux
initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/initrd.img-5.1>
options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet
bootctl met optie list
# bootctl list
bootctl list
'bootctl list' ziet er zo uit (dit als voorbeedl):
Boot Loader Entries:
title: Debian GNU/Linux 11 (bullseye) (5.10.0-8-amd64)
id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf
source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf
version: 5.10.0-8-amd64
machine-id: 2af230c8d6464a7d8e64657bf5584ee3
linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-8-amd64/linux
initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-8-amd64/initrd.img-5.10.0-8-amd64
options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet
title: Debian GNU/Linux 11 (bullseye) (5.10.0-14-amd64)
id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
version: 5.10.0-14-amd64
machine-id: 2af230c8d6464a7d8e64657bf5584ee3
linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-14-amd64/linux
initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-14-amd64/initrd.img-5.10.0-14-amd64
options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet
title: Debian GNU/Linux 11 (bullseye) (5.10.0-15-amd64) (default)
id: 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf
source: /boot/efi/loader/entries/2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf
version: 5.10.0-15-amd64
machine-id: 2af230c8d6464a7d8e64657bf5584ee3
linux: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/linux
initrd: /2af230c8d6464a7d8e64657bf5584ee3/5.10.0-15-amd64/initrd.img-5.10.0-15-amd64
options: root=UUID=0d8f82d3-9635-4e9c-8f6e-1512f4e1b2d6 ro quiet
title: Windows Boot Manager
id: auto-windows
source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
title: Reboot Into Firmware Interface
id: auto-reboot-to-firmware-setup
source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
gebruik hiervoor het bootctl commando met optie update
# bootctl update
bootctl update
sudo systemctl enable systemd-boot-update # éénmalig !
sudo systemctl start systemd-boot-update # éénmalig !
# check status
sudo systemctl status systemd-boot-update
Het is mogelijk de EFI variabele LoaderEntryDefault (in /sys/firmware/efi/efivars/) te wijzigen
De mogelijke waarden kun je vinden in /boot/efi/loader/entries
# mogelijke waarden kun je vinden
ls /boot/efi/loader/entries/
output (dit als voorbeeld !)
2af230c8d6464a7d8e64657bf5584ee3-5.10.0-8-amd64.conf
2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
2af230c8d6464a7d8e64657bf5584ee3-5.10.0-15-amd64.conf
verander bijvoorbeeld de default waarde naar 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf Hiervoor gebruik je het bootctlcommando met de set-default optie
# bootctl set-default ...
bootctl set-default 2af230c8d6464a7d8e64657bf5584ee3-5.10.0-14-amd64.conf
rm /etc/machine-id
systemd-machine-id-setup
entries aanpassen in /boot/efi/loader/entries map /boot/efi/'nieuw_machine_id'
tune2fs -U nieuw_uuid /dev/mapper/ ...
# vereist eerst een : e2fsck -f /dev/mapper/....
ofwel met : 'gparted /dev/sda' en selecteer partitie nieuw UUID
update-initramfs -u
efibootmgr --create --disk=/dev/sda --part=1 --label='debian' --loader='EFI/debian/shimx64.efi'
Hiervoor gebruik je het bootctl commando met de remove optie
# indien je toch de installatie wil teniet doen
bootctl remove
exit
Maak dat je kunt opstarten met een andere bootloader (Grub, Refind, Lilo, ...) vooraleer je computer te herstarten.
Gebruik de recenste systemrescuecd en start de systemrescue iso het best op in copy to RAM mode copytoram
cd /mnt
mkdir root
# /mnt/root wordt dan de basis map voor de chroot
# mount je root partitie
...
# mount je boot, boot/efi, home en data partities (indien van toepassing) onder de basis map
...
# mount efivars, dev, proc, sys, run
for i in proc sys run dev dev/pts sys/firmware/efi/efivars do mount -o bind /$i /mnt/root/$i; done
chroot /mnt/root
# doe updates binnen chroot
....
# exit chroot
exit
#
for i in sys/firmware/efi/efivars dev/pts dev sys proc run; do umount /mnt/root/$i; done
#
umount /mnt/root/boot/efi
umount /mnt/root/boot
umount /mnt/root/home
umount /mnt/root/data
...
umount /mnt/root
...
reboot
Ofwel opstarten in Grub (ook al start je systeem niet meer automatisch op in Grub !) dit als je grub nog niet weggegooid hebt van je systeem ! Boot in UEFI mode vanaf Super Grub2 Disk
Zet RAID mode en LVM mode aan
Selecteer Manueel Grub2 proces
Laat Grub2 disk zoeken naar je Grub2 Configfiles
selecteer nog een goeie Configfile en start op
Bij foute Configfile selectie , doe Esc en neem een andere Configfile.
confer de oorspronkelijk website : link naam