systemd
Daemonjournalctl
: Query the systemd
Journaludev
This chapter describes how to configure GRUB 2, the boot loader used in openSUSE® Leap. It is the successor of the traditional GRUB boot loader—now called “GRUB Legacy”. A YaST module is available for configuring the most important settings. The boot procedure as a whole is outlined in Chapter 9, Booting a Linux System. For details on Secure Boot support for UEFI machines, see Chapter 14, UEFI (Unified Extensible Firmware Interface).
The configuration is stored in different files.
More file systems are supported (for example, Btrfs).
Can directly read files stored on LVM or RAID devices.
The user interface can be translated and altered with themes.
Includes a mechanism for loading modules to support additional features, such as file systems, etc.
Automatically searches for and generates boot entries for other kernels and operating systems, such as Windows.
Includes a minimal Bash-like console.
The configuration of GRUB 2 is based on the following files:
/boot/grub2/grub.cfg
This file contains the configuration of the GRUB 2 menu items. It
replaces menu.lst
used in GRUB Legacy.
grub.cfg
is automatically generated by the
grub2-mkconfig
command, and should not be edited.
/boot/grub2/custom.cfg
This optional file is directly sourced by grub.cfg
at boot time and can be used to add custom items to the boot menu.
Starting with openSUSE Leap Leap 42.2 these entries will also
be parsed when using grub-once
.
/etc/default/grub
This file controls the user settings of GRUB 2 and usually includes additional environmental settings such as backgrounds and themes.
/etc/grub.d/
The scripts in this directory are read during execution of the
grub2-mkconfig
command. Their instructions are
integrated into the main configuration file
/boot/grub/grub.cfg
.
/etc/sysconfig/bootloader
This configuration file is used when configuring the boot loader with
YaST and every time a new kernel is installed. It is evaluated by the
perl-bootloader which modifies the boot loader configuration file (for
example /boot/grub2/grub.cfg
for GRUB 2)
accordingly. /etc/sysconfig/bootloader
is not a
GRUB 2-specific configuration file—the values are applied to any
boot loader installed on openSUSE Leap.
/boot/grub2/x86_64-efi
,
,
These configuration files contain architecture-specific options.
GRUB 2 can be controlled in various ways. Boot entries from an existing
configuration can be selected from the graphical menu (splash screen). The
configuration is loaded from the file
/boot/grub2/grub.cfg
which is compiled from other
configuration files (see below). All GRUB 2 configuration files are
considered system files, and you need root
privileges to edit them.
After having manually edited GRUB 2 configuration files, you need to run
grub2-mkconfig
to activate the changes. However, this
is not necessary when changing the configuration with YaST, since it will
automatically run grub2-mkconfig
.
/boot/grub2/grub.cfg
#
The graphical splash screen with the boot menu is based on the GRUB 2
configuration file /boot/grub2/grub.cfg
, which
contains information about all partitions or operating systems that can be
booted by the menu.
Every time the system is booted, GRUB 2 loads the menu file directly from
the file system. For this reason, GRUB 2 does not need to be re-installed
after changes to the configuration file. grub.cfg
is
automatically rebuilt with kernel installations or removals.
grub.cfg
is compiled by the
grub2-mkconfig
from the file
/etc/default/grub
and scripts found in the
/etc/grub.d/
directory. Therefore you should never
edit the file manually. Instead, edit the related source files or use the
YaST module to modify the configuration as
described in Section 12.3, “Configuring the Boot Loader with YaST”.
/etc/default/grub
#More general options of GRUB 2 belong here, such as the time the menu is displayed, or the default OS to boot. To list all available options, see the output of the following command:
grep "export GRUB_DEFAULT" -A50 /usr/sbin/grub2-mkconfig | grep GRUB_
In addition to already defined variables, the user may introduce their own
variables, and use them later in the scripts found in the
/etc/grub.d
directory.
After having edited /etc/default/grub
, run
grub2-mkconfig
to update the main configuration file.
All options set in this file are general options that affect all boot entries. Specific options for Xen Kernels or the Xen hypervisor can be set via the GRUB_*_XEN_* configuration options. See below for details.
GRUB_DEFAULT
Sets the boot menu entry that is booted by default. Its value can be a numeric value, the complete name of a menu entry, or “saved”.
GRUB_DEFAULT=2
boots the third (counted from zero)
boot menu entry.
GRUB_DEFAULT="2>0"
boots the first submenu entry
of the third top-level menu entry.
GRUB_DEFAULT="Example boot menu entry"
boots the menu
entry with the title “Example boot menu entry”.
GRUB_DEFAULT=saved
boots the entry specified by the
grub2-reboot
or grub2-set-default
commands. While grub2-reboot
sets the
default boot entry for the next reboot only,
grub2-set-default
sets the default boot entry until
changed.
GRUB_HIDDEN_TIMEOUT
Waits the specified number of seconds for the user to press a key.
During the period no menu is shown unless the user presses a key. If no
key is pressed during the time specified, the control is passed to
GRUB_TIMEOUT
.
GRUB_HIDDEN_TIMEOUT=0
first checks whether
Shift is pressed and shows the boot menu if yes,
otherwise immediately boots the default menu entry. This is the default
when only one bootable OS is identified by GRUB 2.
GRUB_HIDDEN_TIMEOUT_QUIET
If false
is specified, a countdown timer is displayed
on a blank screen when the GRUB_HIDDEN_TIMEOUT
feature is active.
GRUB_TIMEOUT
Time period in seconds the boot menu is displayed before automatically
booting the default boot entry. If you press a key, the timeout is
cancelled and GRUB 2 waits for you to make the selection manually.
GRUB_TIMEOUT=-1
will cause the menu to be displayed
until you select the boot entry manually.
GRUB_CMDLINE_LINUX
Entries on this line are added at the end of the boot entries for normal and recovery mode. Use it to add kernel parameters to the boot entry.
GRUB_CMDLINE_LINUX_DEFAULT
Same as GRUB_CMDLINE_LINUX
but the entries are
appended in the normal mode only.
GRUB_CMDLINE_LINUX_RECOVERY
Same as GRUB_CMDLINE_LINUX
but the entries are
appended in the recovery mode only.
GRUB_CMDLINE_LINUX_XEN_REPLACE
This entry will completely replace the
GRUB_CMDLINE_LINUX
parameters for all Xen boot
entries.
GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT
Same as GRUB_CMDLINE_LINUX_XEN_REPLACE
but it will
only replace parameters ofGRUB_CMDLINE_LINUX_DEFAULT
.
GRUB_CMDLINE_XEN
This entry specifies the kernel parameters for the Xen guest kernel
only—the operation principle is the same as for
GRUB_CMDLINE_LINUX
.
GRUB_CMDLINE_XEN_DEFAULT
Same as GRUB_CMDLINE_XEN
—the operation
principle is the same as for
GRUB_CMDLINE_LINUX_DEFAULT
.
GRUB_TERMINAL
Enables and specifies an input/output terminal device. Can be
console
(PC BIOS and EFI consoles),
serial
(serial terminal),
ofconsole
(Open Firmware console), or the default
gfxterm
(graphics-mode output). It is also possible
to enable more than one device by quoting the required options, for
example GRUB_TERMINAL="console serial"
.
GRUB_GFXMODE
The resolution used for the gfxterm
graphical
terminal. Note that you can only use modes supported by your graphics
card (VBE). The default is ‘auto’, which tries to select a preferred
resolution. You can display the screen resolutions available to GRUB 2
by typing vbeinfo
in the GRUB 2 command line. The
command line is accessed by typing C when the GRUB 2
boot menu screen is displayed.
You can also specify a color depth by appending it to the resolution
setting, for example GRUB_GFXMODE=1280x1024x24
.
GRUB_BACKGROUND
Set a background image for the gfxterm
graphical
terminal. The image must be a file readable by GRUB 2 at boot time, and
it must end with the .png
, .tga
,
.jpg
, or .jpeg
suffix. If
necessary, the image will be scaled to fit the screen.
GRUB_DISABLE_OS_PROBER
If this option is set to true
, automatic searching
for other operating systems is disabled. Only the kernel images in
/boot/
and the options from your own scripts in
/etc/grub.d/
are detected.
SUSE_BTRFS_SNAPSHOT_BOOTING
If this option is set to true
, GRUB 2 can boot
directly into Snapper snapshots. For more information, see
Section 3.3, “System Rollback by Booting from Snapshots”.
All *_DEFAULT
parameters can be configured manually or
with YaST.
For a complete list of options, see the GNU GRUB manual. For a complete list of possible parameters, see http://en.opensuse.org/Linuxrc.
/etc/grub.d
#
The scripts in this directory are read during execution of the
grub2-mkconfig
command, and their instructions are
incorporated into /boot/grub2/grub.cfg
. The order of
menu items in grub.cfg
is determined by the order in
which the files in this directory are run. Files with a leading numeral are
executed first, beginning with the lowest number.
00_header
is run before 10_linux
,
which would run before 40_custom
. If files with
alphabetic names are present, they are executed after the numerically-named
files. Only executable files generate output to
grub.cfg
during execution of
grub2-mkconfig
. By default all files in the
/etc/grub.d
directory are executable. The most
important scripts are:
00_header
Sets environmental variables such as system file locations, display
settings, themes, and previously saved entries. It also imports
preferences stored in the /etc/default/grub
.
Normally you do not need to make changes to this file.
10_linux
Identifies Linux kernels on the root device and creates relevant menu entries. This includes the associated recovery mode option if enabled. Only the latest kernel is displayed on the main menu page, with additional kernels included in a submenu.
30_os-prober
This script uses OS-prober
to search for Linux and
other operating systems and places the results in the GRUB 2 menu. There
are sections to identify specific other operating systems, such as
Windows or macOS.
40_custom
This file provides a simple way to include custom boot entries into
grub.cfg
. Make sure that you do not change the
exec tail -n +3 $0
part at the beginning.
90_persistent
This is a special script that copies a corresponding part of the
grub.cfg
file and outputs it back unchanged. This
way you can modify that part of grub.cfg
directly
and the change survives the execution of
grub2-mkconfig
.
The processing sequence is set by the preceding numbers with the lowest number being executed first. If scripts are preceded by the same number the alphabetical order of the complete name decides the order.
In GRUB Legacy, the device.map
configuration file was
used to derive Linux device names from BIOS drive numbers. The mapping
between BIOS drives and Linux devices cannot always be guessed correctly.
For example, GRUB Legacy would get a wrong order if the boot sequence of
IDE and SCSI drives is exchanged in the BIOS configuration.
GRUB 2 avoids this problem by using device ID strings (UUIDs) or file
system labels when generating grub.cfg
. GRUB 2
utilities create a temporary device map on the fly, which is usually
sufficient, particularly in the case of single-disk systems.
However, if you need to override the GRUB 2's automatic device mapping
mechanism, create your custom mapping file
/boot/grub2/device.map
. The following example changes
the mapping to make DISK 3
the boot disk. Note that
GRUB 2 partition numbers start with 1
and not with
0
as in GRUB Legacy.
(hd1) /dev/disk-by-id/DISK3 ID (hd2) /dev/disk-by-id/DISK1 ID (hd3) /dev/disk-by-id/DISK2 ID
Even before the operating system is booted, GRUB 2 enables access to file systems. Users without root permissions can access files in your Linux system to which they have no access after the system is booted. To block this kind of access or to prevent users from booting certain menu entries, set a boot password.
If set, the boot password is required on every boot, which means the system does not boot automatically.
Proceed as follows to set a boot password. Alternatively use YaST ().
Encrypt the password using grub2-mkpasswd-pbkdf2:
tux >
sudo grub2-mkpasswd-pbkdf2
Password: ****
Reenter password: ****
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...
Paste the resulting string into the file
/etc/grub.d/40_custom
together with the set
superusers
command.
set superusers="root" password_pbkdf2 root grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...
Run grub2-mkconfig
to import the changes into the
main configuration file.
After you reboot, you will be prompted for a user name and a password when
trying to boot a menu entry. Enter root
and the password
you typed during the grub2-mkpasswd-pbkdf2
command. If
the credentials are correct, the system will boot the selected boot entry.
For more information, see https://www.gnu.org/software/grub/manual/grub.html#Security.
The easiest way to configure general options of the boot loader in your openSUSE Leap system is to use the YaST module. In the , select › . The module shows the current boot loader configuration of your system and allows you to make changes.
Use the
tab to view and change settings related to type, location and advanced loader settings. You can choose whether to use GRUB 2 in standard or EFI mode.If you have an EFI system you can only install GRUB2-EFI, otherwise your system is no longer bootable.
To reinstall the boot loader, make sure to change a setting in YaST and then change it back. For example, to reinstall GRUB2-EFI, select
first and then immediately switch back to .Otherwise, the boot loader may only be partially reinstalled.
To use a boot loader other than the ones listed, select
. Read the documentation of your boot loader carefully before choosing this option.
The default location of the boot loader depends on the partition setup and
is either the Master Boot Record (MBR) or the boot sector of the
/
partition. To modify the location of the boot loader,
follow these steps:
Select the
tab and then choose one of the following options for :
This installs the boot loader in the MBR of the disk containing the
directory /boot
. Usually this will be the disk
mounted to /
, but if /boot
is
mounted to a separate partition on a different disk, the MBR of that
disk will be used.
This installs the boot loader in the boot sector of the
/
partition.
Use this option to specify the location of the boot loader manually.
Click
to apply your changes.If your computer has more than one hard disk, you can specify the boot sequence of the disks. For more information, see Section 12.2.4, “Mapping between BIOS Drives and Linux Devices”.
Open the
tab.Click
.If more than one disk is listed, select a disk and click
or to reorder the displayed disks.Click
two times to save the changes.Advanced boot options can be configured via the
tab.Change the value of
by typing in a new value and clicking the appropriate arrow key with your mouse.When selected, the boot loader searches for other systems like Windows or other Linux installations.
Hides the boot menu and boots the default entry.
Select the desired entry from the “Default Boot Section” list. Note that the “>” sign in the boot entry name delimits the boot section and its subsection.
Protects the boot loader and the system with an additional password. For more information, see Section 12.2.6, “Setting a Boot Password”.
The VGA Mode option specifies the default screen resolution during the boot process.
The optional kernel parameters are added at the end of the default parameters. For a list of all possible parameters, see http://en.opensuse.org/Linuxrc.
When checked, the boot menu appears on a graphical splash screen rather than in a text mode. The resolution of the boot screen can be then set from the
list, and graphical theme definition file can be specified with the file-chooser.
If your machine is controlled via a serial console, activate this option
and specify which COM port to use at which speed. See info
grub
or
http://www.gnu.org/software/grub/manual/grub.html#Serial-terminal
Activates the partition that contains the boot loader. Some legacy operating systems (such as Windows) can only boot from an active partition.
Replaces the current MBR with generic, operating system independent code.
Starts TrustedGRUB2 which supports trusted computing functionality (Trusted Platform Module (TPM)). For more information refer to https://github.com/Sirrix-AG/TrustedGRUB2.
On 3215 and 3270 terminals there are some differences and limitations on how to move the cursor and how to issue editing commands within GRUB 2.
Interactivity is strongly limited. Typing often does not result in visual feedback. To see where the cursor is, type an underscore (_).
The 3270 terminal is much better at displaying and refreshing screens than the 3215 terminal.
“Traditional” cursor movement is not possible. Alt, Meta, Ctrl and the cursor keys do not work. To move the cursor, use the key combinations listed in Section 12.4.2, “Key Combinations”.
The caret (^) is used as a control character. To type a literal ^ followed by a letter, type ^, ^, LETTER.
The Enter key does not work, use ^–J instead.
Common Substitutes: |
^–J |
engage (“Enter”) |
^–L |
abort, return to previous “state” | |
^–I |
tab completion (in edit and shell mode) | |
Keys Available in Menu Mode: |
^–A |
first entry |
^–E |
last entry | |
^–P |
previous entry | |
^–N |
next entry | |
^–G |
previous page | |
^–C |
next page | |
^–F |
boot selected entry or enter submenu (same as ^–J) | |
E |
edit selected entry | |
C |
enter GRUB-Shell | |
Keys Available in Edit Mode: |
^–P |
previous line |
^–N |
next line | |
^–B |
backward char | |
^–F |
forward char | |
^–A |
beginning of line | |
^–E |
end of line | |
^–H |
backspace | |
^–D |
delete | |
^–K |
kill line | |
^–Y |
yank | |
^–O |
open line | |
^–L |
refresh screen | |
^–X |
boot entry | |
^–C |
enter GRUB-Shell | |
Keys Available in Command Line Mode: |
^–P |
previous command |
^–N |
next command from history | |
^–A |
beginning of line | |
^–E |
end of line | |
^–B |
backward char | |
^–F |
forward char | |
^–H |
backspace | |
^–D |
delete | |
^–K |
kill line | |
^–U |
discard line | |
^–Y |
yank |
grub2-mkconfig
Generates a new /boot/grub2/grub.cfg
based on
/etc/default/grub
and the scripts from
/etc/grub.d/
.
grub2-mkconfig -o /boot/grub2/grub.cfg
Running grub2-mkconfig
without any parameters prints
the configuration to STDOUT where it can be reviewed. Use
grub2-script-check
after
/boot/grub2/grub.cfg
has been written to check its
syntax.
grub2-mkconfig
Cannot Repair UEFI Secure Boot TablesIf you are using UEFI Secure Boot and your system is not reaching GRUB 2 correctly anymore, you may need to additionally reinstall Shim and regenerate the UEFI boot table. To do so, use:
root #
shim-install --config-file=/boot/grub2/grub.cfg
grub2-mkrescue
Creates a bootable rescue image of your installed GRUB 2 configuration.
grub2-mkrescue -o save_path/name.iso iso
grub2-script-check
Checks the given file for syntax errors.
grub2-script-check /boot/grub2/grub.cfg
grub2-once
Set the default boot entry for the next boot only. To get the list of
available boot entries use the --list
option.
grub2-once number_of_the_boot_entry
grub2-once
HelpCall the program without any option to get a full list of all possible options.
Extensive information about GRUB 2 is available at
http://www.gnu.org/software/grub/. Also refer to the
grub
info page. You can also search for the keyword
“GRUB 2” in the Technical Information Search at
http://www.suse.com/support to get information about
special issues.