From b6bf8bf5187e38e6787ea61807e64ac7ac80e6c9 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 15 Aug 2016 02:26:01 +0200 Subject: [PATCH] Fix GRUB menu entry generation for Debian & Ubuntu This patch fixes the /etc/grub.d/40_custom generation for the Debian sample so that it properly extracts the UUID For /boot and / Note: the maintenance free symlinks /vmlinuz and /initrd.img may not work properly with /boot on a separate partition or disk. If only the symlinks where in /boot as well ... Signed-off-by: Joachim Nilsson --- contrib/debian/build.sh | 2 +- contrib/debian/grub.d/40_custom | 7 +++---- contrib/debian/install.sh | 8 +++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/contrib/debian/build.sh b/contrib/debian/build.sh index a2e75884..54657350 100755 --- a/contrib/debian/build.sh +++ b/contrib/debian/build.sh @@ -24,7 +24,7 @@ echo --with-heading="Debian GNU/Linux 8.5" --with-hostname=jessie \ --enable-inetd-echo-plugin --enable-inetd-chargen-plugin \ --enable-inetd-daytime-plugin --enable-inetd-discard-plugin \ - --enable-inetd-time-plugin + --enable-inetd-time-plugin if [ $? -ne 0 ]; then echo diff --git a/contrib/debian/grub.d/40_custom b/contrib/debian/grub.d/40_custom index c41f2028..c45efcbb 100755 --- a/contrib/debian/grub.d/40_custom +++ b/contrib/debian/grub.d/40_custom @@ -4,12 +4,11 @@ exec tail -n +3 $0 # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. -menuentry 'Debian GNU/Linux with Finit' --class debian --class gnu-linux --class gnu --class os --user { +menuentry '$MENU with Finit' --class $TYPE --class gnu-linux --class gnu --class os --user { insmod gzio insmod part_msdos insmod ext2 - set root='(hd0,0)' - search --no-floppy --fs-uuid --set=root 05831a47-bf7c-4812-9cb2-818537aa68fc - linux /vmlinuz root=UUID=05831a47-bf7c-4812-9cb2-818537aa68fc ro quiet init=/sbin/finit + search --no-floppy --fs-uuid --set=root $BOOT + linux /vmlinuz root=UUID=$ROOT ro quiet init=/sbin/finit initrd /initrd.img } diff --git a/contrib/debian/install.sh b/contrib/debian/install.sh index ebae59f0..f43d73bb 100755 --- a/contrib/debian/install.sh +++ b/contrib/debian/install.sh @@ -1,7 +1,7 @@ #!/bin/sh SYMLINKS="start.d/*" -FILES="finit.conf grub.d/40_custom" +FILES="finit.conf" if [ "x`id -u`" != "x0" ]; then echo @@ -43,6 +43,12 @@ if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then for link in $SYMLINKS; do cp -va $link /etc/$link done + echo "Setting up a GRUB boot entry ..." + MENU=`grep gnu-linux /boot/grub/grub.cfg |head -1 |sed "s/menuentry '\([^']*\).*/\1/"` + TYPE=`grep gnu-linux /boot/grub/grub.cfg |head -1 |sed "s/.*' --class \([a-z]*\).*/\1/"` + BOOT=`grep set=root /boot/grub/grub.cfg |head -1 |sed 's/.* \([a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*\).*/\1/'` + ROOT=`grep root=UUID /boot/grub/grub.cfg |head -1 |sed 's/.*UUID=\([a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*\).*/\1/'` + cat grub.d/40_custom | sed "s,\$BOOT,$BOOT,;s,\$ROOT,$ROOT,;s,\$TYPE,$TYPE,;s,\$MENU,$MENU," >/etc/grub.d/40_custom update-grub else echo "Aborting install."