120 lines
3.9 KiB
Markdown
120 lines
3.9 KiB
Markdown
---
|
|
title: S6
|
|
layout: default
|
|
parent: Init Systems
|
|
nav_order: 4
|
|
---
|
|
|
|
# S6
|
|
|
|
**S6** is a process supervision suite designed for modularity, security, and performance. It's not just an init system — it's a full ecosystem of tools for service management (`s6-rc`), logging, and system initialization (`s6-linux-init`). Written by Laurent Bercot, it's the most technically sophisticated of the non-systemd inits.
|
|
|
|
> S6 is actually three layers:
|
|
> 1. **s6** — core process supervision (svscan, supervise, svc)
|
|
> 2. **s6-rc** — dependency-based service manager
|
|
> 3. **s6-linux-init** — creates the `/sbin/init` binary
|
|
|
|
## Philosophy
|
|
|
|
S6 takes the daemontools/runit model and extends it with:
|
|
- **Modularity** — every piece is separate and replaceable
|
|
- **Security** — services run with minimal privileges, no ambient authority
|
|
- **Performance** — fully parallel startup, designed for speed
|
|
- **Reliability** — automatic restart, logging, notification
|
|
|
|
Unlike runit, s6 has a real dependency-based service manager (`s6-rc`) with declarative service definitions. It's the closest you can get to systemd's feature set without the bloat.
|
|
|
|
## Who uses it?
|
|
|
|
- **Artix Linux** — available as an alternative init
|
|
- **Docker images** — s6-overlay is popular for container supervision
|
|
- Embedded systems, minimal Linux builds
|
|
|
|
## How it works
|
|
|
|
1. Kernel starts `/sbin/init` (created by `s6-linux-init-maker`)
|
|
2. `s6-linux-init` mounts tmpfs, copies early services, execs into `s6-svscan`
|
|
3. `s6-svscan` becomes PID 1 and starts the supervision tree
|
|
4. `rc.init` script launches `s6-rc` with the default runlevel
|
|
5. `s6-rc` resolves dependencies and starts services in order
|
|
|
|
## Key concepts
|
|
|
|
| Concept | What it means |
|
|
|---------|---------------|
|
|
| `s6-svscan` | PID 1 — root of the supervision tree |
|
|
| `s6-supervise` | Monitors one service directory, restarts on crash |
|
|
| `s6-svc` | Control tool — send commands to services |
|
|
| `s6-rc` | Dependency-based service manager (compiled database) |
|
|
| `s6-log` | Built-in logging with auto-rotation |
|
|
| Service directories | Like runit — each service is a directory with a `run` script |
|
|
| Compilation | `s6-rc` compiles service definitions into a binary database |
|
|
|
|
## Basic commands
|
|
|
|
```bash
|
|
# Start a service
|
|
s6-svc -u /run/service/sshd
|
|
|
|
# Stop a service
|
|
s6-svc -d /run/service/sshd
|
|
|
|
# Restart a service
|
|
s6-svc -r /run/service/sshd
|
|
|
|
# Check status
|
|
s6-svc -a /run/service/sshd
|
|
|
|
# With s6-rc (service manager):
|
|
s6-rc -d change sshd # start
|
|
s6-rc -d stop sshd # stop
|
|
s6-rc -d status sshd # status
|
|
```
|
|
|
|
## Example service
|
|
|
|
`/etc/s6/sv/sshd/run`:
|
|
```bash
|
|
#!/bin/sh
|
|
exec /usr/bin/sshd -D
|
|
```
|
|
|
|
With s6-rc, you also need a service definition file:
|
|
|
|
`/etc/s6/rc/sources/sshd/type`:
|
|
```
|
|
oneshot
|
|
```
|
|
|
|
`/etc/s6/rc/sources/sshd/up`:
|
|
```bash
|
|
#!/bin/sh
|
|
s6-svc -u /run/service/sshd
|
|
```
|
|
|
|
## Comparison with OpenRC
|
|
|
|
| | OpenRC | S6 |
|
|
|---|--------|-----|
|
|
| Service format | Shell scripts | `run` scripts + s6-rc definitions |
|
|
| Dependencies | Manual (`need`/`use`) | Automatic via s6-rc |
|
|
| Supervision | No built-in | Yes — full supervision tree |
|
|
| Logging | syslog or separate | Built-in per-service (`s6-log`) |
|
|
| Boot speed | Fast | Very fast |
|
|
| Complexity | Low | Medium-High |
|
|
| Flexibility | Moderate | Very high (modular) |
|
|
|
|
## When to use S6
|
|
|
|
S6 is suitable for advanced users who want full process supervision with dependency-based service management and per-service logging. It offers the most features of any non-systemd init but has a steeper learning curve than OpenRC or Runit.
|
|
|
|
Users who need supervision, logging, and dependency resolution without systemd will find S6 the most capable option. Users who prefer simplicity may prefer OpenRC or Dinit.
|
|
|
|
## Learn more
|
|
|
|
- [S6 official site](https://skarnet.org/software/s6/)
|
|
- [S6 overview](https://skarnet.org/software/s6/overview.html)
|
|
- [s6-linux-init](https://skarnet.org/software/s6-linux-init/)
|
|
- [Artix S6 page](https://wiki.artixlinux.org/Main/S6)
|
|
- [S6 on Gentoo Wiki](https://wiki.gentoo.org/wiki/S6)
|