Skip to content

Switch Between KDE Linux and Another Operating System

If you have KDE Linux installed alongside another Linux-based operating system, you can normally reach both of them through your computer’s firmware boot menu — the one you get by pressing a key such as F12 while the machine starts up.

That works, but it means catching a key press within a second or two on every restart. This page describes how to add an entry for each system to the other system’s boot menu, so you can switch between them from a menu that waits for you.

This page does not explain how to install two operating systems side by side. It assumes you already have both installed and working, both installed in UEFI mode, and sharing the same EFI System Partition (ESP). Note that installing KDE Linux to anything other than an entire disk is known to fail under certain circumstances and is not a formally supported configuration yet.

Which system am I typing this on?

Each section below is labelled with the system its commands belong on, because the two are not interchangeable:

  • On KDE Linux, administrator commands use run0, as everywhere else in this documentation.
  • On the other system, they most likely use sudo instead, and file locations vary by distribution.

Running a command on the wrong system will at best do nothing.

If the other system also uses systemd-boot

There is usually nothing to set up. systemd-boot finds entries by looking at the ESP, so if both systems write to the same one, both should already appear in the same menu.

To check, run the following on KDE Linux or the other system:

bootctl list

If the other system uses GRUB

GRUB and systemd-boot do not see each other automatically, so an entry has to be added on each side.

Add KDE Linux to GRUB’s menu

Do this on the other system, the one that uses GRUB.

Add the following to /etc/grub.d/40_custom, below the lines that are already there:

menuentry "systemd-boot" --class systemd {
    insmod part_gpt
    insmod fat
    insmod chain
    search --no-floppy --file --set=root /EFI/systemd/systemd-bootx64.efi
    chainloader /EFI/systemd/systemd-bootx64.efi
}

Nothing in there needs to be adjusted: bootctl always installs systemd-boot at that same path, whichever distribution it was run on.

Then make the file executable and regenerate GRUB’s configuration:

sudo chmod +x /etc/grub.d/40_custom
sudo grub-mkconfig -o /boot/grub/grub.cfg

Some distributions name these differently — for example grub2-mkconfig and /boot/grub2/grub.cfg on Fedora and openSUSE. Check what your distribution uses.

Add GRUB to KDE Linux’s menu

Do this on KDE Linux.

For this direction you first need to know where GRUB lives on the ESP. There is no single answer: every distribution picks its own directory name there, so this has to be looked up rather than copied.

To find it:

run0 find /boot -name 'grub*.efi' 2>/dev/null

Take the result and drop everything before /EFI. If you get /boot/EFI/debian/grubx64.efi, the path you want is /EFI/debian/grubx64.efi.

If Secure Boot is enabled, look in that same directory for shimx64.efi and use that path instead, if there is one. Not every distribution ships one.

Now open a text editor, create a file called grub.conf in your home directory, and put this in it:

title    GRUB ([name for the other OS goes here])
efi      [path to the EFI file goes here, e.g. /EFI/debian/grubx64.efi]
sort-key zz-grub

Replace the part in the first line with whatever you would like the entry to be called in the menu, and the part in the second line with the path you just looked up. Then move the file into place:

run0 mv ~/grub.conf /boot/loader/entries/grub.conf

bootctl list should now show it, and it will appear at the bottom of the boot menu on the next restart.

Notes

  • If each menu’s default entry is the other bootloader, give at least one a non-zero timeout, or you will bounce between them like in a particle accelerator. So avoid doing that.
  • A shared ESP holds kernels for both systems, so it can fill up. df -h /boot is worth a look if updates start failing.
  • Updates on either system can change the firmware boot order or remove entries. If something changes unexpectedly, efibootmgr -v and bootctl list are good places to start looking.
  • If the two systems have separate ESPs, the GRUB side may still work, but the systemd-boot side generally will not, since it can only load files from its own ESP.

Article contributed by under the CC-BY-4.0 license.