From 2789c57616056b936e33603e297e8320f83b97c0 Mon Sep 17 00:00:00 2001 From: Christian Nilsson Date: Wed, 25 Jul 2018 01:08:23 +0200 Subject: [PATCH] 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 --- 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 -- 2.16.4