diff --git a/bootfiles/syslinux.cfg b/bootfiles/syslinux.cfg index c1bb04e..cf71798 100644 --- a/bootfiles/syslinux.cfg +++ b/bootfiles/syslinux.cfg @@ -9,7 +9,7 @@ MENU BACKGROUND /boot/bootlogo.png LABEL default MENU LABEL Run Linux KERNEL /boot/vmlinuz -APPEND vga=769 initrd=/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 +APPEND vga=769 initrd=/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 debug LABEL default MENU LABEL Run Linux 2 diff --git a/initramfs/init b/initramfs/init index 816829a..2ad7832 100644 --- a/initramfs/init +++ b/initramfs/init @@ -2,15 +2,30 @@ # Initial script for Linux Live Kit # Author: Tomas M -MEMORYDIR=/memory -UNIONDIR=/union -DATADIR=/mnt/data -BUNDLESDIR=/mnt/bundles +# This is needed to enable pivot_root +# We simply switch initramfs to mounted ramfs +if [ ! -r /lib/root_switched ]; then + echo "switch root from initramfs to ramfs" + SWITCH=/m + mkdir -p $SWITCH + mount -t ramfs ramfs $SWITCH + cp -a /* $SWITCH 2>/dev/null + cd $SWITCH + touch $SWITCH/lib/root_switched + exec switch_root -c /dev/console . $0 +fi + +MOUNTDIR=/mnt +CHANGES=$MOUNTDIR/changes +MEMORY=$MOUNTDIR/memory +UNION=$MOUNTDIR/union +DATAMNT=$MOUNTDIR/data +BUNDLES=$MOUNTDIR/bundles export PATH=.:/:/usr/sbin:/usr/bin:/sbin:/bin -. /.config -. /livekitlib +. /lib/.config +. /lib/livekitlib header "Starting $LIVEKITNAME ..." @@ -18,21 +33,22 @@ init_proc init_devs init_aufs init_zram -init_union $MEMORYDIR $UNIONDIR + +init_union "$CHANGES" "$UNION" # find data dir with filesystem bundles -DATA="$(find_data $LIVEKITNAME $DATADIR)" +DATA="$(find_data $DATAMNT)" # copy to RAM if needed # add data to union -union_append_bundles "$DATA" "$BUNDLESDIR" "$UNIONDIR" +union_append_bundles "$DATA" "$BUNDLES" "$UNION" # create empty fstab -fstab_create "$UNIONDIR" +fstab_create "$UNION" header "Live Kit phase ends, starting $LIVEKITNAME" -change_root "$UNIONDIR" +change_root "$UNION" header "!!ERROR!!" /bin/sh diff --git a/initramfs/initramfs_create b/initramfs/initramfs_create index 3d0d460..0b4ba4a 100755 --- a/initramfs/initramfs_create +++ b/initramfs/initramfs_create @@ -48,6 +48,7 @@ busybox/busybox | grep , | grep -v Copyright | tr "," " " | while read LINE; do ln -s ../bin/busybox $INITRAMFS/sbin/$TOOL done done +rm $INITRAMFS/{s,}bin/init mknod $INITRAMFS/dev/console c 5 1 mknod $INITRAMFS/dev/null c 1 3 @@ -75,12 +76,12 @@ touch $INITRAMFS/etc/{m,fs}tab cp init $INITRAMFS/ chmod a+x $INITRAMFS/init -cp ../livekitlib $INITRAMFS/ -cp ../.config $INITRAMFS/ +cp ../livekitlib $INITRAMFS/lib/ +cp ../.config $INITRAMFS/lib/ cd $INITRAMFS find . -print | cpio -o -H newc 2>/dev/null | gzip -f --best >$INITRAMFS.img echo $INITRAMFS.img cd .. -rm -Rf $INITRAMFS +#rm -Rf $INITRAMFS diff --git a/livekitlib b/livekitlib index 5cc85a2..e0028a7 100644 --- a/livekitlib +++ b/livekitlib @@ -153,8 +153,7 @@ init_union() debug_log "init_union" mkdir -p "$1" mkdir -p "$2" - mount -t ramfs ramfs "$1" - mount -t aufs -o xino=$1/xino,br=$1 none "$2" + mount -t aufs -o xino="$1/.xino",br="$1" none "$2" } # Make sure to mount FAT12/16/32 using vfat @@ -249,6 +248,9 @@ change_root() if [ -x sbin/init ]; then INIT=sbin/init; fi if [ "$INIT" = "" ]; then fatal "Can't find executable init command"; fi + mkdir -p mnt/memory mount -n -o remount,ro aufs . + pivot_root . mnt/memory exec $CHROOT . $INIT dev/console 2>&1 +# exec switch_root -c /dev/console . $INIT } \ No newline at end of file