buildroot/board/canaan/k210-soc/rootfs_overlay/sbin/init

42 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# This script replaces the default busybox init process to avoid having that
# process staying alive and sleeping in the background, (uselessly) consuming
# precious memory.
# Mount procfs and sysfs
/bin/mount -t proc proc /proc
/bin/mount -t sysfs sysfs /sys
# When the kernel is directly booted, devtmpfs is not automatically mounted.
# Manually mount it if needed.
devmnt=$(mount | grep -c devtmpfs)
if [ ${devmnt} -eq 0 ]; then
/bin/mount -t devtmpfs devtmpfs /dev
fi
# Use the /dev/console device node from devtmpfs if possible to not
# confuse glibc's ttyname_r().
# This may fail (E.G. booted with console=), and errors from exec will
# terminate the shell, so use a subshell for the test
if (exec 0</dev/console) 2>/dev/null; then
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
fi
# Clear memory to reduce page fragmentation
echo 3 > /proc/sys/vm/drop_caches
# Print a fun logo :)
echo " __ _"
echo " / / (_) ____ _ _ __ __"
echo " / / | || _ \\ | | | |\\ \\/ /"
echo " / /___| || | | || |_| | > < "
echo " /_____/|_||_| |_| \\____|/_/\\_\\"
echo " 64-bits RISC-V Kendryte K210 NOMMU"
echo ""
# Finally, let's start an interactive shell
exec /bin/sh