This package contains a Linux init script suitable for resource-limited systems which can be used as an alternative to the one provided by Busybox. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Cc: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> [yann.morin.1998@free.fr: drop 'imply busybox'] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
33 lines
971 B
Bash
33 lines
971 B
Bash
#!/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
|