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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
\input{configpres}
\title{The Linux Boot Process}
\maketitle
\subsection{Boot Process}
\begin{frame}
\frametitle{Components of the Boot Process}
\begin{itemize}
\item Bootloader
\item Linux
\item ''Userspace''
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Boot Process Procedure}
\begin{enumerate}
\item bootloader initializes hardware
\item bootloader relocates kernel
\item bootloader provides parameters and starts kernel
\item Linux boots
\item Linux kernel mounts a RFS
\item Linux kernel starts first process (/sbin/init, /linuxrc, or specified with init= parameter)
\end{enumerate}
\end{frame}
\begin{frame}
\frametitle{Responsibilities of the Bootloader}
Low-Level Initialization:
\pause
\begin{itemize}
\item clocks (CPU, PLLs, peripherals...)
\item memory (DRAM-controller, NAND-controller...)
\item serial interface
\item provide parameters to the kernel
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{The Linux Kernel}
\begin{itemize}
\item setup interrupts (i.e. timer interrupt)
\item load drivers, initialize hardware
\item mount ''root filesystem'' to /
\item start the first process
\end{itemize}
\end{frame}
\subsection{init Systems}
\begin{frame}
\frametitle{The init System}
\begin{itemize}
\item System V init
\item systemd
\item busybox-init
\item OpenRC
\item upstart
\item \dots
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{System V init}
\begin{itemize}
\item behavior defined in /etc/inittab
\item start scripts in /etc/init.d
\item split into ''runlevels''
\item runlevels describe various system states (shutdown, single-user, multi-user with/without network, \dots)
\item System V does not understand dependencies, sequential calling of start scripts
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{systemd}
\begin{itemize}
\item starts processes in parallel (without explizitly configuring dependencies):
\begin{itemize}
\item creates sockets for communicating with the starting processes
\item data written so the sockets are buffered until the starting processes can receieve the data
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{systemd}
\begin{itemize}
\item configuration via invidividual text files (no shell code)
\item the actions to perform are based on the configuration and are performed by systemd (Linux executable)
\item this prevents starting many individual shell instances
\item administration via systemctl
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{systemd}
\begin{itemize}
\item ''targets'' replace the roll of ''runlevels'' (i.e. runlevel 0 == poweroff.target)
\item multiple targets can be activated simultaneously
\item configuration files in /etc/systemd and /lib/systemd
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{systemd}
\begin{itemize}
\item compatbile to System V init. Scripts in /etc/init.d will be started
\item uses ''control groups'' for starting/monitoring processes (systemd requires CGROUPS support in the kernel!)
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{systemd: Integrating own Services}
/lib/systemd/system/training.service
\begin{verbatim}
[Unit]
Description=Just a simple systemd service
[Service]
Type=oneshot
ExecStart=/home/devel/systemd_test.sh
StandardOutput=syslog
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{systemd: Integrating own Services}
/home/devel/systemd\_test.sh
\begin{verbatim}
#!/bin/sh
echo "Here I AM :)"
sleep 5
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{systemd: Integrating own Services}
/home/devel/systemd\_test.sh
\begin{verbatim}
$ systemctl enable training.service
ln -s '/lib/systemd/system/training.service'
'/etc/systemd/system/multi-user.target.wants/training.service'
\end{verbatim}
\end{frame}
\subsection{Boot Time Analysis}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: Bootloader}
Use the scope, Luke! ;)
\begin{figure}[h]
\centering
\includegraphics[height=5cm]{images/at91_ipl_quiet_lpj_lzo.png}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: Kernel}
\begin{itemize}
\item boot the target with initcall\_debug und printk.time=1
\item from the target: dmesg > bootlog.txt
\item copy bootlog.txt to the host
\item from the host:
\begin{verbatim}
perl linux-src/scripts/bootgraph.pl < bootlog.txt > bootlog.svg
\end{verbatim}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: Kernel}
\begin{figure}[h]
\centering
\includegraphics[height=5cm]{images/bootlog.png}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: System V}
Analyze the boot process with bootchart:
\begin{itemize}
\item boot the target with init=/sbin/bootchartd
\item after booting, stop bootchard on the target:
\begin{verbatim}
/sbin/bootchartd stop
\end{verbatim}
\item (for older versions) copy /var/log/bootchart.tgz to the host
\item (for older versions) from the host generate an SVG graphic file:
\begin{verbatim}
java -jar bootchart.jar -f svg bootchart.tgz
\end{verbatim}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: System V / bootchart}
\begin{figure}[h]
\centering
\includegraphics[height=5cm]{images/bootchart.png}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: systemd}
Analyze the boot process with systemd:
\begin{itemize}
\item boot the target via systemd
\item after booting, run systemd-analyze on the target
\begin{verbatim}
$ systemd-analyze blame
1897ms networking.service
1715ms vmware-tools.service
1234ms nfs-common.service
# or
$ systemd-analyze plot > boot.svg
\end{verbatim}
\item copy the output or plot to the host to analyze
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: systemd-analyze plot}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/debian_systemd_top.png}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boot Time Analysis: systemd-analyze plot}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/debian_systemd_bottom.png}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Sources}
\begin{thebibliography}{1}
\bibitem{kof} Linux 2012, Michael Kofler, PEARSON Verlag
\bibitem{heise} http://www.heise.de/open/artikel/Das-Init-System-Systemd-Teil-1-1563259.html
\end{thebibliography}
\end{frame}
\input{tailpres}
|