!BMC external buildroot tree. For building minimal Raptorcs Blackbird/Talos II bmc images.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 lines
2.0 KiB

#!/bin/sh
echo "init: prepping filesystem for busybox init"
# This will hide the overlay internals once
# the rootfs has been switched
mount -t tmpfs scratch /mnt
mkdir -p \
/mnt/overlay \
/mnt/root \
/mnt/dev-data \
/mnt/rwfs
lowerdirs="/mnt/root"
mount --bind / /mnt/root
mount -t devtmpfs dev /dev
mount -t proc proc /proc
for entry in $(cat /proc/cmdline) ; do
# we only care about bangBMC arguments
# cut needs us to ensure there is delimiter otherwise it will throw
# an error.
[ "$(echo ${entry}. | cut -f 1 -d '.')" = "bangBMC" ] || continue
cmd="$(echo ${entry}= | cut -f 1 -d '=' |cut -f 2 -d '.')"
arg="$(echo ${entry}= | sed -e 's/^[^=]\+=//' )"
case $cmd in
#skip-rwfs is a legacy option, it will be removed soon.
skip-rwfs)
skip_rwfs=true
;;
do-jffs-mount)
do_jffs_mount=true
;;
*)
continue
;;
esac
done
if mount -t squashfs /dev/mtdblock1 /mnt/dev-data ; then
have_layers=true
lowerdirs="/mnt/dev-data:${lowerdirs}"
fi
# if the cmdline asked us to skip the persistent storage, then don't mount it
if [ -z "${skip_rwfs}" ] && [ -n "${do_jffs_mount}" ] && mount -t jffs2 /dev/mtdblock5 /mnt/rwfs ; then
have_layers=true
mkdir -p /mnt/rwfs/root /mnt/rwfs/work
upperdir_cmd=',upperdir=/mnt/rwfs/root,workdir=/mnt/rwfs/work'
# if the rwfs isn't available, then mount a portion of the initrd rootfs
# as the upper layer so that the overlay doesn't make things read-only.
elif [ -n "${have_layers}" ] ; then
mkdir -p /tmp/ov/root /tmp/ov/work
upperdir_cmd=',upperdir=/tmp/ov/root,workdir=/tmp/ov/work'
fi
if [ -n "${have_layers}" ] ; then
mount -t overlay -olowerdir=${lowerdirs}${upperdir_cmd} fs_layers /mnt/overlay && \
dest_root=/mnt/overlay/
fi
umount /dev /proc
export TERM=xterm
if [ -n "${dest_root}" ] ; then
cd ${dest_root}
mount --move . /
fi
exec chroot . busybox init