Skip to content

Commit b172d71

Browse files
committed
docs: make expectations for converting to Dinit-based system clearer
1 parent fe014d2 commit b172d71

File tree

1 file changed

+55
-22
lines changed

1 file changed

+55
-22
lines changed

doc/linux/DINIT-AS-INIT.md

+55-22
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,61 @@
11
# Dinit as init: using Dinit as your Linux system's init
22

3-
You can use Dinit, in conjunction with other software, to boot your system and
4-
replace your current init system (which on most main distributions is now
5-
Systemd, Sys V init, or OpenRC).
6-
7-
Be warned that a modern Linux system is complex and changing your init system
8-
will require some effort and preparation. It is not a trivial task to take a
9-
system based on a typical Linux distribution that uses some particular init
10-
system and make it instead boot with Dinit. You need to set up suitable
11-
service description files for your system; at present there are no automated
12-
conversion tools for converting service descriptions or startup scripts from
13-
other systems. For example service files, please check the [services](services)
14-
subdirectory (and see descriptions of all of them below).
3+
You can use Dinit, in conjunction with other software, to boot your system.
4+
5+
This document is intended as a guide for building a system around Dinit. The
6+
reader is assumed to be knowledgeable about how a Linux system works and the
7+
various components that it may be comprised of. If making changes to an
8+
existing system, please make backups and/or be prepared to recover a system
9+
that fails to boot. Support cannot be provided.
10+
11+
12+
## Converting an existing system
13+
14+
If running a Linux distribution, it is theoretically possible to replace your
15+
current init system (which on most main distributions is now Systemd, Sys V
16+
init, or OpenRC) with Dinit. However: Be warned that a modern Linux system is
17+
complex and changing your init system will require some effort and
18+
preparation. It is not a trivial task to take a system based on a typical
19+
distribution that uses some particular init system and make it instead boot
20+
with Dinit. You need to set up suitable service description files for your
21+
system; at present there are no automated conversion tools for converting
22+
service descriptions or startup scripts from other systems.
23+
24+
This guide is focused mainly on building a new system "from scratch" rather
25+
than for converting an existing system to use Dinit. With care and preparation
26+
it may, however, still be possible to convert a system based on a distribution
27+
to use Dinit. The steps required to accomplish this will depend on the
28+
specific details of how the system boots and what services it runs; this is
29+
largely beyond the scope of this guide. Note that altering a system in this
30+
way is likely to cause changes in system behaviour, potentially causing
31+
breakages, and should not be attempted for any critical systems.
32+
33+
The example services (see link below) are mostly designed for a system built
34+
"from scratch" rather than based on an existing distribution, and should be
35+
modified accordingly to keep existing functionality provided by your
36+
distribution and to work with its boot mechanism.
1537

1638
Once you have service descriptions ready, you can test Dinit by adding
1739
"init=/sbin/dinit" (for example) to the kernel command line when booting.
1840
To have Dinit run as your system init (once you are satisfied that the service
1941
descriptions are correct and that the system is bootable via Dinit), replace
2042
your system's `/sbin/init` with a link to the `dinit` executable.
2143

22-
*Note*: if your system boots via an "initrd" (initial ramdisk image), you
23-
might need to either adjust the ramdisk image to include `dinit` or switch
24-
to mounting the root filesystem directly; consult kernel, bootloader and
25-
distribution documentation for details.
26-
27-
The additional software required can be broken into _essential_ and
28-
_optional_ packages, which are detailed in following sections.
44+
*Note*: if your system is based on a distribution and boots via an
45+
"initrd"/"initramfs" (initial RAM-disk image or RAM-based filesystem), it may
46+
or may not honour kernel options such as "init=...", and it may or may not
47+
pass options such as "single" on to Dinit (which enables single-user mode).
48+
In order to be able to follow the advice/instructions in this guide, you might
49+
need to either adjust the ramdisk image or switch to mounting the root
50+
filesystem directly; consult kernel, bootloader and distribution documentation
51+
for details (which are beyond the scope of this guide).
2952

3053

3154
## General notes
3255

56+
For example service description files, please check the [services](services)
57+
subdirectory (and see descriptions of all of them below).
58+
3359
It is common to use "devtmpfs" on /dev, and the kernel can actually mount it
3460
there before it even starts the init process, which can be quite handy; for
3561
one thing it means that a range of device nodes will be available by default
@@ -61,7 +87,9 @@ days. They include:
6187
udev and some other programs
6288

6389
These filesystems (particularly /sys, /proc and /run) need to be mounted
64-
quite early as they will be used by early-boot processes.
90+
quite early as they will be used by early-boot processes. It is typical for
91+
some or all of them to be mounted by an initramfs/initrd-based initial
92+
boot, in which case it may not be necessary to mount them via Dinit services.
6593

6694
Many Linux distributions are now built around Systemd. Much of what Systemd
6795
manages was previously managed by other utilities/daemons (syslogd, inetd,
@@ -99,6 +127,9 @@ The service description files and scripts in the `services` subdirectory
99127
provide a template for accomplishing the above, but may need some adjustment
100128
for your particular configuration.
101129

130+
The additional software required can be broken into _essential_ and
131+
_optional_ packages, which are detailed in following sections.
132+
102133

103134
## Essential packages for building a Dinit-based system
104135

@@ -175,7 +206,7 @@ which they are expected to start:
175206
- `early-filesystems` - this service has no dependencies and so is one of the earliest
176207
to start. It mounts virtual filesystems including _sysfs_, _devtmpfs_ (on `/dev`)
177208
and _proc_, via the `early-filesystems.sh` shell script. Note that if startup is via
178-
an initial ram disk (initrd, initfs) as is now common, these early filesystems are
209+
an initial ram disk (initrd, initramfs) as is now common, these early filesystems are
179210
most likely already mounted by that, so this service may not be needed or could be
180211
edited to remove initrd-mounted filesystems.
181212
- `udevd` - this services starts the device node manager, udevd (from the eudev package).
@@ -300,4 +331,6 @@ For services which specify a `logfile`, the location must be writable when the s
300331
depend on the service that makes the root filesystem writable. For services that must start
301332
before the root filesystem becomes writable, it may be possible to log in `/run` or another
302333
directory that is mounted with a RAM-based filesystem; alternatively, the `shares-console`
303-
option can be used for these services so that their output is visible at startup.
334+
option can be used for these services so that their output is visible at startup. There is also
335+
the possibility of using the "log-type = buffer" setting to keep output buffered in memory
336+
instead.

0 commit comments

Comments
 (0)