How to make systemd-boot custom entries permanent

I’m using a dual boot of EndeavourOS with KDE Plasma and Gnome. I have edited the systemd-boot entries to look like this:

EndeavourOS (KDE Plasma)
EndeavourOS (Gnome)

But every time there is an update I have to redo the customization.

How can I make it permanent?

You would need to modify /usr/lib/kernel/install.d/90-loaderentry-fallback.install and /etc/kernel/install.d/90-loaderentry.install

What do I modify?

In /efi/loader/entries/*.conf
I edited title version sort-key

The scripts generate those values. You would have to find the places they were generated and figure out how to change them to do what you want.

maybe you need to do a pacman-hook in order to modify the /efi/loader/entries/*.conf after each update.

  1. in /etc/pacman.conf remove the comment # in ‘HookDir = /etc/pacman.d/hooks/’
  2. create the hook-script in ‘/etc/pacman.d/hooks/’
    I have here:
   [Trigger]
   Type = Package
   Operation = Install
   Operation = Upgrade
   Target = *

   [Action]
   Description = mike-update.hook nach update systemd-boot zz
   When = PostTransaction
   Exec = /home/mike/bin/zz
  1. In my homedir I have the script zz which modifies the title in the
    /efi/loader/entries/*.conf

Are there instructions somewhere on how to do this?

No, you would have to read the scripts and figure out what to change.

Can you share your script?

I need to check over it first. My script is not generally exemplary, it just works for me with my limited programming knowledge. Maybe it can help to find out, what you need.
I will post it tomorrow.

It looks like I just need the version and sort-key to be permanent. The title doesn’t seem to change.

version KDE Plasma
sort-key 01
version Gnome
sort-key 02

Thanks

The title is what appears in the boot menu. My script modifies the title. So I can distinguish different intallations and releases in the boot menue. Tis is most important for me.
Here it comes:

#!/bin/bash
# /home/mike/bin/zz

echo
echo ===================================================================================

echo "hier ist  $0 (14.05.2025)."
# notify-send "hier ist ($0 ??.12.2023)."

echo "HOSTNAME: "$HOSTNAME

HOME=/home/mike
echo "HOME: "$HOME

DAT=`date "+%d.%m.-%H:%M"`
echo "DAT: "$DAT

ESP=$(bootctl -p)
echo "ESP: "$ESP

echo "Inhalt von "$ESP"/loader/entries/:"
sudo ls -oh $ESP/loader/entries/

echo

DISTRIB_DESCRIPTION=$(grep DISTRIB_DESCRIPTION /etc/lsb-release | cut -d= -f2)
# echo "DISTRIB_DESCRIPTION: "$DISTRIB_DESCRIPTION

PRETTY_NAME=$(grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d \")
# echo "PRETTY_NAME: "$PRETTY_NAME

MODULES=$(ls /usr/lib/modules)
# echo "MODULES: "$MODULES

VERSION=$(ls /usr/lib/modules | tr ' ' '\n' | tail -1)
# echo "VERSION: "$VERSION

LFDKERNEL=$(uname -r)
echo "LFDKERNEL: "$LFDKERNEL

DEVPART=$(findmnt -no SOURCE /)
DEVPART=${DEVPART%'[/@]'}
 echo "DEVPART: "$DEVPART

PART=${DEVPART##*/}
 echo "PART: "$PART

LABEL=$(lsblk -lno name,label | grep ${PART} | tr -s " " | cut -d" " -f2)
echo "LABEL: "$LABEL

UUID=$(lsblk -no uuid $DEVPART)
echo "UUID: "$UUID

MIDUI=${UUID:0:8}
echo "MIDUI: "$MIDUI

MACHINEID=$(cat /etc/machine-id)
echo "MACHINEID: "$MACHINEID

MID=${MACHINEID:0:8}
echo "MID: "$MID

