|
1 | 1 | # Dinit as init: using Dinit as your Linux system's init
|
2 | 2 |
|
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. |
15 | 37 |
|
16 | 38 | Once you have service descriptions ready, you can test Dinit by adding
|
17 | 39 | "init=/sbin/dinit" (for example) to the kernel command line when booting.
|
18 | 40 | To have Dinit run as your system init (once you are satisfied that the service
|
19 | 41 | descriptions are correct and that the system is bootable via Dinit), replace
|
20 | 42 | your system's `/sbin/init` with a link to the `dinit` executable.
|
21 | 43 |
|
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). |
29 | 52 |
|
30 | 53 |
|
31 | 54 | ## General notes
|
32 | 55 |
|
| 56 | +For example service description files, please check the [services](services) |
| 57 | +subdirectory (and see descriptions of all of them below). |
| 58 | + |
33 | 59 | It is common to use "devtmpfs" on /dev, and the kernel can actually mount it
|
34 | 60 | there before it even starts the init process, which can be quite handy; for
|
35 | 61 | one thing it means that a range of device nodes will be available by default
|
@@ -61,7 +87,9 @@ days. They include:
|
61 | 87 | udev and some other programs
|
62 | 88 |
|
63 | 89 | 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. |
65 | 93 |
|
66 | 94 | Many Linux distributions are now built around Systemd. Much of what Systemd
|
67 | 95 | manages was previously managed by other utilities/daemons (syslogd, inetd,
|
@@ -99,6 +127,9 @@ The service description files and scripts in the `services` subdirectory
|
99 | 127 | provide a template for accomplishing the above, but may need some adjustment
|
100 | 128 | for your particular configuration.
|
101 | 129 |
|
| 130 | +The additional software required can be broken into _essential_ and |
| 131 | +_optional_ packages, which are detailed in following sections. |
| 132 | + |
102 | 133 |
|
103 | 134 | ## Essential packages for building a Dinit-based system
|
104 | 135 |
|
@@ -175,7 +206,7 @@ which they are expected to start:
|
175 | 206 | - `early-filesystems` - this service has no dependencies and so is one of the earliest
|
176 | 207 | to start. It mounts virtual filesystems including _sysfs_, _devtmpfs_ (on `/dev`)
|
177 | 208 | 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 |
179 | 210 | most likely already mounted by that, so this service may not be needed or could be
|
180 | 211 | edited to remove initrd-mounted filesystems.
|
181 | 212 | - `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
|
300 | 331 | depend on the service that makes the root filesystem writable. For services that must start
|
301 | 332 | before the root filesystem becomes writable, it may be possible to log in `/run` or another
|
302 | 333 | 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