From 2feb5ea3250b37d6a86ad6ec887045037e89159d 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/linuxrc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/defaults/linuxrc b/defaults/linuxrc index 81e7799..d8f1516 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 @@ -868,7 +877,7 @@ FSTAB # Unpacking additional packages from NFS mount # 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