定制ubuntu启动时加载的服务(原名:加速Ubuntu开机过程)(转

在解决把ubuntu启动到文本模式的过程中搜到这篇帖子,觉得有收藏价值,特转帖于此。

原文http://www.ubuntuforums.org/showthread.php?t=89491

加速Ubuntu开机过程

此HowTo的建议:

1. 我希望你能从中学到东西而不是仅仅简单的拷贝。 因此请, **不要 ** 完全地按照我所作的并复制到你的计算机。阅读服务的描述并自己判断去决定是否需要保留他们。 例如,在我的电脑上我关闭GDM用终端引导,但是如果你看到终端感到一点都不舒服,你应该保留GDM或KDM直接引导到用户图形界面。

2.如果你对开机服务有疑问并且确实对该服务是什么不是很确定, 在此张贴问题并且看看是否有人能帮助你。 在你行动之前如果你不知道。保持系统安全的底线是让一种服务开着而不是关闭它,如果你不理解的该服务的话。

3. 如果你在你机器上见过一个开机服务但不在这里,告知我们它是什么?正如我在这里做的一样 –给一些说明和建议关于是否它应该在一台正常的笔记本或者桌面环境上开或关。

颜色参考: 我开启的服务

我关闭的服务

I. 安装一个工具 - sysv-rc-conf。 它是一款基于perl的开机进程调整工具。

代码:

sudo apt-get update

sudo apt-get install sysv-rc-conf

它提供一种配置开机进程和运行等级的简单方法, 但是如果你想要通过链接/解除链接文件来手工操作的话,这不是必需的... 这由你决定

II. Ok,一切就绪。现在让我们通过以下代码来运行它

代码:

sudo sysv-rc-conf

并一个一个的分析每种服务。 **注意 ** 我有的一些服务或许你没有,完全可以。如果一些服务你有但是我没有, 你将需要独自研究或者在这里提问 ... 但是此HowTo 涵盖它们中的大多数 ...

在我们开始搞乱它们之前,我要在这里引入一些运行等级知识 ....全部开机进程执行顺序如下:

运行等级 S:开机进程中的第一个运行等级。/etc/init.d/rcS脚本将被调用到开启并且/etc/rcS.d目录下的所有进程将被执行。

运行等级 1:单用户模式。/etc/rc1.d目录下的所有进程将被执行。

运行等级 2,3,4,5:在debian系统里是多用户环境,可能不包含图形用户界面。同样的,在相应目录下的进程将被运行。

**注意** 这和RedHat,SuSE, 以及其它基于RPM的系统不同。

运行等级 0:关闭计算机

运行等级 6:重起计算机

好,让我们回到sysv-rc-conf:

1. acpi-support - 你最好使其在S运行等级处于“X”状态。

2. acpid - acpi守护程序.这两个用于电源管理,对于笔记本和台式电脑很重要,所以让它们开启。

3. alsa - 如果你使用alsa声音子系统,是的,开启它。

4. alsa-utils -在我系统里,此服务取代了alsa,所以我关闭了alsa并在S运行等级将此服务开启。**注意**,我所说的“关闭”是指在所有运行等级里面去除所有“X”。如果在你系统里没有它,没问题。让我们继续。

5. anacron - 一个cron子系统,当时间到达时用于执行任何没有被执行的cron作业。当某种cron 作业时间准备好时,很可能你或许已经关闭了你的计算机。打个比方,updatedb被计划在每天2点执行,但是在那个时候,你的计算机是关闭的,然后如果 ananron服务如果是开启的话,它将设法抓起那个updatedb cron… 我将它关闭是因为我不经常关闭我的笔记本,但是否开启此服务完全取决于你。

6. apmd - 这是十分困惑我的一个服务。我已经开启了acpid服务,那同时开启apmd有啥好处呢?如果你的计算机不是那么老,甚至不能支持acpi,然后你可以设法关闭它。无论如何,我是关闭它的。

7. atd - 就像cron,一个作业调度程序。我把它关了

8. binfmt-support - 核心支持其他二进制的文件格式。我让它开着

9. bluez-utiles - 我把它关了因为我没有任何蓝牙设备

10. bootlogd - 开启它

11. cron – 开启它

12. cupsys – 管理打印机的子系统。我没有打印机所以我关闭它了,如果你有打印机,开启他。

13. dbus – 消息总线系统(message bus system)。非常重要,开启它。

14. dns-clean – 当使用拨号连接,主要用于清除dns信息。我不用拨号,所以我关闭了它。

15. evms – 企业卷管理系统(Enterprise Volumn Management system). 我关闭了它。

16. fetchmail – 一个邮件接受守护进程,我关闭了它。

17. gdm – gnome桌面管理器。 无论如何我关闭它了,因为我将系统用终端引导。如果你想直接引导到图形用户界面,这取决于你。

18. gdomap – 事实上我也不知道为什么此服务必需开启。我没有在其他系统见过这个守护程序,所以我将其关闭并且我没觉得我失去了什么。开启它对笔记本或者台式机有任何好处吗?

19. gpm – 终端鼠标支持。如果你觉得你在终端使用鼠标更好,那么在运行等级 1 和2 开启它。那正是你所需要的。

20. halt - 别更改它。

21. hdparm – 调整硬盘的脚本。我在运行等级 2,3,4,5去除了它但是在S 运行等级添加了它。我觉得早点打开DMA,32bit I/O等等将对其余过程有益。我自己也将原来的脚本精简了一下。如果我知道我正做什么,我觉得做过多的检查没用。相应配置文件是 /etc/hdparm.conf。

22. hibernate – 如果你的系统支持休眠,把它打开,否则它对你没用。

23. hotkey-setup – 此守护进程为你的笔记本建立一些热键映射。支持的制造商包括: HP, Acer, ASUS, Sony, Dell, 和IBM。如果你有那些品牌的笔记本,你可以打开它,否则它或许对你没有任何好处。

24. hotplug and hotplug-net #激活热插拔系统是费时的。我将考虑关掉它们。我在的/etc/network/interfaces文件作了很多修改,并将其设置为自动运行,而不是在热插拔进程期间映射我的无线网卡。所以我可以将它们关掉。我已经测试过了,甚至我将它们关闭,ubuntu仍旧可以检测到我的usb驱动器,我的数码相机,等等。所以我认为关掉它们是很安全的**注意**如果在关闭热插拔服务以后发现你的声卡部工作了,你可以将服务打开,或者编辑 /etc/modules文件并添加声卡驱动模块。经测试,后者比较快。

25. hplip – HP打印机和图形子系统,我将其关闭了。

26. ifrename – 网络接口重命名(network interface rename)脚本。听上去很酷但是我把它关掉了。主要用于管理多网络接口名称。虽然我有无线网卡和以太网卡,两者被内核标识为eth0和ath0,所以此服务对我不是很有用。

27. ifupdown and ifupdown-clean – 打开它,它们是开机时网络及口激活脚本。

28. inetd or inetd.real – 查看文件/etc/inetd.conf 注释掉所有你不需要的服务。如果该文件不包含任何服务,那关闭它是很安全的。

29. klogd – 打开它。

30. linux-restricted-modules-common – 你应该去查看下是否你的系统装载有任何受限制的模块。既然我需要madwifi ath_pci 模块,所以我将其开启。受限制的模块可以从/lib/linux-restricted-modules查看到。如果你发现你没有使用任何受限制的模块,那关掉这个服务没事。

31. lvm – 我没有使用逻辑卷所以我将此服务关闭。让它开启如果你 *确实* 有lvm(lvm是逻辑卷管理器在此不再扩充).

32. makedev – 打开它。

33. mdamd – Raid管理工具。不使用Raid所以我将此服务关闭。

34. module-init-tools – 从/etc/modules加载扩展模块。你可以研究/etc/modules文件查看是否有一些你不需要的模块。通常我们将此服务开启。

35. networking – 在启动期间通过扫描/etc/network/interfaces文件增加网络接口和配置dns信息。让它开着。

36. ntpdate – 通过ubuntu时间服务器同步时间 。在开机的时候我不需要它,故我关掉了此服务。

37. nvidia-kernel – 我自己编译了nvidia驱动,所以此服务对我没用。如果你从受限制模块中使用nvidia驱动,那打开此服务。

38. pcmcia – 激活pcmica设备。我将此服务打开在S运行等级而不是分别在2,3,4,5运行等级打开此服务,因为我觉得起先让硬件设备准备更好。如果你在使用没有pcmica卡的台式机的话,请关闭此服务。

39. portmap – 管理像nis,nfs等等之类服务的守护程序。如果你的笔记本或台式机是纯粹的客户端,那么关闭此服务。

40. powernowd – 管理CPU频率的客户端程序。主要用于支持CPU speed stepping技术的笔记本。通常如果你在配置一台笔记本,你应该开启此服务。如果是台式机,那此服务应该没有用。

41. ppp and ppp-dns - 对我没用,我不使用拨号。

42. readahead - **感谢 mr_pouit!** readahead似乎是一种“预加载程序”。在开机时它将一些库文件加载到内存,以便一些程序启动的更快。但是它给启动时间增加了3-4秒。所以,你可以留着它…或者不。**更新**,经我测试我觉得加载程序没有什么不同。所以我决定关闭此服务。如果你有打开此服务的理由,那就打开它 。

43. reboot - 别更改它。

44. resolvconf – 按照你的网络状态自动配置DSN信息,我将它打开着。

45. rmnologin – 如果发现nologin,那么去除它。此情况不会在笔记本上面发生,所以我摆脱它。

46. rsync – rsync守护程序. 我不打算在我的笔记本上使用rsync协议,所以我将其关闭

47. sendsigs – 在重启和关机期间发送信号。顺其自然。

48. single – 激活单用户模式。顺其自然。

49. ssh – ssh守护程序。 我需要ssh,所以我将此服务打开。

50. stop-bootlogd – 从2,3,4,5运行等级停止bootlogd。顺其自然。

51. sudo – 检查sudo 状态。我没在一台笔记本或者台式机客户端上看到任何使用sudo的好处,因此我关闭了它。

52. sysklogd - 顺其自然。

53. udev and udev-mab – 用户空间dev文件系统(userspace dev filesystem)。好东西,我将它们打开。

54. umountfs - 顺其自然。

55. urandom – 随机数生成器。可能没什么用处,但是我留着它。

56. usplash - 嗯,如果你想看到漂亮的开机画面,顺其自然。 无论如何沃关闭此服务了。如果你想关闭它,你也可以编辑/boot/grub/menu.lst文件注释掉splashimage行,除去开机splash核心选项。

57. vbesave – 显卡BIOS配置工具。它能保存你显卡的状态。我将其开启。

58. xorg-common – 设置X服务ICE socket。我将其从在S运行等级开启移动到2,3,4,5,运行等级。如果我引导到单用户模式,那我不需要此服务。在最初引导期间这种方法将不占用时间。

59. adjtimex – 这也是调整核心hw时钟的工具。通常你不会在开机列表中看见它。在非常少有的情况如果你确实在开机进程中看见它了,事出有因,因此最好顺其自然。在我的情况里,它是关闭的。

60. dirmngr – 证书列表管理工具(certification lists management tool)。和gnupg一起工作。你必须看看你是否需要它。在我的情况里,我是关掉它的。

61. hwtools – 一个优化irqs的工具。不确定打开它的好处。在我的情况里,我是关掉它的。

62. libpam-devperm - 在系统崩溃之后用于修理设备文件许可的一个守护程序。听起来不错,因此我打开它了。

63. lm-sensors – 如果你的主板内建一些传感芯片,通过用户空间(userspace)查看hw状态可能是有帮助的。我运行了它,但是它提示“没有发现传感器”,因此我关闭了此服务。64. mdadm-raid – 作用和mdadm服务相同。用来管RAID设备。如果你没有此类设备,那尽管关掉它好了。

65. screen-cleanup – 一个用来清除开机屏幕的脚本。嗯,是否关闭它有你决定。在我的情况里,我打开它了。

66. xinetd – 用来管理其他守护进程的一个inetd超级守护程序。在我的系统里,xinetd管理chargen, daytime, echo和time (在 /etc/xinetd.d 目录找到的),我不关系任何一个,因此我关掉了此服务。如果在xinetd下你确实有一些重要的服务,那打开它。

III.修改 /etc/inittab 文件

代码:

vi /etc/inittab

然后注释掉tty4,tty5, 和tty6。只留下tty1, tty2,和 tty3.。对于笔记本或台式机用户3个终端应该足够了。保存文件。

IV. Ok,好,我们可以重启计算机并看看它变的如何了。从我测试来看:在我停止大量服务之前,引导到终端整个过程大约花费了85到90秒。 (在那时,我也打开了我不需要的samba和nfs服务。 我也将它们关闭了)。之后,整个过程花费了50秒。我有一台 P4M 1.8G CPU的笔记本。一些高档台式机或者笔记本应该花费更少时间。

**更新**: 加速/打扫系统重启或关机进程

1. 通过以下代码运行sysv-rc-conf:

代码:

sudo sysv-rc-conf

2. OK,睁开你的眼睛并仔细寻找那些在所有运行等级都没有“X”的服务。(所有运行等级包括 1,2,3,4,5,6, 和S), 一个一个的把它们写下来。在这里千万别出错。再你搞定以后再来一遍。

3. 退出sysv-rc-conf。

4.

代码:

cd /etc/rc0.d

- 此目录关于系统关机进程。

5. OK, 现在开始

代码:

ls K*

将列出所有以大写K开头的链接。比较你的列表,将你列表中每个包含服务名的文件名改为小写k开头。例如,在你列表中你有一个ppp服务(意思是说ppp将在所有运行等级关闭),然后你可以这样做:

代码:

sudo mv K00ppp k00ppp

你只要将大写K改成小写k就好了,保留其余的。将此举应用到你列表中存在的所有服务 。

6.

代码:

cd ../rc6.d

- 此目录关于系统重启进程。

7. ok,你应该也看到了相似的东西了吧,因此在此做和rc0.d中同样的修改。

8. 现在,你的重启和关机进程被清理了,你的重启和关机过程将变的更快。

关于什么是你要做的已经相当明了了。在每个运行等级/etc/rc和/etc/rcS脚本通过扫描每个链接是否以大写S开头来决定开启与否,通过扫描每个链接是否它是以大写K开头来决定停止与否。因此对于重启和关机运行等级,我们更关心的是大写K开头的链接,因为那写服务不运行在所有运行等级,不必停止他们。它们更本没有运行。如果有一天你想重新开启其中的一些服务, 只要将小写的k改为大写的K即可。就这些了。

无论如何,它不适用服务器,但是我确实在我的一台拥有2.7G P4 ,1.5G内存的服务器上测试过。它将整个启动过程缩短为31秒。我用我的手表计算的。而且,其中还包括了开启的ftp服务器和nft服务器。

原文http://www.ubuntuforums.org/showthread.php?t=89491

technorati tags ubuntu Tags: ubuntu

2 thoughts on “定制ubuntu启动时加载的服务(原名:加速Ubuntu开机过程)(转”

  1. 用上面的命令sudo apt-get install sysv-rc-conf 来安装sysv-rc-conf,报告好像已经从软件库中移除了。所以暂时没有安装它。今天,在网上搜索到下面这个叫BUM的工具,是指定在Ubuntu系统下的(上面的那个sysv-rc-conf是在Debian下的),应该不会被移除吧。

    安装BUM的方法如下:


    Dapper has BUM in repositories, so it is enough to type:

    sudo apt-get install bum

    ...and all the dependencies come in!

    The context below come from: http://www.ubuntuforums.org/showthread.php?t=82783&page=9

    Go Back     Ubuntu Forums > Support & Resources  > 3rd Party Ubuntu Projects  > BUM - Boot Up Manager

    Reload this Page BUM v.2.x

    User Name Remember Me?

    Password

    Forum Home Gallery Guidelines Register Today's Posts Search

    BUM - Boot Up Manager BUM is a Perl-Gtk2 application to handle runlevels configuration of an Ubuntu system. With this program the user will easily start and stop boot-up scripts, without the necessity to handle thru complex links and permissions.

    Search Forums

    Show Threads   Show Posts

    Advanced Search

    Get Unanswered Posts

    Get All New Posts

    Last 15 Minutes

    Last 30 Minutes

    Last Hour

    2 Hours

    4 Hours

    8 Hours

    12 Hours

    1 Day

    2 Days

    3 Days

    4 Days

    Find All Your Threads

    Find All Your Posts

    Go to Page...

    ReplyReply

    Page 9 of 11 « First < 7 8 9 10 11 >

     

    Thread Tools Search this Thread Display Modes

      #81 

    Old February 22nd, 2006

    saltydog saltydog is offline

    Ubuntu House Blend

     

    Join Date: Jan 2005

    Location: Rome - Italy

    Beans: 196

    Default Re: BUM v.2.x

    Quote:

    Originally Posted by Zxaos

    Well that was fun. Tried to install libgtk2-gladexml-perl, and got a big nasty error message about how I was crazy and it didn't exist. Moral of the story - always make sure that your apt repositories are up to date - it appears that my connection was down last time they updated, and as such they were missing half the packages!

    I am not sure I have understood what you are speaking about...

    Maybe you are referring to a very old bug? Pls note that latest BUM version is 2.1.5 and you can download it from debian repositories..

    libgtk2-gladexml-perl is a normal package in Ubuntu/debian repositories...

    __________________

    My Ubuntu Wiki Page

    Reply With Quote

    saltydog

    View Public Profile

    Send a private message to saltydog

    Find all posts by saltydog

      #82 

    Old February 28th, 2006

    earobinson's Avatar

    earobinson earobinson is offline

    Fresh Brewed Ubuntu

     

    Join Date: Jan 2005

    Location: Ontario, Canada

    Beans: 1,540

    Dapper Drake Testing/ User

    Send a message via ICQ to earobinson Send a message via MSN to earobinson

    Default Re: BUM v.2.x

    Im a fan of da bum

    __________________

    Ubuntu Member - Ubuntu Code of Conduct - Think Ubuntu is great, get involved, anyone can do it!

    [Ubuntu Forums Search] [Ubuntu FAQ] [Ubuntu Wiki Search] [Ubuntu Documents] [My Blog] [Contact Me]

    Reply With Quote

    earobinson

    View Public Profile

    Send a private message to earobinson

    Visit earobinson's homepage!

    Find all posts by earobinson

      #83 

    Old March 17th, 2006

    jaja23bd jaja23bd is offline

    5 Cups of Ubuntu

     

    Join Date: Dec 2005

    Location: Sydney

    Beans: 58

    Ubuntu 6.06 User

    Send a message via Yahoo to jaja23bd

    Default Re: BUM v.2.x

    hi

    thanks mate..

    I just installed bum in dapper. Though i need to install some library by synaptic ... then everything is alright..

    when i run the package its says the following word

    Package libgtk2-gladexml-perl is not installed.

    i search the lib and got it in synaptic ... and then run again

    sudo dpkg -i bum_2.1.5-1_all.deb

    .........................

    Thanks again...

    jaja

    Reply With Quote

    jaja23bd

    View Public Profile

    Send a private message to jaja23bd

    Find all posts by jaja23bd

      #84 

    Old March 17th, 2006

    saltydog saltydog is offline

    Ubuntu House Blend

     

    Join Date: Jan 2005

    Location: Rome - Italy

    Beans: 196

    Default Re: BUM v.2.x

    Quote:

    Originally Posted by jaja23bd

    hi

    thanks mate..

    I just installed bum in dapper. Though i need to install some library by synaptic ... then everything is alright..

    when i run the package its says the following word

    Package libgtk2-gladexml-perl is not installed.

    i search the lib and got it in synaptic ... and then run again

    sudo dpkg -i bum_2.1.5-1_all.deb

    .........................

    Thanks again...

    jaja

    Why are you installing BUM in dapper with dpkg??

    Dapper has BUM in repositories, so it is enough to type:

    sudo apt-get install bum

    ...and all the dependencies come in!

    Thanks

    Fabio

    __________________

    My Ubuntu Wiki Page

    Reply With Quote

    saltydog

    View Public Profile

    Send a private message to saltydog

    Find all posts by saltydog

      #85 

    Old March 17th, 2006

    jaja23bd jaja23bd is offline

    5 Cups of Ubuntu

     

    Join Date: Dec 2005

    Location: Sydney

    Beans: 58

    Ubuntu 6.06 User

    Send a message via Yahoo to jaja23bd

    Default Re: BUM v.2.x

    Quote:

    Originally Posted by saltydog

    Why are you installing BUM in dapper with dpkg??

    Dapper has BUM in repositories, so it is enough to type:

    sudo apt-get install bum

    ...and all the dependencies come in!

    Thanks

    Fabio

    Yup, my mistake... few hours back i run the apt-get.. its update the BUM..

    thank you..

    Reply With Quote

    jaja23bd

    View Public Profile

    Send a private message to jaja23bd

    Find all posts by jaja23bd

      #86 

    Old March 24th, 2006

    frodon's Avatar

    frodon frodon is offline

    Ubuntu Master Roaster

     

    Join Date: Jun 2005

    Location: Nantes(Fr)

    Beans: 2,182

    Ubuntu 6.06 User

    Default Re: BUM v.2.x

    Hi saltydog,

    just a quick question :

    - Is it possible to use BUM to make a script running on boot ?, for example i wrote an iptables firewall script and i'm wondering if i can use BUM to make this script running on each startup.

    __________________

    Need some good ubuntu HowTo's ?

    Visit the Ubuntu Document Storage Facility

    http://doc.gwos.org/index.php/

    Get your UDSF search engine plugin for firefox here

    Reply With Quote

    frodon

    View Public Profile

    Send a private message to frodon

    Find all posts by frodon

      #87 

    Old March 29th, 2006

    Ubuntuud's Avatar

    Ubuntuud Ubuntuud is offline

    Dipped in Ubuntu

     

    Join Date: Jan 2006

    Location: Netherlands

    Beans: 568

    Dapper Drake Testing/ User

    Default Re: BUM v.2.x

    It looks like sysv-rc-conf (the options), is there any difference between BUM and sysv-rc-conf, except for the GUI part?

    __________________

    Huh?

    Reply With Quote

    Ubuntuud

    View Public Profile

    Send a private message to Ubuntuud

    Find all posts by Ubuntuud

      #88 

    Old March 29th, 2006

    saltydog saltydog is offline

    Ubuntu House Blend

     

    Join Date: Jan 2005

    Location: Rome - Italy

    Beans: 196

    Default Re: BUM v.2.x

    Quote:

    Originally Posted by Ubuntuud

    It looks like sysv-rc-conf (the options), is there any difference between BUM and sysv-rc-conf, except for the GUI part?

    No. Both of them are recommended by sysv-rc.

    __________________

    My Ubuntu Wiki Page

    Reply With Quote

    saltydog

    View Public Profile

    Send a private message to saltydog

    Find all posts by saltydog

      #89 

    Old April 2nd, 2006

    RaptorRaider RaptorRaider is offline

    A Carafe of Ubuntu

     

    Join Date: Dec 2005

    Beans: 146

    Dapper Drake Testing/ User

    Default Re: BUM v.2.x

    Wouldn't it be a good idea to add a GUI front-end to /boot/grub/menu.lst in BUM?

    I know BUM currently doesn't have much to do with that file, but booting in general does; I think making a GUI for such a file wouldn't be that hard but would improve usability significantly for new users.

    Reply With Quote

    RaptorRaider

    View Public Profile

    Send a private message to RaptorRaider

    Find all posts by RaptorRaider

      #90 

    Old April 4th, 2006

    klahjn's Avatar

    klahjn klahjn is offline

    Way Too Much Ubuntu

     

    Join Date: Mar 2006

    Location: Kankakee, IL

    Beans: 288

    Send a message via AIM to klahjn Send a message via MSN to klahjn Send a message via Yahoo to klahjn

    Default Re: BUM v.2.x

    BUM looks pretty good, any information if it is ready for dapper?

    __________________

    Linux Registered User #: 411584

    ZDC Technologies - Providing computer maintenance and repair to the chicagoland area

    "My tech told me to give windows the three finger salute, but what are the other two fingers?" - Anonymous

    Reply With Quote

Comments are closed.