slitaz-arm rev 211
piboot: load clean initramfs
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 27 19:04:14 2016 +0200 (2016-03-27) |
parents | 5be8b2141f10 |
children | 3b857a987d2b |
files | rpi/piboot |
line diff
1.1 --- a/rpi/piboot Sun Mar 27 12:20:30 2016 +0200 1.2 +++ b/rpi/piboot Sun Mar 27 19:04:14 2016 +0200 1.3 @@ -301,10 +301,14 @@ 1.4 cp /tmp/menu.txt $mnt/menu.txt 1.5 fi 1.6 1.7 + [ "$INITRD" ] && ! kexec -u 2> /dev/null && mount -t tmpfs tmpfs /media 1.8 + 1.9 for i in ${INITRD//,/ }; do 1.10 + echo "Loading $(basename $i)" 1.11 web_get $KEYWORD/$i /rootfs 1.12 if ! kexec -u; then 1.13 - ( zcat /rootfs || unlzma < /rootfs ) | cpio -idmu 1.14 + ( zcat /rootfs || unlzma < /rootfs ) | \ 1.15 + ( cd /media ; cpio -idmu ) 1.16 rm -f /rootfs 1.17 else 1.18 n=$(stat -c %s /rootfs) 1.19 @@ -315,6 +319,7 @@ 1.20 done 1.21 1.22 if ! kexec -u 2> /dev/null; then 1.23 + umount $mnt 1.24 ROOTDIR=$(cmdvararg "subroot") 1.25 TMPDIR=$ROOTDIR/dev/shm 1.26 TMPDIR=${TMPDIR#/} 1.27 @@ -326,18 +331,34 @@ 1.28 [ "$L" ] && echo -e "LANG=$L\nLC_ALL=$L" > /etc/locale.conf 1.29 TZ=$(cmdvararg "tz") 1.30 [ "$TZ" ] && echo $TZ > /etc/TZ 1.31 - umount $mnt 1.32 - if [ "$ROOTDEV" ] && mount $ROOTDEV $mnt && 1.33 - mount -t tmpfs tmpfs $mnt/$TMPDIR ; then 1.34 + RDINIT=$(cmdvararg "rdinit") 1.35 + INIT=$(cmdvararg "init") 1.36 + INIT=${INIT:-/sbin/init} 1.37 + if [ -z "$ROOTDEV" ] || ! mount $ROOTDEV $mnt; then 1.38 + INIT=${RDINIT:-/init} 1.39 + mnt=/media 1.40 + for i in $(seq 2 5); do 1.41 + mount -r /dev/mmcblk0p$i /tmp || continue 1.42 + echo "Get modules from /dev/mmcblk0p$i" 1.43 + cp -a /tmp/lib/modules /tmp/lib/firmware \ 1.44 + $mnt/$ROOTDIR/lib 1.45 + umount /tmp 1.46 + break 1.47 + done 1.48 + fi 1.49 + KEXEC="exec /sbin/switch_root $mnt $INIT" 1.50 + if [ "$ROOTDIR" ] && mount -t tmpfs tmpfs $mnt/$TMPDIR ; then 1.51 CHROOT=/usr/sbin/chroot 1.52 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $CHROOT \ 1.53 | sed 's|.*=> \(/lib/l[^ ]*\).*|\1|;/^\//!d') \ 1.54 $CHROOT $mnt/$TMPDIR 1.55 CHROOT="$(cd $mnt ; ls $TMPDIR/ld-*so) $TMPDIR/chroot" 1.56 export LD_LIBRARY_PATH=/$TMPDIR:/lib 1.57 - KEXEC="exec /sbin/switch_root $mnt $CHROOT $ROOTDIR/ /sbin/init" 1.58 + KEXEC="exec /sbin/switch_root $mnt $CHROOT $ROOTDIR/ $INIT" 1.59 fi 1.60 + stat $mnt/$ROOTDIR/$INIT > /dev/null || KEXEC="echo 'No $ROOTDIR/$INIT'" 1.61 else 1.62 + echo "Loading $(basename $KERNEL)" 1.63 web_get $KEYWORD/$KERNEL /vmlinuz 1.64 umount $mnt 1.65 kexec -l /vmlinuz ${INITRD+=--initrd /rootfs} --command-line \