]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install/90-loaderentry: fix when /boot is not mountpoint
authorKir Kolyshkin <kolyshkin@gmail.com>
Sat, 1 Aug 2020 02:24:15 +0000 (19:24 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 3 Aug 2020 08:01:03 +0000 (10:01 +0200)
I happen to have a machine where /boot is not a separate mountpoint,
but rather just a directory under /. After upgrade to recent Fedora,
I found out that grub2 can't find any new kernels.

This happens because loadentry script generates kernel and initrd file
paths relative to /boot, while grub2 expects path to be relative to the
root of filesystem on which they are residing.

This commit fixes this issue by using stat's %m to find the mount point
of a partition holding the images, and using it as a prefix to be
removed from ENTRY_DIR_ABS.

Note that %m for stat requires coreutils 8.6, released in Oct 2010.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
src/kernel-install/90-loaderentry.install

index 6c0e27ba3a6ef991600bf36e65b27916c1142589..97fc3bcc3525de24ebaac9b6cecbe515dea5347f 100644 (file)
@@ -18,8 +18,9 @@ fi
 
 MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
 
-ENTRY_DIR="/$MACHINE_ID/$KERNEL_VERSION"
-BOOT_ROOT=${ENTRY_DIR_ABS%$ENTRY_DIR}
+BOOT_ROOT=${ENTRY_DIR_ABS%/$MACHINE_ID/$KERNEL_VERSION}
+BOOT_MNT=$(stat -c %m $BOOT_ROOT)
+ENTRY_DIR=/${ENTRY_DIR_ABS#$BOOT_MNT}
 
 if [[ $COMMAND == remove ]]; then
     rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"