找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 7957|回复: 7

[N1盒子] 开启armbian系统的开机启动脚本rc.local

[复制链接]
发表于 2018-11-6 13:44 | 显示全部楼层 |阅读模式
本帖最后由 hayes 于 2018-11-6 15:45 编辑

N1安装armbian系统,开机启动脚本rc.local 默认是不启动,不管在里面添加了什么脚本都是不管用的,需要按如下方法开启

方法:
命令vi修改,也可以winscp修改
  1. vi /lib/systemd/system/rc.local.service
复制代码


在最后添加下面三行内容
  1. [Install]  
  2. WantedBy=multi-user.target  
  3. Alias=rc-local.service
复制代码


然后就可以在/etc/rc.local 中添加需要的开机启动脚本,脚本要写在exit 0的前面 。

----------------------------------------------------------------------------------------------------------------
以下是找的原理


armbian(我使用5.62  5.64版本) 使用的是systemd管理系统,不是使用initd管理系统,systemd 默认读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件

执行 ls /lib/systemd/system 你可以看到有很多启动脚本,其中就有我们需要的 rc.local.service

打开脚本内容:
  1. #  This file is part of systemd.
  2. #
  3. #  systemd is free software; you can redistribute it and/or modify it
  4. #  under the terms of the GNU Lesser General Public License as published by
  5. #  the Free Software Foundation; either version 2.1 of the License, or
  6. #  (at your option) any later version.

  7. # This unit gets pulled automatically into multi-user.target by
  8. # systemd-rc-local-generator if /etc/rc.local is executable.
  9. [Unit]
  10. Description=/etc/rc.local Compatibility
  11. ConditionFileIsExecutable=/etc/rc.local
  12. After=network.target

  13. [Service]
  14. Type=forking
  15. ExecStart=/etc/rc.local start
  16. TimeoutSec=0
  17. RemainAfterExit=yes
复制代码


一般正常的启动文件主要分成三部分
[Unit] 段: 启动顺序与依赖关系
[Service] 段: 启动行为,如何启动,启动类型
[Install] 段: 定义如何安装这个配置文件,即怎样做到开机启动

可以看出,/etc/rc.local 的启动顺序是在网络后面,但是显然它少了 Install 段,也就没有定义如何做到开机启动,所以显然这样配置是无效的。 因此我们就需要在后面帮他加上 [Install] 段:
[Install]  WantedBy=multi-user.target  Alias=rc-local.service


我的恩山、我的无线 The best wifi forum is right here.
发表于 2018-11-6 13:49 | 显示全部楼层
学习学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2018-11-6 14:09 | 显示全部楼层
版本问题?我的默认就可以啊

点评

可能吧,我试过5.62 5.64  详情 回复 发表于 2018-11-6 14:26
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2018-11-6 14:26 | 显示全部楼层
心理有数 发表于 2018-11-6 14:09
版本问题?我的默认就可以啊

可能吧,我试过5.62  5.64
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2018-11-6 14:29 | 显示全部楼层
这是什么原理啊?学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-3-31 21:12 | 显示全部楼层
不行啊 按照教程做了 开机还是不能自动执行脚本
版本:Welcome to ARMBIAN 5.77 user-built Debian GNU/Linux 9 (stretch) 5.0.2-aml-s905
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-6 12:29 | 显示全部楼层
我的 Linux 5.9.0-arm-64,按照这样操作,还是开机启动不了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-6 12:29 | 显示全部楼层
我的 Linux 5.9.0-arm-64,按照这样操作,还是开机启动不了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-19 01:42

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表