Difference between revisions of "Bootloaders"

From Alpine Linux
Jump to: navigation, search
Line 79: Line 79:
  
 
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.
 
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>.
 
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>.
Line 88: Line 90:
  
 
If you are not sure if the bootloader was installed then <code>bootctl is-installed</code> can be used to check, if it returns <code>yes</code> then systemd-boot is installed.
 
If you are not sure if the bootloader was installed then <code>bootctl is-installed</code> can be used to check, if it returns <code>yes</code> then systemd-boot is installed.
 +
 +
== 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>.
 
Example configuration files for alpine are available on <code>/usr/share/systemd/bootctl</code> as <code>loader.conf</code> and <code>alpine.conf</code>.
  
Systemd-boot also provides a way to pass random-seed to the next boot, this can be enabled with <code>bootctl</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>
 
<pre>
# bootctl random-seed
+
# cp /usr/share/systemd/bootctl/loader.conf /boot/loader
 +
# vi /boot/loader/loader.conf
 
</pre>
 
</pre>
  
 
To prepare a proper boot entry for your operating system, one can copy the example alpine.conf to <code>/boot/loader/entries</code> and edit to be appropriate for their system, including: changing the example root=UUID= to point to their root partition; changing rootfstype= to the filesystem of the root parition and adding options used in previous syslinux or grub entries.
 
To prepare a proper boot entry for your operating system, one can copy the example alpine.conf to <code>/boot/loader/entries</code> and edit to be appropriate for their system, including: changing the example root=UUID= to point to their root partition; changing rootfstype= to the filesystem of the root parition and adding options used in previous syslinux or grub entries.
  
<pre>
+
Entries for <code>systemd-boot</code> are located in <code>/boot/loader/entries</code> and take the form of one file for each boot entry. An example one for Alpine Linux is provided (assumes you use <code>linux-lts</code>). One can copy the example configuration to <code>/boot/loader/entries</code> and do the final edits necessary to have a working boot entry.
# cp /usr/share/systemd/bootctl/alpine.conf /boot/loader/entries
+
 
# vi /boot/loader/entries/alpine.conf
+
All the options available are documented in the [https://systemd.io/BOOT_LOADER_SPECIFICATION/ systemd boot loader specification] under Technical Details.
</pre>
 
  
One can use the <code>bootctl list</code> to see what entries are available, which one is default and more information about them.
+
== Updating ==
  
If the <code>systemd-boot</code> package is updated then the bootloader installed needs to be updated as well:
+
When the <code>systemd-boot</code> package is updated then the bootloader installed needs to be updated as well:
  
 
<pre>
 
<pre>
 
# bootctl update
 
# bootctl update
 
</pre>
 
</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:
 
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:

Revision as of 19:41, 31 January 2020

By default Alpine uses Syslinux as bootloader. This page shows the basic steps you need to perform, if you for any reason want to switch bootloaders or apply some manual configuration.


Installing 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 syslinux package:

apk add syslinux

If you're using GPT partitions, install the GPT MBR onto the drive you want to install the bootloader on (in this case /dev/sda):

dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/sda

Or if you're using DOS partitions, install the DOS MBR instead:

dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda


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.

extlinux --install /boot

The configuration file is located in /boot/extlinux.conf. Alpine ships with a script called update-extlinux which automatically (re)generates this file, for example on updates to Syslinux. The settings for this script can be found in /etc/update-extlinux.conf, including the option to disable automatic overwriting of /boot/extlinux.conf. You can also place additional menu entries in the /etc/update-extlinux.d/ directory, e.g. for dual booting.


EFI

Underconstruction clock icon gray.svg
Todo: Work in progress. This should at least get you started.


Assuming /mnt is a FAT32 partition of type EF00 and /boot belongs to the rootfs created after running setup-disk:

mkdir -p /mnt/EFI/syslinux
cp /usr/share/syslinux/efi64/* /mnt/EFI/syslinux/
cp /boot/extlinux.conf /mnt/EFI/syslinux/syslinux.cfg
cp /boot/vmlinuz* /mnt/
cp /boot/initramfs* /mnt/

You may need to modify /mnt/EFI/syslinux/syslinux.cfg to change the paths to absolute paths (just add a / in front of the vmlinuz/initramfs entries), or copy the files to /mnt/EFI/syslinux instead (XXX: untested).

GRUB

To install GRUB in BIOS mode, (optionally) remove the Syslinux package and install the required GRUB packages:

apk del syslinux
apk add grub grub-bios

For EFI, install Grub's EFI package instead. Note that /boot has to be an EFI compatible filesystem like FAT32.

apk add grub-efi

Next install the MBR and GRUB binaries to disk for BIOS mode:

grub-install /dev/vda

For EFI mode:

grub-install --target=x86_64-efi --efi-directory=/boot

GRUB ships with an automatic config generator, including some automatic detection of other operating systems installed on the device:

grub-mkconfig -o /boot/grub/grub.cfg

This script can be configured via the /etc/default/grub file. See [1] for a list of available options.

systemd-boot

Underconstruction clock icon gray.svg
Todo: Work in progress. This is very short and doesn't cover a lot of the options.


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 systemd-boot package. Then make sure the boot and EFI partitions are mounted as read-write and install the bootloader with bootctl.

# apk add systemd-boot
# bootctl install

If you are not sure if the bootloader was installed then bootctl is-installed can be used to check, if it returns yes then systemd-boot is installed.

Configuring

Example configuration files for alpine are available on /usr/share/systemd/bootctl as loader.conf and alpine.conf.

The bootloader (not the boot entries) can be configured via the loader.conf file, an example is available in /usr/share/systemd/bootctl/loader.conf.

# cp /usr/share/systemd/bootctl/loader.conf /boot/loader
# vi /boot/loader/loader.conf

To prepare a proper boot entry for your operating system, one can copy the example alpine.conf to /boot/loader/entries and edit to be appropriate for their system, including: changing the example root=UUID= to point to their root partition; changing rootfstype= to the filesystem of the root parition and adding options used in previous syslinux or grub entries.

Entries for systemd-boot are located in /boot/loader/entries and take the form of one file for each boot entry. An example one for Alpine Linux is provided (assumes you use linux-lts). One can copy the example configuration to /boot/loader/entries and do the final edits necessary to have a working boot entry.

All the options available are documented in the systemd boot loader specification under Technical Details.

Updating

When the systemd-boot package is updated then the bootloader installed needs to be updated as well:

# bootctl update

Removing

If for any reason you wish to not use systemd-boot anymore then the bootctl binary also provides a command for easily removing the files that were installed with the install command:

# bootctl remove
# apk del systemd-boot

External Links