aboutsummaryrefslogtreecommitdiff
path: root/init.texi
blob: e9283bccd90c573a600d33227587004802383225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@c This document is part of Carbs Linux Documentation.
@c See the top.texi file for LICENSE information.

@c -----------------------------------------------------------------------------

@node Init System
@chapter Init System

Carbs Linux init scripts are run by the init daemon (@command{busybox} by default)
on boot and shutdown processes. It also provides its own halting program named
shalt. This provides a portable method that doesn't rely on non-POSIX external
programs.

@menu
* Configuring Init::       Ways to configure the init system
* Init Hooks::             Adding your personal commands to the init system
* Changing Init Program::  Replacing the default busybox init with something new
@end menu


@c -----------------------------------------------------------------------------

@node Configuring Init
@section Configuring Init

There are three ways you can change the behaviour of the init system. Those are:

@enumerate
@item
Kernel Command Line
@item
@file{/etc/init/rc.conf} file
@item
Init Hooks
@end enumerate


@c -----------------------------------------------------------------------------

@subsection Kernel Command Line

On GRUB, you can edit the kernel command line parameters, which will be parsed
as variables on the init system. Not all of the parameters will be acted upon,
but all of them will be set as variables on the init script. For example an
example command line, and how it is interpreted.

@example
BOOT_IMAGE=/boot/vmlinuz root=/dev/sda2 rw loglevel=3 quiet
@end example

This command line will be parsed to set the following variables:

@example
BOOT_IMAGE=/boot/vmlinuz
root=/dev/sda2
rw=1
loglevel=3
quiet=1
@end example

Some of these variables, such as @env{rw}/@env{ro}, @env{loglevel}, and
@env{quiet}, will be used by the init system to change the behaviour of the
startup.


@c -----------------------------------------------------------------------------

@subsection @file{/etc/init/rc.conf} file

However, the kernel command line isn't the only place to set your boot
parameters. You can specify variables here as well, although note that the
kernel command line always gets the priority for these variables since they can
be set just before boot.


@c -----------------------------------------------------------------------------

@node Init Hooks
@section Init Hooks

Init hooks are for custom personal commands that the user may want to add to
alter their boot. These can be used to load kernel modules, modify interfaces,
and lot more. Those hooks are added to the @file{/etc/init} directory with the
hook name as the suffix. For example, a boot script will be placed as
@file{/etc/init/my-hook.boot}. Currently, there are 4 hooks that the user can use.

@table @file
@item early-boot
Run after pseudo-filesystems are mounted.
@item boot
Run before the boot stage is completed.
@item pre.shutdown
Run first when shutting down.
@item post.shutdown
Run just before the system is halted.
@end table


@c -----------------------------------------------------------------------------

@node Changing Init Program
@section Changing Init Program

By default, Carbs Linux comes preinstalled with @command{busybox-init}, but this
can easily be replaced without any issues. Currently, available init systems are:

@itemize
@item
sinit
@item
busybox
@item
runit
@item
shinit
@end itemize

This example is for runit, but it will work with all init systems packaged in the
distribution repositories. @xref{@command{cpt-alternatives}}

@example
$ cpt a runit /usr/bin/init
$ cpt a runit /usr/bin/poweroff
$ cpt a runit /usr/bin/reboot
@end example


@c -----------------------------------------------------------------------------

@subsection Rebooting after changing Init

After switching init systems, your running init system may not accept the
new poweroff commands. You will need to reboot/poweroff using the running init's
utilities for the new utilities to work. These commands are for the init system
currently running on your system and not the one you are switching to.

@table @command
@item busybox
@code{$ busybox reboot}
@item runit
@code{$ runit-init 6}
@item shinit/sinit
@code{$ kill -s INT 1}
@end table


@c -----------------------------------------------------------------------------