[2/2] init-install-efi.sh: fix to handle the boot partition correctly

Submitted by Drew Moseley on July 2, 2014, 10:09 p.m.


Message ID 1404338969-30935-2-git-send-email-drew_moseley@mentor.com
State Accepted
Commit 3b1bae7ad8d36930aae840175c6a3433c1469772
Headers show

Commit Message

Drew Moseley July 2, 2014, 10:09 p.m.
(This patch was originally done against init-install.sh in
OE-Core rev aa67b1333b4774e1845f562085f7048df65a644f)

Previously, the boot partition was created for the target hard drive
but there was no corresponding entry for it in /etc/fstab. Besides,
even if the boot partition was mounted, it would just result in odd
directory hierarchy like /boot/boot/grub. However, what we really need
is /boot/grub. This patch fixes this problem.

Besides, for future maintance work, this patch also renames some of the
intermediate directories. It uses more descriptive names like /tgt_root
and /src_root. The name of /ssd is dropped.

Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
 .../initrdscripts/files/init-install-efi.sh        | 47 ++++++++++++----------
 1 file changed, 25 insertions(+), 22 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index da3e33c..fcf21cd 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -144,34 +144,32 @@  mkfs.ext3 $rootfs
 echo "Formatting swap partition...($swap)"
 mkswap $swap
-mkdir /ssd
-mkdir /rootmnt
-mkdir /bootmnt
-mount $rootfs /ssd
-mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /rootmnt
+mkdir /tgt_root
+mkdir /src_root
+mkdir -p /boot
+# Handling of the target root partition
+mount $rootfs /tgt_root
+mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
 echo "Copying rootfs files..."
-cp -a /rootmnt/* /ssd
-if [ -d /ssd/etc/ ] ; then
-    echo "$swap                swap             swap       defaults              0  0" >> /ssd/etc/fstab
+cp -a /src_root/* /tgt_root
+if [ -d /tgt_root/etc/ ] ; then
+    echo "$swap                swap             swap       defaults              0  0" >> /tgt_root/etc/fstab
+    echo "$bootfs              /boot            vfat       defaults              1  2" >> /tgt_root/etc/fstab
     # We dont want udev to mount our root device while we're booting...
-    if [ -d /ssd/etc/udev/ ] ; then
-        echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist
+    if [ -d /tgt_root/etc/udev/ ] ; then
+	echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
-umount /ssd
-umount /rootmnt
+umount /src_root
+# Handling of the target boot partition
+mount $bootfs /boot
 echo "Preparing boot partition..."
-mount $bootfs /ssd
 mkdir -p $EFIDIR
-cp /run/media/$1/vmlinuz /ssd
 # Copy the efi loader
 cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
@@ -192,11 +190,11 @@  if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
 if [ -d /run/media/$1/loader ]; then
-    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    GUMMIBOOT_CFGS="/tgt_root/loader/entries/*.conf"
     # copy config files for gummiboot
-    cp -dr /run/media/$1/loader /ssd
+    cp -dr /run/media/$1/loader /tgt_root
     # delete the install entry
-    rm -f /ssd/loader/entries/install.conf
+    rm -f /tgt_root/loader/entries/install.conf
     # delete the initrd lines
     sed -i "/initrd /d" $GUMMIBOOT_CFGS
     # delete any LABEL= strings
@@ -207,7 +205,12 @@  if [ -d /run/media/$1/loader ]; then
     sed -i "s@options *@options root=$rootfs rw $rootwait quiet @" $GUMMIBOOT_CFGS
-umount /ssd
+umount /tgt_root
+cp /run/media/$1/vmlinuz /boot
+umount /boot
 echo "Remove your installation media, and press ENTER"