blob: fbcb481010c269d5841cdb98e14e8217f16d9024 [file] [log] [blame]
#!/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
# Finally, let's start an interactive shell
exec /bin/sh