buildroot根文件系统已经在/etc/init.d/中添加了一个自启脚本,如需要添加开机自启,添加一个脚本命令必须为S开头

#!/bin/sh


# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     case "$i" in
        *.sh)
            # Source shell script for speed.
            (
                trap - INT QUIT TSTP
                set start
                . $i
            )
            ;;
        *)
            # No sh extension, so fork subprocess.
            $i start
            ;;
    esac
done

export PATH=$PATH:/config
export TERMINFO=/config/terminfo
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/config/lib:/config/wifi
mkdir -p /dev/pts
mount -t sysfs none /sys
mount -t tmpfs mdev /dev
mount -t debugfs none /sys/kernel/debug/
mdev -s
mkdir -p /var/lock
mount -t ubifs ubi0:miservice /config
 mount -t ubifs ubi0:customer /customer
 mount -t ubifs ubi0:appconfigs /appconfigs

mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
busybox telnetd&
echo 85 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio85/direction
echo 1 > /sys/class/gpio/gpio85/value
echo 86 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio86/direction
echo 1 > /sys/class/gpio/gpio86/value
if [ -e /etc/core.sh ]; then
    echo "|/etc/core.sh %p" > /proc/sys/kernel/core_pattern
chmod 777 /etc/core.sh
fi;
if [ -e /customer/demo.sh ]; then
    /customer/demo.sh
fi;

例如在同一目录下的命名方式

添加完脚本后给脚本设置权限即可

#根据自己命名的实际情况
chmod 777 Sxx

例如:使用nfs开机自动挂载文件系统到/mnt目录下

touch S51nfs
chmod 777 S51nfs

#!/bin/sh
#
#mount nfs
#
mount -t nfs -o nolock 192.168.0.17:/home/industio/ssd20x/nfs/ /mnt
echo "mount ok!"

重新开机之后就会看到自动挂载的到/mnt目录下

文档更新时间: 2022-06-23 16:46   作者:Aeeditor