2011年2月18日 星期五

加快開機速度

這邊記錄如何加快開機速度

有兩種方式:
1. 將用不到的功能從核心中移除
2. 將用不到的服務從設定檔中移除

1的話請參考如何優化Linux Kernel
這邊只討論2的狀況

~$ runlevel 可以查目前環境的runlevel
N 2
所以runlvel = 2
那Linux載入時會去參考 /etc/rc2.d裡的設定

~$ ls /etc/rc2.d
README S20atftpd S20fancontrol ... S79sendmail... 略

我根本用不到mail啊...每次開機到 "Mail Transport Agent (MTA) Sendmail starting" 就會停在這一下,拖慢我的開機速度

看一下S79sendmail實際長啥樣
~$ ls -l /etc/rc2.d/S79sendmail
lrwxrwxrwx 1 root root 18 2011-02-18 18:50 S79sendmail -> ../init.d/sendmail

所以他實際上是/etc/init.d/sendmail

看一下rc.d的Readme
~$ cat /etc/rc2.d/README
To disable a service in this runlevel, rename its script in this
directory so that the new name begins with a 'K' and a two-digit
number, and run 'update-rc.d script defaults' to reorder the scripts according to dependencies.


man一下update-rc.d就知道如何開關服務
~$ sudo update-rc.d sendmail disable

這樣就不會在開機時開啟 sendmail這個script了

有空再解譯/etc/init.d/sendmail在做啥