上篇文章介绍了Arch操作系统的网络配置,包括动态DHCP以及静态IP获取的配置方法:http://note.t4x.org/basic/arch-linux-network/,此次介绍一下开机启动的问题。
顺便说一下Centos 7 中rc.local其实依然是可以使用的,无法使用的原因是由于/etc/rc.d/rc.local中没有X权限,增加一个执行权限即可。
既然centos中的可以使用,哪么arch linux中其实也是可以使用的。直接copycentos中的资料即可。
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
[root@Arch ~]# egrep -v "#" /usr/lib/systemd/system/rc-local.service [Unit] Description=/etc/rc.local Compatibility ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target [root@Arch ~]# touch /etc/rc.local [root@Arch ~]# chmod +x /etc/rc.local [root@Arch ~]# systemctl enable rc-local.service Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /usr/lib/systemd/system/rc-local.service. [root@Arch ~]# cat /etc/rc.local ulimit -HSn 30961 && echo 'right' >>/tmp/right.txt || echo 'wrong' >>/tmp/wrong.txt printf $(ulimit -n) >>/tmp/ulimit1.txt 2>&1 ulimit -HSn 3096 printf $(ulimit -n) >>/tmp/ulimit.txt 2>&1 |
测试:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
[root@Arch ~]# ls -al /usr/lib/systemd/system/rc-local.service -rw-r--r-- 1 root root 675 Apr 5 23:24 //usr/lib/systemd/system/rc-local.service [root@Arch ~]# chmod +x /usr/lib/systemd/system/rc-local.service [root@Arch ~]# ls -al /usr/lib/systemd/system/rc-local.service -rwxr-xr-x 1 root root 675 Apr 5 23:24 //usr/lib/systemd/system/rc-local.service [root@Arch ~]# systemctl start rc-local.service Job for rc-local.service failed. See "systemctl status rc-local.service" and "journalctl -xe" for details. [root@Arch ~]# systemctl status rc-local.service ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2015-04-05 23:30:27 UTC; 9s ago Process: 246 ExecStart=/etc/rc.local start (code=exited, status=203/EXEC) Apr 05 23:30:27 Arch systemd[1]: rc-local.service: control process exited, code=exited status=203 Apr 05 23:30:27 Arch systemd[1]: Failed to start /etc/rc.local Compatibility. Apr 05 23:30:27 Arch systemd[1]: Unit rc-local.service entered failed state. Apr 05 23:30:27 Arch systemd[1]: rc-local.service failed. [root@Arch ~]# ls -al /usr/lib/systemd/system/sshd.service #排除权限原因 -rw-r--r-- 1 root root 410 Mar 20 04:52 /usr/lib/systemd/system/sshd.service [root@Arch ~]# journalctl -xe Apr 05 23:29:34 Arch systemd[1]: Configuration file /usr/lib/systemd/system/rc-local.service is marked executable. Please remove exec Apr 05 23:29:38 Arch systemd[1]: rc-local.service: control process exited, code=exited status=203 -- Subject: Unit rc-local.service has failed -- Unit rc-local.service has failed. Apr 05 23:29:38 Arch systemd[1]: Unit rc-local.service entered failed state. Apr 05 23:29:38 Arch systemd[1]: rc-local.service failed. [root@Arch ~]# systemctl start rc-local.service Warning: Unit file of rc-local.service changed on disk, 'systemctl daemon-reload' recommended. Job for rc-local.service failed. See "systemctl status rc-local.service" and "journalctl -xe" for details. [root@Arch ~]# systemctl | grep rc-loca rc-local.service loaded active exited /etc/rc.local Compatibility [root@Arch ~]# cat /etc/rc.local #!/bin/sh [root@Arch ~]# egrep -v "#" /etc/systemd/system/multi-user.target.wants/rc-local.service [Unit] Description=/etc/rc.local Compatibility ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target |
rc.loca在Arch中无法启动的原因是由于我在rc.loca中没有设置#!/bin/sh导致的!!!SourceByrd's Weblog-https://note.t4x.org/basic/arch-linux-rc-local/
THE ENDSourceByrd's Weblog-https://note.t4x.org/basic/arch-linux-rc-local/ SourceByrd's Weblog-https://note.t4x.org/basic/arch-linux-rc-local/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!