mount -t tmpfs tmpfs /newroot
mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo
[ ! -e /newroot/dev/.devfsd ] && mount -t devfs devfs /newroot/dev
- devfsd /newroot/dev
+ devfsd /newroot/dev -np
sleep 1
findcdmount /newroot/dev/cdroms/*
exec /bin/ash
# Undo stuff
- kill_devfsd
+ # kill_devfsd # We run devfsd with -np now
sleep 1
umount /newroot/dev/
sleep 1
if [ "${CDROOT}" -eq "0" -a "${USE_DEVFS_NORMAL}" -eq "1" ]
then
[ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev
- devfsd /dev
+ devfsd /dev -np
fi
echo "STEP 4: Determining root device"
elif [ "${LOOP}" = "/zisofs" ]
then
LOOPTYPE="zisofs"
+ elif [ "${LOOP}" = "/livecd.squashfs" ]
+ then
+ LOOPTYPE="squashfs"
+ elif [ "${LOOP}" = "/livecd.gcloop" ]
+ then
+ LOOPTYPE="gcloop"
else
LOOPTYPE="noloop"
fi
fi
FS_LOCATION="mnt/livecd"
umount /dev
+ elif [ "${LOOPTYPE}" = "squashfs" ]
+ then
+ check_loop
+ mount -o bind /newroot/dev /dev
+ echo "STEP 5a1: mounting squashfs filesystem"
+ mount -t squashfs -o loop,ro /newroot/mnt/cdrom/${LOOP} /newroot/mnt/livecd
+ if [ "$?" != "0" ]
+ then
+ echo "FAILED TO MOUNT LOOP FILESYSTEM, barfing out to shell"
+ /bin/ash
+ fi
+ FS_LOCATION="mnt/livecd"
+ umount /dev
+ elif [ "${LOOPTYPE}" = "gcloop" ]
+ then
+ check_loop
+ mount -o bind /newroot/dev /dev
+ echo "STEP 5a1: mounting gcloop (ext2) filesystem"
+ echo " " | losetup -e ucl-0 /newroot/dev/loop0 /newroot/mnt/cdrom/${LOOP}
+ if [ "$?" != "0" ]
+ then
+ echo "FAILED TO losetup THE LOOP DEVICE"
+ /bin/ash
+ fi
+ mount -t ext2 -o ro /newroot/dev/loop0 /newroot/mnt/livecd
+ FS_LOCATION="mnt/livecd"
+ umount /dev
elif [ "${LOOPTYPE}" = "zisofs" ]
then
check_loop
mkdir initrd proc tmp sys
chmod 1777 tmp
(cd /newroot/${FS_LOCATION}; cp -a ${ROOT_TREES} /newroot)
-
- # Unmount the -o bind /dev and kill devfsd
-# umount /dev
- kill_devfsd
else
echo "STEP 5b: setting up stuff for pivot_root"
mkdir -p /newroot/tmp/.initrd
fi
+echo "STEP 5c: redirect console"
+console=/newroot/dev/console
+exec < $console > $console 2>&1 || echo "CONSOLE REDIRECTION FAILED, /dev ON ROOT DOES NOT CONTAIN console !!!"
+
echo "STEP 6: pivot_root and exec/chroot real init"
cd /newroot
pivot_root . tmp/.initrd
-# We cannot use if [ this = that ] after a pivot_root as
-# an old version of coreutils in real_root does not support
-# that style, noted by Weeve
-# Well, changed it back to using [ ] for 3.0.1_beta10 too many
-# people reporting with newer binutils that using 'test' does
-# not work for some reason
-
if [ "${USE_DEVFS_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ]
then
# must mount a new devfs before we can
# umount the old one for some reason
mount -t proc proc /proc
mount -t devfs devfs /dev
- kill_devfsd
- umount /tmp/.initrd/proc
- umount /tmp/.initrd/dev
+ umount /tmp/.initrd/proc || echo "COULD NOT UMOUNT tmp/.initrd/proc !!!"
+ umount /tmp/.initrd/dev || echo "COULD NOT UMOUNT tmp/.initrd/dev !!!"
# Uhh, initrd is wasting memory ... let's
# kill the sucker here and now!
# also umount proc
echo "STEP 6a: clean up mounts"
sleep 1
- umount /tmp/.initrd/dev > /dev/null 2>&1
+ umount /tmp/.initrd/dev || echo "COULD NOT UMOUNT tmp/.initrd/dev !!!"
sleep 1
- umount /tmp/.initrd/proc > /dev/null 2>&1
+ umount /tmp/.initrd/proc || echo "COULD NOT UMOUNT tmp/.initrd/proc !!!"
sleep 1
fi
-# why chroot ?? /usr/src/linux/Documentation/initrd.txt
-# says to, but I see no reason to do this .... very odd...
+# /usr/src/linux/Documentation/initrd.txt
# here's the line it says we should do:
# exec chroot . /sbin/init </dev/console >/dev/console 2>&1
-# not gonna though ....
-exec chroot . /sbin/init ${CMDLINE} < /dev/console > /dev/console 2>&1
+exec chroot . /bin/sh <<- EOF
+ echo "UMOUNTING /tmp/.initrd"
+ umount /tmp/.initrd || echo "UMOUNT of /tmp/.initrd FAILED!!!" && /sbin/blockdev --flushbufs /dev/ram0
+ echo "INIT: starting /sbin/init ${CMDLINE}"
+ exec /sbin/init ${CMDLINE}
+EOF
+
+# exec chroot . /sbin/init ${CMDLINE} < /dev/console > /dev/console 2>&1
+echo "IF YOU ARE SEEING THIS MESSAGE, A FATAL ERROR HAS OCCURRED"
+echo "MOST LIKELY /sbin/init DOES NOT EXIST, ATTEMPTING TO DROP"
+echo "YOU TO A SHELL"
+
+exec /bin/bash
+exec /bin/sh
+exec /bin/ash
+exec sh