|
|
Line 73: |
Line 73: |
| This script can be configured via the <code>/etc/default/grub</code> file. | | This script can be configured via the <code>/etc/default/grub</code> file. |
| See [https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html] for a list of available options. | | See [https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html] for a list of available options. |
|
| |
| = systemd-boot=
| |
|
| |
| {{Todo|Work in progress. It is mostly done in Linux basics but doesn't cover topics like creating entries for other Operating Systems.}}
| |
|
| |
| Systemd-boot is the simple EFI bootloader part of the systemd project. It is also available in the Alpine Linux testing repository as a standalone component.
| |
|
| |
| == Installing ==
| |
|
| |
| To install the systemd-boot, enable the testing repository, and install the <code>systemd-boot</code> package. Then make sure the boot and EFI partitions are mounted as read-write and install the bootloader with <code>bootctl</code>.
| |
|
| |
| <pre>
| |
| # apk add systemd-boot
| |
| # bootctl install
| |
| </pre>
| |
|
| |
| The <code>bootctl</code> binary also has support for checking if the bootloader is installed.
| |
|
| |
| <pre>
| |
| # bootctl is-installed
| |
| yes
| |
| </pre>
| |
|
| |
| == Configuring ==
| |
|
| |
| Example configuration files for alpine are available on <code>/usr/share/systemd/bootctl</code> as <code>loader.conf</code> and <code>alpine.conf</code>.
| |
|
| |
| The bootloader (not the boot entries) can be configured via the [https://www.freedesktop.org/software/systemd/man/loader.conf.html# loader.conf] file, an example is available in <code>/usr/share/systemd/bootctl/loader.conf</code>.
| |
|
| |
| <pre>
| |
| # cp /usr/share/systemd/bootctl/loader.conf /boot/loader
| |
| # vi /boot/loader/loader.conf
| |
| </pre>
| |
|
| |
| systemd-boot makes use of configuration files in <code>/boot/loader/entries</code> to list entries for different OSes it can boot into. An example file for Alpine Linux is present on <code>/usr/share/systemd/bootctl/alpine.conf</code>.
| |
|
| |
| <pre>
| |
| # cp /usr/share/systemd/bootctl/alpine.conf /boot/loader/entries
| |
| # vi /boot/loader/entries/alpine.conf
| |
| </pre>
| |
|
| |
| The example file has a skeleton structure that requires minimal modifications to make them work. You need to modify the example file to fit your oeprating system, among them:
| |
|
| |
| * Replace root=UUID=XXXX with the UUID of the root partition. (Or remove UUID= altogether and use PARTUUID=, LABEL= or plain /dev/sdXY)
| |
| * Replace rootfstype with the filesystem used for the root filesystem.
| |
| * Add boot options required/recommended for booting your operating system (E.g: cryptdm=, cryptroot=, modules=, etc).
| |
| * (If you don't use the default linux-lts kernel) Replace vmlinuz-lts and initramfs-lts with the ones that are used.
| |
| * (If you use an Intel CPU and need Intel microcode) add <code>initrd /intel-ucode.img</code> before the initrd call for the initramfs
| |
|
| |
| All the options available are documented in the [https://systemd.io/BOOT_LOADER_SPECIFICATION/ systemd boot loader specification] under Technical Details.
| |
|
| |
| === Unified Kernel Images ===
| |
|
| |
| Systemd-boot also accepts unified kernel images, as outlined in their [https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images document]. They are a combination of various pieces that are usually separate when normally booting, like the kernel, the initramfs and the kernel commandline.
| |
|
| |
| To generate a unified kernel image the <code>objcopy</code> binary can be used:
| |
|
| |
| <pre>
| |
| # objcopy \
| |
| --add-section .osrel="/etc/os-release" --change-section-vma .osrel=0x20000 \
| |
| --add-section .cmdline="/proc/cmdline" --change-section-vma .cmdline=0x30000 \
| |
| --add-section .linux="$(bootctl -x)/vmlinuz-lts" --change-section-vma .linux=0x40000 \
| |
| --add-section .initrd="$(bootctl -x)/initramfs-lts" --change-section-vma .initrd=0x3000000 \
| |
| /usr/lib/systemd/boot/efi/linuxx64.efi.stub $(bootctl -p)/EFI/Linux/linux.efi
| |
| </pre>
| |
|
| |
| The above can be signed, with the bootloader, for use in Secure Boot.
| |
|
| |
| Users that require CPU microcode (like intel-ucode) can include it by concatenating the CPU microcode .img file before the normal initramfs into a single .img file.
| |
|
| |
| <pre>
| |
| # cat $(bootctl -x)/cpu_microcode.img $(bootctl -x)/initramfs-lts > /tmp/initramfs-lts
| |
| </pre>
| |
|
| |
| Then use that in the .initrd section of the <code>objcopy</code> call.
| |
|
| |
| == Listing Information and Status ==
| |
|
| |
| <code>bootctl</code> can also list the entries available, which one is default and a wealth of information from them. (Example from Alpine Linux developer Leo, which inculdes an entry and a Unified Kernel Image)
| |
|
| |
| <pre>
| |
| # bootctl list
| |
| Boot Loader Entries:
| |
| title: Alpine Linux
| |
| id: alpine
| |
| source: /boot/loader/entries/alpine.conf
| |
| linux: /vmlinuz-lts
| |
| initrd: /intel-ucode.img
| |
| /initramfs-lts
| |
| options: root=UUID=1437f4dd-7efd-4a4e-8fac-797b548076d1 cryptdm=pool cryptroot=/dev/sda2 modules=ext4,xfs rootfstype=ext4 psi=1 quiet
| |
|
| |
| title: Alpine Linux edge (default)
| |
| id: alpine-3.12_alpha20200122
| |
| source: /boot/EFI/Linux/linux.efi
| |
| linux: EFI/Linux/linux.efi
| |
| options: initrd=\intel-ucode.img initrd=\initramfs-lts root=UUID=1437f4dd-7efd-4a4e-8fac-797b548076d1 cryptdm=pool cryptroot=/dev/sda2 modules=ext4,xfs rootfstype=ext4 psi=1 quiet
| |
|
| |
| title: Reboot Into Firmware Interface
| |
| id: auto-reboot-to-firmware-setup
| |
| source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
| |
| </pre>
| |
|
| |
| And it can also list general status of the system, including information on the current bootloader, the system firmware and options (like if Secure Boot is enabled).
| |
|
| |
| <pre>
| |
| # bootctl status
| |
| System:
| |
| Firmware: UEFI 2.40 (American Megatrends 5.11)
| |
| Secure Boot: enabled
| |
| Setup Mode: user
| |
|
| |
| Current Boot Loader:
| |
| Product: systemd-boot 243
| |
| 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
| |
| Stub: systemd-stub 243
| |
| ESP: /dev/disk/by-partuuid/00e7649e-bf1f-481b-87cd-7228af8c118f
| |
| File: └─/EFI/systemd/systemd-bootx64.efi
| |
|
| |
| Random Seed:
| |
| Passed to OS: no
| |
| System Token: set
| |
| Exists: yes
| |
|
| |
| Available Boot Loaders on ESP:
| |
| ESP: /boot (/dev/disk/by-partuuid/00e7649e-bf1f-481b-87cd-7228af8c118f)
| |
| File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot 243)
| |
| File: └─/EFI/BOOT/BOOTX64.EFI (systemd-boot 243)
| |
|
| |
| Boot Loaders Listed in EFI Variables:
| |
| Title: Linux Boot Manager
| |
| ID: 0x0007
| |
| Status: active, boot-order
| |
| Partition: /dev/disk/by-partuuid/00e7649e-bf1f-481b-87cd-7228af8c118f
| |
| File: └─/EFI/systemd/systemd-bootx64.efi
| |
|
| |
| Title: Windows Boot Manager
| |
| ID: 0x0000
| |
| Status: active
| |
| Partition: /dev/disk/by-partuuid/fd36bbae-be4f-409a-b1ce-14771e091067
| |
| File: └─/EFI/Microsoft/Boot/bootmgfw.efi
| |
|
| |
| Boot Loader Entries:
| |
| $BOOT: /boot (/dev/disk/by-partuuid/00e7649e-bf1f-481b-87cd-7228af8c118f)
| |
|
| |
| Default Boot Loader Entry:
| |
| title: Alpine Linux edge
| |
| id: alpine-3.12_alpha20200122
| |
| source: /boot/EFI/Linux/linux.efi
| |
| linux: EFI/Linux/linux.efi
| |
| options: initrd=\intel-ucode.img initrd=\initramfs-lts root=UUID=1437f4dd-7efd-4a4e-8fac-797b548076d1 cryptdm=pool cryptroot=/dev/sda2 modules=ext4,xfs rootfstype=ext4 psi=1 quiet
| |
| </pre>
| |
|
| |
| == Updating ==
| |
|
| |
| When the <code>systemd-boot</code> package is updated the bootloader installed needs to be updated as well:
| |
|
| |
| <pre>
| |
| # bootctl update
| |
| </pre>
| |
|
| |
| == Removing ==
| |
|
| |
| If for any reason you wish to not use systemd-boot anymore then the <code>bootctl</code> binary also provides a command for easily removing the files that were installed with the install command:
| |
|
| |
| <pre>
| |
| # bootctl remove
| |
| # apk del systemd-boot
| |
| </pre>
| |
|
| |
|
| = External Links = | | = External Links = |
| * [https://www.denx.de/wiki/U-Boot/ReleaseCycle U-Boot Release Cycle] | | * [https://www.denx.de/wiki/U-Boot/ReleaseCycle U-Boot Release Cycle] |
| * [https://wiki.archlinux.org/index.php/systemd-boot ArchWiki extensive article on systemd-boot]
| |
|
| |
|
| [[Category:Installation]] | | [[Category:Installation]] |
| [[Category:Booting]] | | [[Category:Booting]] |