1
00:00:00,005 --> 00:00:03,004
- [Instructor] GRUB is the most popular bootloader

2
00:00:03,004 --> 00:00:07,001
for Linux for servers and desktops.

3
00:00:07,001 --> 00:00:10,003
Embedded Linux devices often have a different bootloader,

4
00:00:10,003 --> 00:00:14,001
but GRUB is valuable to know about.

5
00:00:14,001 --> 00:00:16,004
There have been, of course, different versions of GRUB,

6
00:00:16,004 --> 00:00:18,003
just like everything else.

7
00:00:18,003 --> 00:00:21,001
For GRUB, there's some important config files

8
00:00:21,001 --> 00:00:23,009
underneath etc,

9
00:00:23,009 --> 00:00:27,009
so you can configure GRUB there

10
00:00:27,009 --> 00:00:31,000
and add new entries for example.

11
00:00:31,000 --> 00:00:33,001
A lot of this happens automatically

12
00:00:33,001 --> 00:00:34,007
through the way packages work.

13
00:00:34,007 --> 00:00:37,001
If you install a new kernel,

14
00:00:37,001 --> 00:00:39,003
generally your GRUB will get updated

15
00:00:39,003 --> 00:00:42,003
to boot your new kernel.

16
00:00:42,003 --> 00:00:47,000
But you can create new entries, you can customize things.

17
00:00:47,000 --> 00:00:48,002
If you want to add a new one,

18
00:00:48,002 --> 00:00:54,005
generally you'll edit 40_custom underneath etc/grub.d.

19
00:00:54,005 --> 00:00:57,000
When you make changes to GRUB configuration,

20
00:00:57,000 --> 00:01:01,003
you need to generate its config file it's going to use,

21
00:01:01,003 --> 00:01:05,003
so you'll run grub2-mkconfig.

22
00:01:05,003 --> 00:01:09,004
One of the nice features of GRUB is

23
00:01:09,004 --> 00:01:14,004
when your system starts booting, it's going to run GRUB,

24
00:01:14,004 --> 00:01:17,008
and then GRUB can pause briefly

25
00:01:17,008 --> 00:01:19,009
before it starts the kernel.

26
00:01:19,009 --> 00:01:23,007
And that can give you time to interrupt it

27
00:01:23,007 --> 00:01:27,007
so that you can temporarily change

28
00:01:27,007 --> 00:01:30,005
the kernel command line.

29
00:01:30,005 --> 00:01:33,000
If you're experimenting with things and you have a typo

30
00:01:33,000 --> 00:01:35,002
and you give it the path to a kernel

31
00:01:35,002 --> 00:01:36,005
that doesn't exist or something,

32
00:01:36,005 --> 00:01:37,009
then your system won't boot.

33
00:01:37,009 --> 00:01:42,006
So being able to interactively fix that is kind of nice.

34
00:01:42,006 --> 00:01:46,004
So GRUB has a bunch of interactive commands

35
00:01:46,004 --> 00:01:49,004
like B to boot and so forth,

36
00:01:49,004 --> 00:01:50,008
and there's a little bit of documentation

37
00:01:50,008 --> 00:01:53,009
that tell you, use B or use Control + X.

38
00:01:53,009 --> 00:01:56,002
Now the challenge here is you might not be able

39
00:01:56,002 --> 00:01:58,004
to get to a system console.

40
00:01:58,004 --> 00:02:01,002
If you have the system at your desk and you have a monitor

41
00:02:01,002 --> 00:02:03,002
and keyboard and all hooked up to it,

42
00:02:03,002 --> 00:02:05,007
then you can get the system console.

43
00:02:05,007 --> 00:02:07,004
But these days,

44
00:02:07,004 --> 00:02:09,002
most of your systems are probably in data centers

45
00:02:09,002 --> 00:02:10,006
or they're Vms,

46
00:02:10,006 --> 00:02:12,005
getting the system console might be difficult,

47
00:02:12,005 --> 00:02:15,000
but it could be handy.

48
00:02:15,000 --> 00:02:17,003
I've done it many, many times.

49
00:02:17,003 --> 00:02:20,002
So the generated GRUB config file

50
00:02:20,002 --> 00:02:24,001
should be boot/grub/grub.cfg,

51
00:02:24,001 --> 00:02:26,001
and that's still kind of hard to read,

52
00:02:26,001 --> 00:02:26,009
but if you read through it,

53
00:02:26,009 --> 00:02:29,009
you'll see lines for booting the kernel,

54
00:02:29,009 --> 00:02:32,002
you'll see the kernel command line.

55
00:02:32,002 --> 00:02:35,006
For example, you might see something like this, Linux,

56
00:02:35,006 --> 00:02:39,005
and then name of a Linux kernel file,

57
00:02:39,005 --> 00:02:45,006
and then where the root file system's supposed to come from.

58
00:02:45,006 --> 00:02:47,001
And ro is usually there,

59
00:02:47,001 --> 00:02:50,008
telling the kernel to mount the root file system read-only.

60
00:02:50,008 --> 00:02:51,007
That's kind of curious.

61
00:02:51,007 --> 00:02:53,009
Your root file system isn't read-only.

62
00:02:53,009 --> 00:02:57,003
Well, it is when GRUB boots it,

63
00:02:57,003 --> 00:03:00,000
that lets the system check it

64
00:03:00,000 --> 00:03:03,000
for consistency while nothing's writing to it.

65
00:03:03,000 --> 00:03:05,005
And then after everything checks out,

66
00:03:05,005 --> 00:03:11,003
the system daemons will remount your file system read-write,

67
00:03:11,003 --> 00:03:13,001
and it's not till after that's done

68
00:03:13,001 --> 00:03:15,009
that you can actually log in.

69
00:03:15,009 --> 00:03:17,008
So might be valuable to know.

70
00:03:17,008 --> 00:03:20,003
You could mount it read-write to start with,

71
00:03:20,003 --> 00:03:24,000
but don't do a file system check with it writeable.

