Linux 系统初始化与服务管理:从 System V init 到 systemd
1. System V init 基础
1.1 inittab 文件解析
在 Linux 系统中, init
程序启动时会读取 /etc/inittab
文件,该文件定义了每个运行级别下系统的行为。其格式是 BusyBox inittab
的扩展版本,因为 BusyBox 最初是从 System V 借鉴而来的。
inittab
中每行的格式如下:
id:runlevels:action:process
各字段说明:
| 字段 | 说明 |
| ---- | ---- |
| id | 最多四个字符的唯一标识符 |
| runlevels | 该条目应执行的运行级别,BusyBox inittab
中此部分留空 |
| action | 以下段落给出的关键字之一 |
| process | 要运行的命令 |
action
关键字与 BusyBox init
相同,包括 sysinit
、 respawn
、 once
、 wait
、 restart