1
00:00:00,001 --> 00:00:02,009
- [Instructor] It can be essential

2
00:00:02,009 --> 00:00:05,002
or at least advantageous

3
00:00:05,002 --> 00:00:09,002
to modify how your kernel boots.

4
00:00:09,002 --> 00:00:11,005
So the Linux kernel supports

5
00:00:11,005 --> 00:00:15,000
what are called kernel command-line parameters,

6
00:00:15,000 --> 00:00:19,006
and GRUB is responsible for passing those parameters.

7
00:00:19,006 --> 00:00:21,007
When GRUB starts up the kernel,

8
00:00:21,007 --> 00:00:23,001
it will tell the kernel

9
00:00:23,001 --> 00:00:24,005
where to find the parameters

10
00:00:24,005 --> 00:00:27,008
that GRUB got out of its config file.

11
00:00:27,008 --> 00:00:30,008
So the kernel will process those command line arguments,

12
00:00:30,008 --> 00:00:33,002
and if there's any it doesn't recognize,

13
00:00:33,002 --> 00:00:34,009
it pretty much just ignores those,

14
00:00:34,009 --> 00:00:37,005
so you can make up new ones.

15
00:00:37,005 --> 00:00:42,000
Sometimes user space will take advantage of that

16
00:00:42,000 --> 00:00:46,006
by looking for special arguments

17
00:00:46,006 --> 00:00:48,002
that were passed at the kernel

18
00:00:48,002 --> 00:00:51,005
that could affect how the user space program works.

19
00:00:51,005 --> 00:00:54,006
You can look at what the kernel command line was

20
00:00:54,006 --> 00:00:57,006
by looking at the output of the dmesg command

21
00:00:57,006 --> 00:01:01,001
or in the file /proc.cmdline.

22
00:01:01,001 --> 00:01:04,006
There is documentation for many other kernel parameters.

23
00:01:04,006 --> 00:01:07,002
You can look in the kernel source tree

24
00:01:07,002 --> 00:01:09,003
underneath the Documentation subdirectory

25
00:01:09,003 --> 00:01:13,008
in the file aptly called kernel-parameters.txt.

26
00:01:13,008 --> 00:01:16,006
In mine, I found about 1,000 kernel parameters

27
00:01:16,006 --> 00:01:18,003
are documented there.

28
00:01:18,003 --> 00:01:21,002
And here's a fancy little grep that started the line.

29
00:01:21,002 --> 00:01:22,004
There's a tap character

30
00:01:22,004 --> 00:01:25,007
and then, you know, a letter or a digit.

31
00:01:25,007 --> 00:01:30,008
So anyway, that found a little over 1,000 for my kernel.

32
00:01:30,008 --> 00:01:33,002
And if you're looking at the kernel source,

33
00:01:33,002 --> 00:01:34,004
and you want to get an idea

34
00:01:34,004 --> 00:01:39,008
of what handles various of these parameters,

35
00:01:39,008 --> 00:01:43,004
you can look at what's getting registered

36
00:01:43,004 --> 00:01:45,009
with the function with_setup().

37
00:01:45,009 --> 00:01:51,000
That's associated with kernel parameters, for the most part.

38
00:01:51,000 --> 00:01:52,008
So like I said, there's over 1,000.

39
00:01:52,008 --> 00:01:55,004
There's all kinds of different ones.

40
00:01:55,004 --> 00:01:57,004
For example, maybe to work

41
00:01:57,004 --> 00:02:00,007
around a hardware bug, like cachesize,

42
00:02:00,007 --> 00:02:04,000
or maybe to disable certain CPU feature,

43
00:02:04,000 --> 00:02:09,003
or maybe there's a security risk, like clearcpuid.

44
00:02:09,003 --> 00:02:12,009
And of course, no guarantee

45
00:02:12,009 --> 00:02:15,009
that messing with things like this is going to work.

46
00:02:15,009 --> 00:02:20,005
You might cause your kernel to misbehave or not even boot.

47
00:02:20,005 --> 00:02:22,009
So, of course, you got to be careful.

48
00:02:22,009 --> 00:02:26,002
crashkernel's used to reserve some memory

49
00:02:26,002 --> 00:02:28,000
in case you have a crash

50
00:02:28,000 --> 00:02:31,007
for a special crashkernel to come up.

51
00:02:31,007 --> 00:02:34,002
And the way that works is the memory

52
00:02:34,002 --> 00:02:37,001
that your original kernel was using is preserved,

53
00:02:37,001 --> 00:02:39,006
and the crashkernel can save

54
00:02:39,006 --> 00:02:41,008
that other memory out to a file.

55
00:02:41,008 --> 00:02:44,005
So you can examine the state of memory

56
00:02:44,005 --> 00:02:47,005
when your kernel crashed for debugging.

57
00:02:47,005 --> 00:02:50,009
The enforcing kernel parameter is used to enable

58
00:02:50,009 --> 00:02:53,002
or disable SELinux.

59
00:02:53,002 --> 00:02:57,000
ftrace is used to start a kernel tracer

60
00:02:57,000 --> 00:02:58,009
as early as possible

61
00:02:58,009 --> 00:03:02,002
to get some trace information that could be helpful

62
00:03:02,002 --> 00:03:06,008
to help debug what's going on in the kernel early on.

63
00:03:06,008 --> 00:03:11,004
You can set a init to run a program instead of /sbin/init,

64
00:03:11,004 --> 00:03:13,002
the process that started up

65
00:03:13,002 --> 00:03:16,005
when the kernel starts the first process.

66
00:03:16,005 --> 00:03:18,006
And if you're using an init ramdisk

67
00:03:18,006 --> 00:03:20,003
or init/ramfs,

68
00:03:20,003 --> 00:03:27,000
you can set what program to run for init within that image.

69
00:03:27,000 --> 00:03:28,009
So there's a lot of parameters,

70
00:03:28,009 --> 00:03:32,004
and you might find when you do a web search

71
00:03:32,004 --> 00:03:34,000
for a problem you're having,

72
00:03:34,000 --> 00:03:38,000
that the advice is to set a kernel parameter.

