summaryrefslogtreecommitdiffstats
path: root/2020-09-08.md
blob: fa96eaa05f0a55962fb3b0d5d09a0ddb6b0773f6 (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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
---
title: WTF is Linux
author: Rémi Nicole <remi.nicole@smile.fr>
date: 2020-09-08
slide-level: 2
aspectratio: 169

theme: metropolis
colortheme: owl
beameroption: "show notes on second screen=right"

toc: true
highlightstyle: breezedark
lang: en-US

bibliography: ../bibliography.bib
---

# The Project

## Building a Linux system manually

- This is the Course (You are Here)
- Using just normal commands

::: notes

Hello

:::

## Building a Linux system automatically

- Practical Work
- Buildroot


## Why

- Linux is everywhere in embedded software
- Linux is everywhere in the server space


# History

## 17th century to 1970s

:::: columns

::: column
![Human computer at NACA [@wikimedia:human_computer]](../res/Human Computer.jpg){ height=80% }
:::
::: column
![Katherine Johnson working as a Human computer at NASA [@wikimedia:katherine_johnson_human_computer]](../res/Katherine Johnson at NASA.jpg){ height=80% }
:::

::::

::: notes

- NACA: National Advisory Committee for Aeronautics
- "Computer" referred to the person that did mathematical computation
  / verification
- Verify trajectories for putting men into Earth orbit
- Katherine Johnson on the right
- You can watch the movie "Hidden Figures"

:::

## 1930s-1940s

![Bletchley Park Bombe [@wikimedia:bletchley_park_bombe]](../res/Bletchley Park Bombe.jpg){ width=45% height=80% }

::: notes

- You can watch the movie "The Imitation Game"

:::

## 1950s

::: columns

:::: column
![IBM 704 Mainframe [@wikimedia:ibm_704_mainframe]](../res/IBM 704 mainframe.jpg){ height=80% }
::::

:::: column
![IBM 709 Mainframe [@ibm:ibm_709_mainframe]](../res/IBM 709 mainframe.jpg){ height=80% }
::::

:::

::: notes

- There are lights and switches
- Back in the day, there were used to inspect and modify memory / registries or
  see the executed instructions
- Already two influential programming languages existed:
	- FORTRAN (formula translation)
	- Lisp
- We can see:
	- The Operator's Console
	- The Central Processing Unit (CPU)
	- The Punch card reader
	- The Magnetic Tape Unit (for long term storage)
- Very few "professional programmers"

:::

## 1950s---The line printer

![IBM 716 Line Printer [@ibm:ibm_716_line_printer]](../res/IBM 716 line printer.jpg){ height=80% }

::: notes

- Really shaped the terminal as we know today

:::

## 1969

:::: columns

::: column

Things were pricey:

- Disk 180MB -> 32,000$
- Commercial compiler -> 100,000$
:::

::: column
![Boot [@needpix:boot]](../res/boot.png){ height=80% }
:::

::::

::: notes

- You could buy a very nice house for 32,000$

:::


## 1970s---UNIX {.allowframebreaks}

![Ken Thompson (sitting) and Dennis Ritchie working together at a PDP-11 [@wikimedia:ken_thompson_dennis_ritchie]](../res/Ken Thompson and Dennis Ritchie at PDP-11.jpg){ height=67% }

::: notes

- He is actually coding using the teletypewriter

:::

\framebreak

- Smaller, for one person[@fosdem:fifty_years_of_unix]
- They actually used their own operating system
- Invented C a bit later (1972)
- Definitely not "free", barely "open":
	160,000 $ per CPU

Berkeley university made BSD out of it (was called Berkeley UNIX)

::: notes

- Targeted at big companies

:::

\framebreak

- Same OS, different computers
- Compiler took care of the difference in architecture.

::: notes

- Big advantages when compared to other solutions
- This made UNIX popular, and by extension the C programming language too

:::

\framebreak

Invented over the years by contributions:

- shell (command interpreter)
- pipes and filters in shell commands
- Network file system (NFS)
- Client/Server Windowing System
- etc.

## 1980s---GNU (Richard Stallman)

1983:
: GNU project annouced

1985:
: Created the Free Software Foundation (helps funding)

1989:
: Created GNU General Public License (GPL)

Created:

- Text editor (Emacs)
- Compiler suite
- Lots of utilities

People could use these tools in different operating system

::: notes

- Frustrated by his printer
- Internet was widely used in academia

:::

## 1990s---POSIX

- Lots of different "UNIX-like" operating system existed
- There was no proper definition of what "UNIX-like" meant

## 1991--The Linux kernel (Linus Torvalds)

- Just for fun
- Needed a license

::: notes

- Got an Intel i386 processor for Christmas
- Wasn't happy with the OS (he wanted page-based memory)
- Started writing a kernel, just for fun
- He was 21 years old
- The current situation made it possible:
	- Powerful "cheap" computers
	- "Faster" internet where you could find information about operating system
	  and hardware architecture

:::

## 1994--Windows NT

Bleurgh

::: notes

- Made the "personal computer" popular
- Based on a shitty technology from IBM called DOS

:::

## 1990s--Linux gaining popularity

- Free
- More choice for architecture
- Real TCP/IP stack


::: notes

- Wow, you want to connect to the internet?!

:::

# Command-line primer

## Most commands

```console
Copies the file "file_1.txt" into "file_2.txt"
user@host:~$ cp    file_1.txt    file_2.txt
             ^^    ^^^^^^^^^^    ^^^^^^^^^^
             |         |             |
             |         '-------------'- arguments
             |
             '---------------------- command name (verb)
```

## The prompt

```console
 ,------ username you are logged in as
 |
 |        ,---- directory you are in,
 |        |     '~' means your user directory
vvvv      v
user@host:~$
     ^^^^  ^
      |    |
      |    '--- '$' if you are a normal user,
      |         '#' if you are the root user
      |
      '--- name of the machine you are on
```

## POSIX & GNU conventions

```console
                       ,-------------- long option / flag
                       |
                       |           ,-- short option / flag
                       |           |
             vvvvvvvvvvvvvvvvvvvvv vv
$ git commit --message="My commit" -S src/main.cpp
  ^^^ ^^^^^^                          ^^^^^^^^^^^^
   |    |                               |
   |    '----------------------------- subcommand or argument
   |
   '---------------------------------- command name
```

# The kernel

## Role

Well, it depends on the kernel

::: notes

Some kernel are very small, some

:::

---

![Monolithic kernel vs Microkernel](../res/OS-structure.pdf){ height=80% }

## The Linux kernel

- Monolithic kernel:
  - Drivers are in the kernel
  - File-systems (ext4, fat32, etc.) are in the kernel
  - Lots of other things


## Communicating with the Linux kernel

- System calls

::: notes

- They look like functions in C code, but that's a lie, it's a hardware feature
  using interrupts

- That's it
- Kinda
- We can't have one system call for everything
  - Different system calls for different types of hardware

:::

. . .

- Everything is a file

::: notes

- We have special files and special file-systems
  - They look like files, but that's a lie
  - Reading / Writing to it does *not* read / write to storage
  - Instead it's like calling a function of the kernel
- Example with `/proc/cpuinfo`

:::

## Compiling a kernel

Let's do it

## Linux boot process


```
Boot loader
    |
    | loads
    v
Linux kernel
    |
    | launches
    v
init (first user process)
    |
    | does whatever it wants
    v
  ?????
```

::: notes

- We're not going to talk about the boot loader
- Example with `htop`

:::

# References