linux - 如何使脚本在 init 后作为启动脚本在 buildroot 中运行

标签 linux linux-kernel embedded-linux beagleboneblack buildroot

我正在使用 busybox 从 buildroot 构建自定义 initramfs,以用于自动 fdisk 分区。如何/在哪里放置脚本文件,以便 busybox 启动并自动执行它。

最佳答案

How to make a script run in buildroot as a boot script after init

您不能将一个脚本文件用于这两种目的。您需要一个在目标上执行的脚本,以及主机上的一种方法来修改目标的原型(prototype)文件系统。

将脚本和文件安装到 Buildroot 生成的目标文件系统中的典型方法是指定“构建后脚本”。该脚本在根文件系统被 tarubinized 之前执行。

来自 Buildroot user manual4.1 自定义生成的目标文件系统部分:

In the Buildroot configuration, you can specify the path to a post-build script, that gets called after Buildroot builds all the selected software, but before the rootfs packages are assembled. The destination root filesystem folder is given as the first argument to this script, and this script can then be used to copy programs, static data or any other needed file to your target filesystem.

Buildroot board 目录下的开发板子目录(例如 board/beaglebone)是存储 post-build.sh 文件以及用于复制的原始文件。

post-build.sh 文件的示例是 here 。使用 echo 命令逐行创建目标的两个脚本文件。只需复制二进制文件即可。

另请参阅 this presentation 的第 24-25 页.

关于linux - 如何使脚本在 init 后作为启动脚本在 buildroot 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31303041/

相关文章:

java - 虚拟内存每秒增加 - 内存不足错误

linux - 如何唤醒内核中的用户态 sleep 进程?

linux-kernel - 用于 ARM 的 Linux 中的矢量页面映射

linux - linux内核如何知道在系统调用中作为参数传递的地址无效?

linux - 错误 : [scripts/Makefile. modinst :33: arch/x86/crypto/aegis128-aesni. ko]

c++ - 不正确的浮点行为

c - 获取 malloc 合并错误的示例示例程序

linux wget 安全认证

linux - Linux 上 Qt6 的 Bazel 规则 : How to copy required libs?

c - 绑定(bind)到设备的原始套接字未接收所有数据包