Arch linux作業系統設定開機啟動配置

來源:互聯網
上載者:User


順便說一下Centos 7 中rc.local其實依然是可以使用的,無法使用的原因是由於/etc/rc.d/rc.local中沒有X許可權,增加一個執行許可權即可。

既然centos中的可以使用,哪麼arch linux中其實也是可以使用的。直接copycentos中的資料即可。

[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

測試:

[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導致的!!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.