Bootloaders

A bootloader, is a computer program that is responsible for booting a computer. If it also provides an interactive menu with multiple boot choices then it's often called a boot manager. This page shows the basic steps you need to perform, if you for any reason want to switch bootloaders or apply some manual configuration.
The following bootloaders are available in Alpine Linux.
* Syslinux is the default light-weight bootloader used in Alpine.
* rEFInd is an easy to use EFI boot menu that allows booting different operating systems.
* GRUB is a standard linux boot loader.
* EFI Boot Stub allows booting linux directly from a motherboard supporting UEFI or another bootloader.
* Gummiboot can be used for UEFI Secure Boot.
== rEFInd ==
For (U)EFI systems, the package can provide a graphical EFI boot menu that allows to boot operating systems that are found on the available partitions. As of now, is available in the testing repository. It can be safely installed by following the guidelines.
The below command installs the alpine-linux rEFInd package:
 
rEFInd's refind-install script creates a sample file . 
 
The above steps should be sufficient for most cases to start using rEFInd as boot loader. 
A sample from rEFInd website for a system with ext4 filesystem is given below:
This sample file defines three entries: 
* The first entry uses options derived from the contents of when the script was run, unless the script was run from an emergency system, in which case refind-install tries to translate from options in .
* The second entry provides the same boot options as the first, but adds single, which causes most distributions to boot into a single-user maintenance mode.
* The final entry subtracts most options from the list, leaving only ro root=rootfs, where rootfs is the identified root (/) filesystem. This option may not be bootable on some systems that need unusual options, but if it does boot, it will normally do so with verbose startup messages, which can be helpful when debugging boot problems.
Given below is a sample created automatically by rEFInd for a system with Btrfs filesystem whose layout is given further below as <Code>blkid</Code> output:
Output of <Code>blkid</Code> from Busybox is given below. 
/dev/sda4: LABEL="_SWAP_" UUID="33899521-599f-458e-9bfe-f4b59254eb7c" TYPE="swap" 
/dev/sda3: LABEL="_SYS0_" UUID="aafbf6b0-7d54-4222-a3dd-a8f45c0ac607" TYPE="btrfs"
/dev/sda1: LABEL="_BOOT_" UUID="6771-DB5C" TYPE="vfat" 
The single-user mode and minimal options does not work in Alpine Linux for Btrfs filesystem as per user u/Xerotras in https://redd.it/1hbog74
Proceed to Manual configuration only if rebooting did not result in rEFInd appearing as boot loader.
=== Manual configuration ===
And a first (default) boot menu line needs to be configured with Alpine's default boot parameters. Assuming the bootable partition is mounted at it can be done like this (at time of writing):
There is also a second config file, refind.conf which is located inside the EFI partition. The config file is self-explanatory and has to be manually edited. Refer refind website for additional information.
The below instructions assume esp partition is mounted as shown:
If your setup is different from above, adjust the path in below files accordingly.
For default alpine sys mode installation, a sample refind.conf to dual boot Alpine Linux and windows will be: 
If you use btrfs filesystem, for the above setup, the necessary boot entry for Alpine Linux is as follows: 
== Syslinux ==
If you want to switch from another bootloader back to Syslinux, or if you for some reason want to install Syslinux manually, the following steps are required.
Install the package:
If you're using GPT partitions, install the GPT MBR onto the drive you want to install the bootloader on (in this case ):
Or if you're using DOS partitions, install the DOS MBR instead:
Next install the required Syslinux binaries. Despite being called extlinux, Syslinux supports booting from FAT12/16/32, NTFS, ext2/3/4, btrfs, XFS, and UFS/FFS filesystems.
The configuration file is located in . 
Alpine ships with a script update-extlinux which automatically (re)generates this file, for example on updates to Syslinux. The settings for this script can be found in , including the option to disable automatic overwriting of . 
You can also place additional menu entries in the directory, e.g. for dual booting.
=== Using EFI with syslinux ===
Alpine Linux installer automatically uses Grub, if EFI mode is detected. The below section is specifically about using EFI with syslinux:
Assuming is a FAT32 partition of type EF00 and belongs to the rootfs created after running setup-disk:
You may need to modify to change the paths to absolute paths (just add a / in front of the vmlinuz/initramfs entries),
or copy the files to instead (XXX: untested).
At the end, the file should look like this:
And finally, add syslinux to EFI boot menu (assuming is your hard drive)
You can now verify that the boot entry has been added
efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0000,0002,...
Boot001* ALPINE-SYSLINUX HD(1,GPT,xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)/FILE(\EFI\syslinux\syslinux.efi)
== GRUB ==
To install GRUB in BIOS mode, (optionally) remove the Syslinux package and install the required GRUB packages:
For EFI, install GRUB's EFI package instead. Note that has to be an EFI compatible filesystem like FAT32.
Next install the MBR and GRUB binaries to disk for BIOS mode:
For EFI mode:
then add this line to :
GRUB ships with an automatic config generator, including some automatic detection of other operating systems installed on the device:
This script can be configured via the file.
See for a list of available options.
== EFI Boot Stub ==
To boot directly from your motherboard's UEFI boot menu, a boot entry needs
to be created with either a UEFI shell or efibootmgr.
=== efibootmgr ===
Install efibootmgr:
Create a boot entry. It's recommended to do this in a script, as efibootmgr
does not allow editing entries.
Where contains the EFI partition and contains the root partition. If you are using , replace lts with edge in the script
Optionally, set the newly created entry as the default:
Where XXXX is the boot number of the new entry.
== Using a UKI ==
Unified Kernel Image (UKI) is supported in UEFI only. It is possible to boot directly into a UKI. A UKI is a single file which contains the initfs, kernel and cmdline. While this is typically done in order to enable SecureBoot, it is perfectly feasible to skip enrolling the custom keys and leave SecureBoot off.
The page UEFI Secure Boot contains the instructions for setting an a UKI. Additionally, it is possible to install the UKI in the default fallback path used by most UEFI implementations. By installing the UKI into this path, the system will automatically boot into it if no other entries are defined. This can be automated as part of the kernel hook by adding the following to 
 is only correct for x86_64 systems. For other architectures the exact name will vary.
= See also =
* Gentoo Wiki
* Archwiki
* PostmarketOS Wiki
* U-Boot Release Cycle
Category:Installation
Category:Booting