initscripts/rc.conf (简体中文)
/etc/rc.conf是initscripts的配置文件。配置哪些守护进程在系统启动时开始运行,基本网络守护进程,和检测某些硬件。
Contents |
概览
下面是最新Arch系统的默认rc.conf文件(当前版本):
/etc/rc.conf
# # /etc/rc.conf - configuration file for initscripts # # Most of rc.conf has been replaced by various other configuration # files. See archlinux(7) for details. # # For more details on rc.conf see rc.conf(5). # DAEMONS=() # A reasonable DAEMONS array when using sysvinit is: # DAEMONS=(syslog-ng network crond) # # When using systemd, it is recommended to only enable daemons that # do not have native systemd service files. # Storage # # USEDMRAID="no" # USELVM="no" # Network # # interface= # address= # netmask= # gateway=
新配置文件
以前此文件也负责其它部分的配置,现在,它主要负责非systemd系统的开启进程配置和网络配置。
| Configuration | Configuration file(s) | Legacy rc.conf section |
|---|---|---|
| Hostname | /etc/hostname
|
NETWORKING
|
| Console fonts and keymap | /etc/vconsole.conf
|
LOCALIZATION
|
| Locale | /etc/locale.conf
|
LOCALIZATION
|
| Timezone | /etc/localtime
|
LOCALIZATION
|
| Hardware clock | /etc/adjtime
|
LOCALIZATION
|
| Kernel modules | /etc/modules-load.d/
|
HARDWARE
|
| Daemons | /etc/rc.conf
|
DAEMONS
|
| Wired network | /etc/rc.conf
|
NETWORKING
|
如果配置文件都还不存在,并且你想修改默认设置,那么你可以很容易的手动生成。
服务
DAEMONS: 此处设置 /etc/rc.d/ 中需要开机执行的脚本,以一个空格分割。默认不设置也能启动系统,但安装了系统服务如 sshd 后,需要修改此设以使其开机启动。其它发行版一般用到 init.d 目录的链接实现。更多信息请阅读: 编写rc.d服务脚本
- 如果在服务名称前加上半角感叹号
!,则显式禁用该服务。 - 如果在服务名称前加上
@符号,则开机时后台启动改服务,亦即:不必等待该服务启动完毕,便执行其他操作。
示例: DAEMONS=(@syslog-ng !network net-profiles crond sshd)
硬件
- MODULES
- 除自动加载的模块外,还需要在启动时装入的模块。要屏蔽模块,请阅读 Kernel modules#Blacklisting.
接口配置
/etc/rc.conf 仅支持单一接口方式。要多接口设置或高级网络配置请使用 netcfg。
- interface
- 设备名 (不能为空)
- address
- IP 地址 (使用 DHCP 设为空)
- netmask
- 子网掩码 (可选,默认为 255.255.255.0,DHCP 可忽略)
- broadcast
- 广播地址,使用 DHCP 可忽略 (可选)
- gateway
- 默认路由 (DHCP 忽略此选项)
Static IP Example
interface=eth0 address=192.168.0.2 netmask=255.255.255.0 broadcast=192.168.0.255 gateway=192.168.0.1
DHCP example
interface=eth0 address= netmask= gateway=
配置好后将 network 加入 DAEMONS:
DAEMONS=(... network sshd)
如果使用 netcfg,请加入 net-profiles :
DAEMONS=(... !network net-profiles sshd)
本地化
- HARDWARECLOCK
- 设置在开关机同步时间时硬件保存的是
UTC时间还是localtime。详情参见 Time。-
UTC是推荐选项,因为它简化了时区和夏令时计算。不管进入夏令时 Linux 是否在运行,Linux 都会进行正确的夏令时转化。 -
localtime是和仅使用localtime的操作系统如 Windows 时应该使用的选项。Linux 不会进行夏令时调整。如果另外的系统没有调整夏令时,夏令时时间就会不正确。 - 空置: 系统会读取
/var/lib/hwclock/adjtime中的设置,默认是 UTC。如果其它用户会修改 adjtime,请使用这个设置。 - 设置为其它值将不会修改硬件时间(使用 virtualization 时比较有用)
-
- TIMEZONE
- 指定时区。可从
/usr/share/zoneinfo文件夹查看所有可用时区。比如德国所在的时区是Europe/Berlin,相应目录是/usr/share/zoneinfo/Europe/Berlin。对于中国用户,使用Asia/Shanghai或者Asia/Chongqing即可,都指的是一个时区。如果留空,则不进行时区设置,可以通过修改/etc/localtime重置设置。 - KEYMAP
- 指定键盘布局,一般键盘布局都是us(即通常的QWERT键盘)。可用的键盘布局在
/usr/share/kbd/keymaps下可以找到。请注意,该设置只对TTY(控制台)有效,图形界面(Xorg)下有自己的一套设置。 - CONSOLEFONT
- 设置启动时通过
setfont加载的控制台字体。可用字体在/usr/share/kbd/consolefonts文件夹下。/etc/vconsole.conf中的FONT优先级更高。详情参见:控制台字体。 - CONSOLEMAP
- 设置启动时通过
setfont加载的控制台布局(console map),例如 8859-1_to_uni。可用布局在/usr/share/kbd/consoletrans文件夹下。如果上面设置了utf8的locale,并且程序输出8位宽的字符,可以在此处设置为其他想要的布局(如Latin1使用的8859-1)。/etc/vconsole.conf中的FONT_MAP优先级更高。 - LOCALE
- 设置系统的语言,i18n 友好的程序将使用此选项。运行
locale -a可以获得所有可用值。默认是为美国英语用户准备。/etc/locale.conf中的LANG优先级更高。无法导入/etc/rc.conf的用户应该在那里设置此值。 - DAEMON_LOCALE
- 如果设置成 yes,将使用
$LOCALE作为守护进程启动时的 locale。如果设置成 no,将使用C。默认是 yes。 - USECOLOR
- 是否启用彩色信息输出。
网络
The HOSTNAME variable is deprecated, and the hostname is now set in /etc/hostname (see man 5 hostname).
Network Persist
NETWORK_PERSIST 变量可以设置系统在关机时是否停止网络。根设备在 NFS 上时需要此设置。默认是 "no"。
# 默认 NETWORK_PERSIST="no" # Root 文件系统位于 NFS # NETWORK_PERSIST="yes"
GUI Frontends
This is a list of /etc/rc.conf GUI front-ends, designed to provide a graphical interface to the /etc/rc.conf file. The list includes GTK2-based software and Qt based software.
ArchLinux Daemon Manager GUI
ArchLinux Daemon Manager allows you to easily change settings in /etc/rc.conf using GTK application aldm-gui or command-line application aldm.
- Homepage: https://github.com/Harvie/ArchLinux-Daemon-Manager
- AUR Package Details: aldm
- Screenshots: http://img130.imageshack.us/img130/4200/aldmgui03.png
rcconf-settings
rcconf-settings is a tool designed for the Chakra GNU/Linux distribution but should also work on Arch Linux.
- Homepage: http://gitorious.org/chakra/rcconf-settings
- AUR Package Details: kcm-rcconf-settings
- Screenshots: http://s2.subirimagenes.com/imagen/5986587instantnea1.png