1
00:00:00,005 --> 00:00:03,007
- [Instructor] Let's talk a little bit more about booting.

2
00:00:03,007 --> 00:00:07,003
So GRUB passes control to the kernel,

3
00:00:07,003 --> 00:00:09,008
giving it its command line arguments

4
00:00:09,008 --> 00:00:13,005
and telling it where in memory GRUB loaded

5
00:00:13,005 --> 00:00:17,000
the initial RAM file system,

6
00:00:17,000 --> 00:00:19,001
if there is one.

7
00:00:19,001 --> 00:00:23,008
That initial RAM file system or initial RAM disk

8
00:00:23,008 --> 00:00:25,005
might have a root file system on it

9
00:00:25,005 --> 00:00:28,004
and that might get mounted first.

10
00:00:28,004 --> 00:00:31,005
And an init from that could run,

11
00:00:31,005 --> 00:00:33,008
perhaps loading some loadable kernel modules

12
00:00:33,008 --> 00:00:35,007
that were in that image,

13
00:00:35,007 --> 00:00:38,003
that might be required

14
00:00:38,003 --> 00:00:41,007
to be able to mount your real root file system.

15
00:00:41,007 --> 00:00:46,005
If your kernel was not built with support

16
00:00:46,005 --> 00:00:48,009
for say the kind of device

17
00:00:48,009 --> 00:00:52,002
that holds your root file system,

18
00:00:52,002 --> 00:00:58,005
then that support could be loaded via the initramfs.

19
00:00:58,005 --> 00:01:01,001
The Linux kernel then kind of by hand

20
00:01:01,001 --> 00:01:03,009
creates the very first process.

21
00:01:03,009 --> 00:01:09,003
So that process will have process ID one.

22
00:01:09,003 --> 00:01:13,006
And in the kernel source code, it looks for a program

23
00:01:13,006 --> 00:01:16,005
and a couple of places with the name init,

24
00:01:16,005 --> 00:01:18,004
and that's what it's going to start.

25
00:01:18,004 --> 00:01:20,002
And if it doesn't find something called init,

26
00:01:20,002 --> 00:01:24,003
then it'll try to start a shell.

27
00:01:24,003 --> 00:01:26,004
In my experience, if it can't find init,

28
00:01:26,004 --> 00:01:27,009
it's not going to be able to find a shell

29
00:01:27,009 --> 00:01:31,006
because something was seriously wrong.

30
00:01:31,006 --> 00:01:34,002
And although you might have the name init,

31
00:01:34,002 --> 00:01:35,007
it might be a link.

32
00:01:35,007 --> 00:01:38,001
Like these days, init probably is a link

33
00:01:38,001 --> 00:01:39,006
to the systemd program.

34
00:01:39,006 --> 00:01:44,004
So systemd will be the very first process.

35
00:01:44,004 --> 00:01:47,000
And the init program, like systemd,

36
00:01:47,000 --> 00:01:51,002
is then responsible for starting up everything else.

37
00:01:51,002 --> 00:01:55,002
So it's the ancestor of all processes,

38
00:01:55,002 --> 00:01:59,003
maybe the great-grandfather or great-great-grandfather,

39
00:01:59,003 --> 00:02:02,005
but it's back there as an ancestor.

40
00:02:02,005 --> 00:02:06,003
So it starts up Daemons, it starts up whatever you need

41
00:02:06,003 --> 00:02:09,005
to be able to log in and so forth.

42
00:02:09,005 --> 00:02:11,004
So of course, as Linux has evolved,

43
00:02:11,004 --> 00:02:14,000
how all that work has evolved.

44
00:02:14,000 --> 00:02:17,005
It used to be services underneath etc/rc.d,

45
00:02:17,005 --> 00:02:21,009
but these days, most Linux systems use systemd,

46
00:02:21,009 --> 00:02:23,009
and there's lots of service files

47
00:02:23,009 --> 00:02:25,000
and you can go look at some

48
00:02:25,000 --> 00:02:28,004
by looking at etc/systemd/system.

49
00:02:28,004 --> 00:02:30,009
And there's other places on your system

50
00:02:30,009 --> 00:02:32,008
where the services might be,

51
00:02:32,008 --> 00:02:35,002
but that's configured just start up stuff,

52
00:02:35,002 --> 00:02:37,001
like your web server.

53
00:02:37,001 --> 00:02:40,002
So these are user-space services, remember.

54
00:02:40,002 --> 00:02:42,005
These are not parts of the kernel.

55
00:02:42,005 --> 00:02:46,004
The kernel's job was to get systemd running

56
00:02:46,004 --> 00:02:49,000
and then systemd takes it from there.

