New image framework generation

The CD now boots directly from the ISO 9660 filesystem instead of using
MBR partitioning with Minix file systems. This saves some space on the
CD and reduces memory requirements by some unknown amount as the root
ramdisk is completely eliminated.

The x86 hard drive image creation is also rewritten in the same
fashion.

The setup is modified to be more NetBSD-like (unpacking sets
tarballs instead of blindly copying the CD contents). Splitting MINIX
into sets is done in another commit due to it being a nightmare to
rebase.

Since MINIX lacks union mounts for now, a bunch of ramdisks are
generated at run-time to make parts of the filesystem writeable for the
CD. This solution isn't ideal, but it's enough for an installation CD.

Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd
This commit is contained in:
Jean-Baptiste Boric
2015-09-14 21:46:48 +02:00
committed by Lionel Sambuc
parent b5400f9ff4
commit 69eead77ff
20 changed files with 762 additions and 371 deletions

49
etc/rc
View File

@@ -1,5 +1,8 @@
# /etc/rc - System startup script run by init before going multiuser.
# Are we booting from CD?
bootcd="`/bin/sysenv bootcd`"
exec >/dev/log
exec 2>/dev/log
exec </dev/null
@@ -64,7 +67,7 @@ edit()
if [ ! -x $binlocation ]
then binlocation=/sbin/$service
fi
service $opt edit $binlocation -label $service "$@"
service $opt edit $binlocation -label $service "$@"
}
while getopts 'saf' opt
@@ -87,6 +90,11 @@ esac
case $action in
autoboot|start)
# If booting from CD, we want some directories to be ramdisks
if [ ! -z "$bootcd" ]
then
. /etc/rc.cd
fi
# National keyboard?
test -f /etc/keymap && loadkeys /etc/keymap
@@ -106,7 +114,8 @@ autoboot|start)
# Set timezone.
export TZ=GMT0
if [ -f "$RC_TZ" ]
then . "$RC_TZ"
then
. "$RC_TZ"
fi
# Start real time clock driver & set system time, otherwise default date.
@@ -114,11 +123,10 @@ autoboot|start)
readclock -q || date 201301010000
# We are not shutting down.
rm -f /etc/nologin
# Initialize files.
>/var/run/utmp # /etc/utmp keeps track of logins
>/var/run/utmpx # /etc/utmpx keeps track of logins
if [ -f /etc/nologin ]
then
rm -f /etc/nologin
fi
# Use MFS binary only from kernel image?
if [ "`sysenv bin_img`" = 1 ]
@@ -126,25 +134,18 @@ autoboot|start)
bin_img="-i "
fi
# Are we booting from CD?
bootcd="`/bin/sysenv bootcd`"
# If booting from CD, mounting is a special case.
# We know what to do - only /usr is mounted and it's readonly.
if [ "$bootcd" = 1 ]
then usrdev="$cddev"p2
echo "/usr on cd is $usrdev"
mount -r $usrdev /usr
else
# If we're not booting from CD, fsck + mount using /etc/fstab.
fsck -x / $fflag $fsckopts
mount -a
fi
# fsck + mount using /etc/fstab.
fsck -x / $fflag $fsckopts
mount -a
# Unmount and free now defunct ramdisk
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
# Initialize files.
>/var/run/utmp # /etc/utmp keeps track of logins
>/var/run/utmpx # /etc/utmpx keeps track of logins
# Edit settings for boot system services
if [ "`sysenv skip_boot_config`" != 1 ]
then
@@ -197,18 +198,18 @@ down|stop)
if [ -f /var/run/devmand.pid ]
then
kill -INT `cat /var/run/devmand.pid`
# without this delay the following will
# without this delay the following will
# be printed in the console
# RS: devman not running?
sleep 1
fi
#
# usbd needs to be stopped exactly
# usbd needs to be stopped exactly
# at this stage(before stopping devman
# and after stopping the services
# stated by devmand)
if [ -x /usr/pkg/etc/rc.d/usbd ]
then
then
/usr/pkg/etc/rc.d/usbd stop
fi

View File

@@ -2,3 +2,30 @@
# CD boottime initializations.
echo -n "Creating ramdisks:"
# Set up a ramdisk to make a read-only part of the directory tree writable
# $1 : ramdisk dev node to use
# $2 : path to make writeable
# $3 : ramdisk size in blocks
create_ramdisk()
{
echo -n " $2"
ramdisk $3 /dev/$1 > /dev/null
mkfs.mfs /dev/$1 > /dev/null
# copy files
mount /dev/$1 /mnt > /dev/null
(cd $2 && pax -rw . /mnt)
umount /mnt > /dev/null
mount /dev/$1 $2 > /dev/null
}
# Create /var ramdisk
create_ramdisk ram0 /var 256
create_ramdisk ram1 /tmp 128
create_ramdisk ram2 /usr/run 64
create_ramdisk ram3 /root 512
echo

View File

@@ -3,7 +3,7 @@
# daily - daily cleanup of the system.
# Doesn't make sense when running from CD
if [ -f /CD ]
if [ ! -z $(sysenv bootcd) ]
then exit
fi
@@ -50,8 +50,8 @@ cycle()
fi
}
cycle 100 wtmp
cycle 100 log
cycle 100 wtmp
cycle 100 log
cycle 20 ftplog
cycle 200 aftplog

View File

@@ -178,6 +178,11 @@ start|autoboot)
cat < $RANDOM_FILE >/dev/random
# overwrite $RANDOM_FILE. We don't want to use this data again
dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
else
# We couldn't find the old state to restart from, so use a binary
# file and the current date instead, even if this is less than ideal.
cat /bin/sh >> /dev/urandom
date >> /dev/urandom
fi
# start network driver instances for all configured ethernet devices