initscripts/rc.conf (简体中文)

From ArchWiki
Jump to: navigation, search

翻译状态: 本文是英文页面 Rc.conf翻译,最后翻译时间:2012-06-19,点击这里可以查看翻译后英文页面的改动。

/etc/rc.confinitscripts的配置文件。配置哪些守护进程在系统启动时开始运行,基本网络守护进程,和检测某些硬件。

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系统的开启进程配置和网络配置。

注意: /etc/rc.conf中老的配置文件依然可以使用,但是新的配置文件优先级更高,是推荐的配置方式。而且新配置文件也可以在 systemd 系统中工作。参阅Systemd#Native_configuration
Configuration Configuration file(s) Legacy rc.conf section
Hostname /etc/hostname

/etc/hosts

NETWORKING
Console fonts and keymap /etc/vconsole.conf LOCALIZATION
Locale /etc/locale.conf

/etc/locale.gen

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

如果配置文件都还不存在,并且你想修改默认设置,那么你可以很容易的手动生成。

服务

Note: Systemd can handle most daemons in Arch. Consider starting daemons with Systemd instead. See this wiki.

DAEMONS: 此处设置 /etc/rc.d/ 中需要开机执行的脚本,以一个空格分割。默认不设置也能启动系统,但安装了系统服务如 sshd 后,需要修改此设以使其开机启动。其它发行版一般用到 init.d 目录的链接实现。更多信息请阅读: 编写rc.d服务脚本

  1. 如果在服务名称前加上半角感叹号!,则显式禁用该服务。
  2. 如果在服务名称前加上@ 符号,则开机时后台启动改服务,亦即:不必等待该服务启动完毕,便执行其他操作。
示例:
DAEMONS=(@syslog-ng !network net-profiles crond sshd)
注意: 由于服务的启动顺序比较重要,所有服务按排列顺序依次启动(除非设置后台启动)。

硬件

MODULES
除自动加载的模块外,还需要在启动时装入的模块。要屏蔽模块,请阅读 Kernel modules#Blacklisting.
注意: MOD_AUTOLOADinitscripts 2011.06.1-1中已经弃用,不起任何效果。需要使用udev规则代替。
Tip: 不保证模块按顺序加载,而且不排除某些模块之前已由udev自动加载。如果必须固定加载顺序,则推荐使用Udev规则
Warning: Modules to be autoloaded at boot are now specified in /etc/modules-load.d/, and modules to be blacklisted are now specified in /etc/modprobe.d/.

接口配置

/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
  1. UTC 是推荐选项,因为它简化了时区和夏令时计算。不管进入夏令时 Linux 是否在运行,Linux 都会进行正确的夏令时转化。
  2. localtime 是和仅使用 localtime 的操作系统如 Windows 时应该使用的选项。Linux 不会进行夏令时调整。如果另外的系统没有调整夏令时,夏令时时间就会不正确。
  3. 空置: 系统会读取 /var/lib/hwclock/adjtime 中的设置,默认是 UTC。如果其它用户会修改 adjtime,请使用这个设置。
  4. 设置为其它值将不会修改硬件时间(使用 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.

Warning: None of these tools are officially supported by the Arch developers. Moreover, systemd is now the default init daemon, so /etc/rc.conf is obsolete.

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.

rcconf-settings

rcconf-settings is a tool designed for the Chakra GNU/Linux distribution but should also work on Arch Linux.