ID=$(grep ^ID= /etc/os-release | cut -d\= -f2 | tr -d \")
echo "ID: "$ID

RELEASE=$(grep CODENAME /etc/lsb-release | cut -d= -f2 | tr -d \")
echo "RELEASE: "$RELEASE

SORTKEY=$PART' '$(echo $LABEL | tr -d ' ' | tr -d '"')
echo "SORTKEY: "$SORTKEY

if [[ $(grep -ic name=.*ubuntu /etc/os-release) > 1 ]] ; then
    SYSTEM=ubuntu
elif [[ $(grep -ic name=.*tuxedo /etc/os-release) > 1 ]] ; then
    SYSTEM=tuxedo
elif [[ $(grep -ic name=.*endeavouros /etc/os-release) > 1 ]] ; then
    SYSTEM=endeavouros
else
    echo "kein System erkannt!"
    exit
fi

echo "SYSTEM: "$SYSTEM
KERNELDIR=$ESP/$MACHINEID/$VERSION
echo "KERNELDIR: "$KERNELDIR

KERNELCNV=$MACHINEID/$VERSION
echo "KERNELCNV: "$KERNELCNV

echo

[[ -d $KERNELDIR ]] || sudo mkdir -pv $KERNELDIR

if [[ $SYSTEM == ubuntu || $SYSTEM == tuxedo ]] ; then

    sudo ls -oh /boot/initrd.img
    sudo cp -v /boot/initrd.img $KERNELDIR/initrd.img
    
    sudo ls -oh /boot/vmlinuz
    sudo cp -v /boot/vmlinuz $KERNELDIR/vmlinuz

    echo "kernel $VERSION kopiert."
    echo

fi

echo "Inhalt von KERNELDIR "$KERNELDIR":"
sudo ls -oh $KERNELDIR

echo ===================================================================================

CONFFILE="$ESP/loader/entries/"$MACHINEID-$VERSION.conf
echo "CONFFILE: "$CONFFILE

SETDEFAULT=$MACHINEID-$VERSION.conf
echo "SETDEFAULT: "$SETDEFAULT

TITLE="${LABEL} ${PRETTY_NAME} ${VERSION} ${DATIT} ${HOSTNAME} ${MID} ${MIDUI} ${PART}"
echo "TITLE: "$TITLE

if sudo test ! -f $CONFFILE ; then
    echo "====> CONFFILE existiert nicht! "

    echo "title      $TITLE" > /tmp/CONF
    echo "sort-key   $SORTKEY" >> /tmp/CONF
    echo "options root=UUID=$UUID" >> /tmp/CONF
    echo "linux $KERNELCNV/vmlinuz" >> /tmp/CONF
    echo "initrd $KERNELCNV/initrd.img" >> /tmp/CONF

    sudo cp -v /tmp/CONF $CONFFILE
fi

sudo sed -i "s/title.*/title      ${TITLE}/" $CONFFILE
sudo sed -i "s/sort-key.*/sort-key   ${SORTKEY}/" $CONFFILE
sudo sed -i "s/root=UUID=.* /root=UUID=${UUID} /" $CONFFILE

if [[ $SYSTEM == ubuntu || $SYSTEM == tuxedo ]] ; then
    sudo sed -i "s%linux .*%linux ${KERNELCNV}/vmlinuz%" $CONFFILE
    sudo sed -i "s%initrd .*%initrd ${KERNELCNV}/initrd.img%" $CONFFILE
fi

echo ===================================================================================
sudo cat $CONFFILE
echo ===================================================================================

sudo bootctl install
echo "bootctl install installiert."

sudo bootctl set-default $SETDEFAULT

echo

if [[ $SYSTEM == endeavouros ]] ; then
#
   echo ===================================================================================
#
   FALLBACK="$ESP/loader/entries/"$MACHINEID-$VERSION-fallback.conf
   echo "FALLBACK: "$FALLBACK
   if sudo test -f $FALLBACK ; then
#
      TITLE="${LABEL} ${PRETTY_NAME} ${VERSION}-fallback ${HOSTNAME} ${MID} ${MIDUI} ${PART}"
      echo "TITLE: "$TITLE
#
      sudo sed -i "s/title.*/title      ${TITLE}/" $FALLBACK
      sudo sed -i "s/sort-key.*/sort-key   ${SORTKEY}/" $FALLBACK
      sudo sed -i "s/root=UUID=.* /root=UUID=${UUID} /" $FALLBACK
#
      echo ===================================================================================
      sudo cat $FALLBACK
      echo ===================================================================================
   else 
      echo "Fallback-Entry nicht gefunden."
   fi
#
   echo
#
fi

lsblk -o model,name,mountpoints,label,partuuid,uuid,fsavail,fsuse%

I don’t know how to modify that script. So I guess I will just give up for now, but thanks.