Implemented another level of "early shell". Now we have 2 early shells - one right after the initial mount procedure and another one right after the overlay procedure.

This commit is contained in:
Ivan Davidov 2016-04-23 21:23:28 +03:00
parent a01bc817b4
commit f86add64c6
3 changed files with 50 additions and 11 deletions

View File

@ -159,7 +159,7 @@ for DEVICE in /dev/* ; do
done
# Move critical file systems to the new mountpoint.
echo "Remounting /dev, /sys, /tmp and /proc in /mnt..."
echo "Remounting /dev, /sys, /tmp and /proc in /mnt."
mount --move /dev /mnt/dev
mount --move /sys /mnt/sys
mount --move /proc /mnt/proc
@ -168,6 +168,7 @@ mount --move /tmp /mnt/tmp
# The new mountpoint becomes file system root. All original root folders are
# deleted automatically as part of the command execution. The '/sbin/init'
# process is invoked and it becomes the new PID 1 parent process.
echo "Moving from initramfs root area to overlayfs root area."
exec switch_root /mnt /etc/03_init.sh
echo "(/etc/02_overlay.sh) - there is a serious bug..."

View File

@ -37,13 +37,15 @@
#
# exec /sbin/init
# Print message on screen.
cat << CEOF
Wait 5 seconds for the default system initialization process based on the
files /sbin/init and /etc/inittab or press any key for PID 1 shell.
Wait 5 seconds for the system initialization process or press any key for
PID 1 shell outside of the initramfs area.
CEOF
# Wait 5 second or until any keybord key is pressed.
read -t 5 -n1 -s key
if [ "$key" = "" ] ; then
@ -51,19 +53,22 @@ if [ "$key" = "" ] ; then
echo "Executing /sbin/init as PID 1."
exec /sbin/init
else
# Using no indentation for this snippet or otherwise it causes kernel panic.
cat << CEOF
This is PID 1 shell. Execute the following in order to continue with the
default system initialization process:
# Print message on screen.
cat << CEOF
This is PID 1 shell outside of the initramfs area. Execute the following in
order to continue with the system initialization.
exec /sbin/init
CEOF
if [ "$PID1_SHELL" = "true" ] ; then
# PID1_SHELL flag is set which means we have controlling terminal.
exec sh
else
# Interactive shell with controlling tty as PID 1.
exec setsid cttyhack sh
fi
fi
echo "(/etc/03_init.sh) - there is a serious bug..."

View File

@ -31,6 +31,39 @@ echo "Welcome to \"Minimal Linux Live\" (/init)"
# Let's mount all core file systems.
/etc/01_prepare.sh
# Print message on screen.
cat << CEOF
Wait 5 seconds to continue with overlay initialization process or press any
key for PID 1 shell inside the initramfs area.
CEOF
# Wait 5 second or until any keybord key is pressed.
read -t 5 -n1 -s key
if [ ! "$key" = "" ] ; then
# Print message on screen.
cat << CEOF
This is PID 1 shell inside the initramfs area. Execute the following in order
to continue with the overlay initialization process.
exec /etc/02_overlay.sh
Execute the following in order to skip the overlay initialization and continue
directly with the system initialization:
exec /sbin/init
CEOF
# Set flag which indicates that we have obtained controlling terminal.
export PID1_SHELL=true
# Interactive shell with controlling tty as PID 1.
exec setsid cttyhack sh
fi
# Create new mountpoint in RAM, make it our new root location and overlay it
# with our storage area (if overlay area exists at all). This operation invokes
# the script '/etc/03_init.sh' as the new init process.