How to use the command 'bootctl' (with examples)

How to use the command 'bootctl' (with examples)

bootctl is a command-line utility designed to interact with EFI firmware boot settings and manage boot loaders on systems that use the Unified Extensible Firmware Interface (UEFI) instead of the traditional BIOS. It is part of the systemd suite and is primarily used for managing the bootloader, particularly systemd-boot. The command provides a range of functionalities, including displaying information about the firmware, listing available bootloader entries, and modifying bootloader installations.

Use case 1: Show information about the system firmware and the bootloaders

Code:

bootctl status

Motivation: Understanding the current status of your system’s firmware and bootloaders is crucial for troubleshooting boot issues or verifying configurations. By running this command, users can gain insights into the loader’s version, state, and the entries available.

Explanation: The status argument is invoked to display comprehensive information about the EFI firmware, including the version of the bootloader in use, its configuration, and details about the EFI System Partition.

Example output:

System:
     Firmware: UEFI 2.70 (American Megatrends 5.14.0)
  Secure Boot: disabled
 TPM2 Support: no

Current Boot Loader:
      Product: systemd-boot 245.4-1-arch
     Features: ✔ Boot counting
                ✔ Menu timeout control

Available Boot Loaders on ESP:
         ESP Path: /boot
        Boot Loaders: 1 (systemd-boot)
                Loaded: systemd-boot x64 245.4-1

Default Boot Loader Entry:
        Title: Arch Linux
        Linux: /vmlinuz-linux
     Initrd: /initramfs-linux.img
  Options: root=PARTUUID=12345678-9abc-def0-1234-56789abcdef0 rw

Use case 2: Show all available bootloader entries

Code:

bootctl list

Motivation: Having a list of all bootloader entries provides users the ability to see what operating systems or kernels are available to boot from. This is particularly useful for dual-boot systems where multiple entries can exist.

Explanation: The list argument tells bootctl to enumerate all the bootloader entries present on the system. This may include different kernels or operating systems.

Example output:

Boot Loader Entries:
        title: Arch Linux
           id: arch
       source: /boot/loader/entries/arch.conf

        title: Arch Linux Fallback
           id: arch-fallback
       source: /boot/loader/entries/arch-fallback.conf

        title: UEFI Firmware Settings
           id: firmware
       source: /boot/loader/entries/firmware.conf

Use case 3: Set a flag to boot into the system firmware on the next boot

Code:

sudo bootctl reboot-to-firmware true

Motivation: This use case is beneficial when the user needs to modify firmware settings, such as enabling or disabling secure boot without needing to manually press a key during boot to enter setup.

Explanation:

  • sudo: Grants administrative privileges required for modifying boot settings.
  • bootctl: The command being executed.
  • reboot-to-firmware: A specific option to set the UEFI/BIOS to enter setup mode on the next boot.
  • true: Sets the flag, indicating this behavior should occur during the next reboot.

Example output:

Reboot into firmware setup is scheduled for the next boot.

Use case 4: Specify the path to the EFI system partition

Code:

bootctl --esp-path=/path/to/efi_system_partition/

Motivation: Specifying the path to the EFI system partition is essential when the default mount points do not apply, such as custom setups or non-standard installations where the EFI partition is mounted at a different path.

Explanation:

  • bootctl: The main command.
  • --esp-path=: An option to specify the target path of the EFI System Partition (ESP).
  • /path/to/efi_system_partition/: The user-defined path where the ESP is mounted.

Example output: There is no standard output; however, it uses the specified path for subsequent operations.

Use case 5: Install systemd-boot into the EFI system partition

Code:

sudo bootctl install

Motivation: Installing systemd-boot is essential when initializing a new system or changing from another boot manager to systemd-boot. This command sets up systemd-boot to be used as the primary bootloader.

Explanation:

  • sudo: Provides administrative access needed for installation.
  • bootctl: Command to be executed for boot manager configurations.
  • install: Instructs bootctl to place and configure systemd-boot on the EFI System Partition.

Example output:

Created EFI boot entry "Linux Boot Manager" for file "\EFI\systemd\systemd-bootx64.efi".

Use case 6: Remove all installed versions of systemd-boot from the EFI system partition

Code:

sudo bootctl remove

Motivation: Uninstalling systemd-boot may be necessary when switching to a different boot manager or preparing a system for decommission by reversing all custom bootloader changes.

Explanation:

  • sudo: Grants necessary privileges to modify system boot settings.
  • bootctl: Command executed for boot configuration tasks.
  • remove: Instructs bootctl to delete systemd-boot from the EFI System Partition.

Example output:

All systemd-boot entries removed from EFI system partition.

Conclusion:

The bootctl command is a powerful utility for managing EFI boot loaders on UEFI-enabled systems. Whether one needs to view bootloader information, configure system startup preferences, or change boot managers, bootctl provides versatile options to suit various administrative needs. Each command option discussed above offers valuable control and clarity for system administrators and advanced users managing Linux-based systems.

Related Posts

How to use the command 'ppmmake' (with examples)

How to use the command 'ppmmake' (with examples)

The ppmmake command is a utility featured in the Netpbm library—an open-source package of graphics programs and a programming library.

Read More
How to use the command `urpmf` (with examples)

How to use the command `urpmf` (with examples)

The urpmf command is a part of the URPMI suite of tools used in Mageia Linux distribution for managing packages.

Read More
How to Create a PostgreSQL Database Using the `createdb` Command (with examples)

How to Create a PostgreSQL Database Using the `createdb` Command (with examples)

The createdb command is a shell utility wrapped around the SQL command CREATE DATABASE, which is used in PostgreSQL to create a new database.

Read More