ArchLinux Systemd 增加rc-local自运行
Archlinux 替换initscript 为systemd方式后 许多服务启动方式已经发生变化 原来的/etc/rc.d/rc.local已经消失 并被建议使用tmpfiles.d方式替换 但是有些操作tmpfiles.d无法替代 所以我们就需要找回我们的rc.local 我…
Archlinux 替换initscript 为systemd方式后
许多服务启动方式已经发生变化
原来的/etc/rc.d/rc.local已经消失
并被建议使用tmpfiles.d方式替换
但是有些操作tmpfiles.d无法替代
所以我们就需要找回我们的rc.local
我们新建一个rc-local.service
nano /usr/lib/systemd/system/rc-local.service
写入以下内容
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
保存之后使用systemctl开机自启动此service
systemctl enable rc-local.service
然后我们再写好rc.local文件
nano /etc/rc.local
里面写入
#!/bin/bash
ip link set eth0 up
dhcpcd eth0
保存 然后将其权限设置为可运行
chmod +x /etc/rc.local
上面的脚本功能为启动网络设备
进行dhcp地址获取
然后就可以reboot看效果啦