# HG changeset patch # User Pascal Bellard # Date 1327401041 -3600 # Node ID 9650e8bd017e5b43a4db42d8fb9e933790b19cca # Parent 6208c17a9e42c4556ab91156cc8f0e4348b7904f log from any boot console diff -r 6208c17a9e42 -r 9650e8bd017e etc/init.d/rcS --- a/etc/init.d/rcS Tue Jun 14 21:13:21 2011 +0200 +++ b/etc/init.d/rcS Tue Jan 24 11:30:41 2012 +0100 @@ -10,9 +10,11 @@ # Set TZ and boot time. [ -s /etc/TZ ] && export TZ="$(cat /etc/TZ)" -bootdate=`date +%s` +[ -n "$bootdate" ] || bootdate=`date +%s` -if [ "$1" != "logged" ]; then # logged +case "$1" in + +readonly) # Graphical boot start. if [ "$FBSPLASH" == "yes" ]; then @@ -32,26 +34,6 @@ [ "$FBSPLASH" == "yes" ] && echo "10" > /etc/fbsplash/fifo -# Parse cmdline args for earlier boot options. All other boot options -# are in /etc/init./bootopts.sh. -echo -n "Searching for early boot options..." -for opt in `cat /proc/cmdline` -do - case $opt in - fastbootx|fbx) - export FAST_BOOT_X="yes" ;; - cdrom=*) - export CDROM=${opt#cdrom=} ;; - modprobe=*) - export MODPROBE="yes" ;; - config=*) - export CONFIG=${opt#config=} ;; - *) - continue ;; - esac -done -status - [ "$FBSPLASH" == "yes" ] && echo "20" > /etc/fbsplash/fifo # Before mounting filesystems we check fs specified in the file @@ -68,6 +50,9 @@ # Remount rootfs rw. echo "Remounting rootfs read/write..." /bin/mount -o remount,rw / +;; + +readwrite) # Trigger Udev and handle hotplug events if [ "$UDEV" = "yes" ]; then @@ -89,10 +74,29 @@ # Store boot messages to log files. /bin/dmesg > /var/log/dmesg.log & -conspy -d | sed 's/ *$//;/^$/d;/^Processi\|^.witchi/,$!d' > /var/log/boot.log -script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log +;; -else # logged +logged) + +# Parse cmdline args for earlier boot options. All other boot options +# are in /etc/init./bootopts.sh. +echo -n "Searching for early boot options..." +for opt in `cat /proc/cmdline` +do + case $opt in + fastbootx|fbx) + export FAST_BOOT_X="yes" ;; + cdrom=*) + export CDROM=${opt#cdrom=} ;; + modprobe=*) + export MODPROBE="yes" ;; + config=*) + export CONFIG=${opt#config=} ;; + *) + continue ;; + esac +done +status # Clean up the system. if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then @@ -280,5 +284,19 @@ echo $time > /var/log/boot-time echo "SliTaz boot time: ${time}s" [ "$FBSPLASH" == "yes" ] && echo "exit" > /etc/fbsplash/fifo +;; -fi # logged +*) +if [ ! -s /dev/shm/boot.log ]; then + mount -t devpts devpts /dev/pts + mount -t tmpfs tmpfs /dev/shm +fi +script -aqc '/etc/init.d/rcS readonly' /dev/shm/boot.log +mv -f /dev/shm/boot.log /boot.log +umount /dev/shm +script -aqc '/etc/init.d/rcS readwrite' /boot.log +mv -f /boot.log /var/log/boot.log +script -aqc '/etc/init.d/rcS logged' /var/log/boot.log +;; + +esac diff -r 6208c17a9e42 -r 9650e8bd017e init --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/init Tue Jan 24 11:30:41 2012 +0100 @@ -0,0 +1,180 @@ +#!/bin/sh + +launch_init() +{ + [ -d /proc/sys ] && umount /proc + echo -e "\\033[70G[ \\033[1;32mOK\\033[0;39m ]" + cat > /dev/shm/init < /dev/null; then + cryptsetup luksOpen $root $dmlabel + else + read -s -t 60 -p "Pass phrase : " passphrase + key=$(echo $passphrase | hashalot -x -n 32 sha512) + blocks=$(cat $(find /sys/block | grep /$dev/size)) + echo 0 $blocks crypt aes-plain $key 0 $root 0 | \ + dmsetup create $dmlabel + fi + mount /dev/mapper/$dmlabel /mnt + fi + if [ -d /mnt/etc ]; then + umount /sys + [ -n "$1" ] && for i in $@ ; do + cp -a $i /mnt$(dirname $i) + done + mount /mnt -o remount,ro + launch_init + fi + failed +} + +mount_mapper() +{ + mount $root /mnt + try_init /dev/mapper $@ +} + +lvmsetup() +{ + grep -q lvmroot= /proc/cmdline || return 1 + modprobe dm-mod + vgscan --ignorelockingfailure + vgchange -ay --ignorelockingfailure + root="/dev/mapper/$(sed 's/.*lvmroot=\([^ ]*\).*/\1/' < /proc/cmdline)" + return 0 +} + +load_raid() +{ +while read line; do + case "$line" in + *raid10*) modprobe raid10 ;; + *raid0*) modprobe raid0 ;; + *raid1*) modprobe raid1 ;; + *raid[456]*) modprobe raid456 ;; + esac +done +} + +if [ "$1" != "logged" ]; then + mount -t devpts devpts /dev/pts + mount -t tmpfs tmpfs /dev/shm + script -qc '/init logged' /dev/shm/boot.log + . /dev/shm/init +else +mount -t proc proc /proc +mount -t sysfs sysfs /sys +echo -n "Switching / to " +if grep -q dmraid= /proc/cmdline; then + root="$(sed 's/.*dmraid=\([^ ]*\).*/\1/' < /proc/cmdline)" + echo -n "dmraid $root..." + dmraid -s | grep ^type | awk '{ print $3 }' | load_raid + case "$root" in + /dev/*);; + *) root=/dev/mapper/$(dmraid -s|grep ^name|awk '{print $3}')p${root#p};; + esac + dmraid -ay + lvmsetup + mount_mapper +fi +if grep -q softraid= /proc/cmdline; then + root="$(sed 's/.*softraid=\([^ ]*\).*/\1/' < /proc/cmdline)" + echo -n "softraid $root..." + mdadm --examine --scan --config=partitions > /etc/mdadm.conf + grep -qs " $root " /etc/mdadm.conf || + root=$(awk '/dev.md/ { print $2; exit }' < /etc/mdadm.conf) + grep level=raid /etc/mdadm.conf | load_raid + for i in 1 2 3 4 5 6 7 8 9; do + sleep $i + mdadm --assemble --scan + grep -qs ': active' /proc/mdstat && break + done + lvmsetup + mount_mapper /etc/mdadm.conf +fi +if lvmsetup; then + echo -n "lvm $root..." + mount_mapper +fi +if grep -q mount= /proc/cmdline; then + root="$(sed 's/.*mount=\([^ ]*\).*/\1/' < /proc/cmdline)" + dev=$(blkid | grep $root | sed 's/:.*//;q') + echo -n "Mounting $dev ($root) ..." + if ! mount $dev /mnt; then + if echo $dev | grep -q "/dev/sd"; then + delay=`cat /sys/module/usb_storage/parameters/delay_use` + delay=$((1+$delay)) + echo -n "sleep for $delay seconds..." + sleep $delay + fi + mount $dev /mnt + fi + grep -q posixovl /proc/cmdline && mount.posixovl /mnt +fi +if grep -q loopfs= /proc/cmdline; then + loopfs="$(sed 's/.*loopfs=\([^ ]*\).*/\1/' < /proc/cmdline)" + echo -n "loop $loopfs..." + losetup /dev/loop0 /mnt/$loopfs + mount /dev/loop0 /mnt 2> /dev/null +fi +if grep -q bindfs= /proc/cmdline; then + bind="$(sed 's/.*bindfs=\([^ ]*\).*/\1/' < /proc/cmdline)" + mount --bind /mnt/${bind%,*} /mnt/${bind%,*}/${bind#*,} +fi +grep -q cryptoroot= /proc/cmdline && try_init +umount /sys +if grep -q subroot= /proc/cmdline; then + subroot="/$(sed 's/.*subroot=\([^ ]*\).*/\1/' < /proc/cmdline)" && + if [ -s /usr/share/boot/busybox-static ]; then + mv /usr/share/boot/busybox-static . + /busybox-static rm -rf /etc /lib /*bin /usr /var + echo "exec /busybox-static chroot /mnt$subroot /sbin/init" > /dev/shm/init + else + echo "exec chroot /mnt$subroot /sbin/init" > /dev/shm/init + fi +fi +echo -n "tmpfs..." +size="$(grep rootfssize= < /proc/cmdline | \ + sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')" +free=$(busybox free | busybox awk '/Mem:/ { print int(($4*100)/$3) }') +umount /proc +[ -n "$size" ] || size="-o size=90%" +echo "exec /sbin/init" > /dev/shm/init +if [ $free -lt 100 ] || ! mount -t tmpfs $size tmpfs /mnt; then + echo -e "\\033[70G[ \\033[1;33mSkipped\\033[0;39m]" + exit +fi +for i in $(ls -a /); do + case "$i" in + .|..) ;; + mnt) mkdir /mnt/mnt;; + *) if ! cp -a /$i /mnt 2> /dev/null; then + failed + umount /mnt + exit + fi;; + esac +done +launch_init +fi