[OE-core] [PATCH] install: Look for grub2 files on the initramfs, not rootfs

Darren Hart dvhart at linux.intel.com
Thu Feb 21 17:28:02 UTC 2013


Fixes [YOCTO #3870] atom-pc - cannot boot image on netbook after install

The problem here is that grub2 is installed but a grub 1 menu.lst is
created at install time. At boot, grub2 doesn't find a grub.cfg file and
drops to the grub shell.

This happens because the installer is looking for 40_custom (a grub2
file) on the rootfs, but grub2 isn't installed on the rootfs. It exists
in the initramfs. Patching the installer to look on the initramfs
resolves the problem.

Note that the problem may have occurred if grub2 used to be installed on
the rootfs but was later removed. In any case, the installer is HORRIBLE
and really needs to be completely redesigned as part of the deployment
effort. For now, this should get the live image installer limping along
again.

Tested on a Toshiba NB-305.

Signed-off-by: Darren Hart <dvhart at linux.intel.com>
Cc: alexandru.c.georgescu at intel.com
Cc: sgw at linux.intel.com
Cc: ross.burton at intel.com
Cc: richard.purdie at intel.com
---
 .../initrdscripts/files/init-install.sh            | 25 +++++++++++-----------
 .../initrdscripts/initramfs-live-install_1.0.bb    |  2 +-
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index c1f8cba..2c4486a 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -151,14 +151,19 @@ if [ -d /ssd/etc/ ] ; then
     fi
 fi
 
-if [ -f /ssd/etc/grub.d/40_custom ] ; then
+if [ -f /etc/grub.d/40_custom ] ; then
     echo "Preparing custom grub2 menu..."
-    sed -i "s at __ROOTFS__@$rootfs $rootwait at g" /ssd/etc/grub.d/40_custom
-    sed -i "s/__VIDEO_MODE__/$3/g" /ssd/etc/grub.d/40_custom
-    sed -i "s/__VGA_MODE__/$4/g" /ssd/etc/grub.d/40_custom
-    sed -i "s/__CONSOLE__/$5/g" /ssd/etc/grub.d/40_custom
+    GRUBCFG="/bootmnt/boot/grub/grub.cfg"
     mount $bootfs /bootmnt
-    cp /ssd/etc/grub.d/40_custom /bootmnt/40_custom
+    mkdir -p $(dirname $GRUBCFG)
+    cp /etc/grub.d/40_custom $GRUBCFG
+    sed -i "s at __ROOTFS__@$rootfs $rootwait at g" $GRUBCFG
+    sed -i "s/__VIDEO_MODE__/$3/g" $GRUBCFG
+    sed -i "s/__VGA_MODE__/$4/g" $GRUBCFG
+    sed -i "s/__CONSOLE__/$5/g" $GRUBCFG
+    sed -i "/#/d" $GRUBCFG
+    sed -i "/exec tail/d" $GRUBCFG
+    chmod 0444 $GRUBCFG
     umount /bootmnt
 fi
 
@@ -171,12 +176,8 @@ grub-install --root-directory=/ssd /dev/${device}
 
 echo "(hd0) /dev/${device}" > /ssd/boot/grub/device.map
 
-if [ -f /ssd/40_custom ] ; then
-    mv /ssd/40_custom /ssd/boot/grub/grub.cfg
-    sed -i "/#/d" /ssd/boot/grub/grub.cfg
-    sed -i "/exec tail/d" /ssd/boot/grub/grub.cfg
-    chmod 0444 /ssd/boot/grub/grub.cfg
-else
+# If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst
+if [ ! -f /ssd/boot/grub/grub.cfg ] ; then
     echo "Preparing custom grub menu..."
     echo "default 0" > /ssd/boot/grub/menu.lst
     echo "timeout 30" >> /ssd/boot/grub/menu.lst
diff --git a/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
index ac73ef8..0f80f0e 100644
--- a/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
@@ -3,7 +3,7 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 SRC_URI = "file://init-install.sh"
 
-PR = "r7"
+PR = "r8"
 
 RDEPENDS_${PN} = "grub parted e2fsprogs-mke2fs"
 
-- 
1.8.1.2





More information about the Openembedded-core mailing list