commit:     24ad5065fa856389ee9b058f57adffbe752da157
Author:     Christian Nilsson <nikize <AT> gmail <DOT> com>
AuthorDate: Tue Jul 24 23:08:23 2018 +0000
Commit:     Richard Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Wed Jul 25 15:10:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=24ad5065

linuxrc: Add detection of squashfs in initrd root

Allows for the squashfs to be found in the initrd root without mounting CD
This allows iPXE boot by adding the squashfs in a extra cpio initrd

Related: https://bugs.gentoo.org/74628
Related: https://bugs.gentoo.org/494300
Closes: https://bugs.gentoo.org/396467
Signed-off-by: Christian Nilsson <nikize <AT> gmail.com>

 defaults/initrd.defaults |  5 +++++
 defaults/linuxrc         | 21 +++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 924bdea..2bf14f4 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -70,6 +70,11 @@ CDROOT_PATH='/mnt/cdrom'
 CDROOT_MARKER='/livecd'
 VERIFY=0
 
+# Flag for if ok when using CDROOT
+got_good_root='0'
+# if LOOP found on root before mount, trigger Unpacking additional packages
+got_loop_wo_mount='0'
+
 # AUFS variables
 aufs=0
 aufs_union_file=/livecd.aufs

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 81e7799..17697fc 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -431,6 +431,15 @@ then
        startiscsi
 fi
 
+# Loop file already exists on fs, assume no mount needed,
+# This allows for squashfs in initrd, which can be used for (i)PXE booting
+if [ -e "${LOOP}" ]
+then
+       got_good_root=1
+       got_loop_wo_mount=1
+       CDROOT_PATH=$(dirname "${LOOP}")
+fi
+
 # Apply scan delay if specified
 sdelay
 
@@ -497,16 +506,16 @@ then
        if [ 1 = "$aufs" ]; then
                 setup_aufs
                CHROOT=$aufs_union
-        elif [ 1 = "$overlayfs" ]; then
+        elif [ 1 = "$overlayfs" ] && [ "${got_good_root}" != '1' ]; then
                 bootstrapCD
                CHROOT=${NEW_ROOT}
        fi
 
-       if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != 
"$aufs" ] && [ 1 != "$overlayfs" ]; then
+       if [ "${got_good_root}" != '1' ] && [ /dev/nfs != "$REAL_ROOT" ] && [ 
sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ] && [ 1 != "$overlayfs" ]; then
                bootstrapCD
        fi
 
-       if [ "${REAL_ROOT}" = '' ]
+       if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ]
        then
                warn_msg "No bootable medium found. Waiting for new devices..."
                COUNTER=0
@@ -518,7 +527,7 @@ then
                bootstrapCD
        fi
 
-       if [ "${REAL_ROOT}" = '' ]
+       if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ]
        then
                # Undo stuff
                umount  "${NEW_ROOT}/dev" 2>/dev/null
@@ -865,10 +874,10 @@ FSTAB
                 fi
        fi
 
-       # Unpacking additional packages from NFS mount
+       # Unpacking additional packages from NFS mount, or root (if squashfs 
was found there)
        # This is useful for adding kernel modules to /lib
        # We do this now, so that additional packages can add whereever they 
want.
-       if [ "${REAL_ROOT}" = '/dev/nfs' ]
+       if [ "${REAL_ROOT}" = '/dev/nfs' ] || [ "${got_loop_wo_mount}" == '1' ]
        then
                if [ -e "${CDROOT_PATH}/add" ]
                then

Reply via email to