1
00:00:00,000 --> 00:00:10,600
In this lesson, I will explain Linux hardware management.

2
00:00:10,600 --> 00:00:14,080
So the Linux kernel is responsible for device management.

3
00:00:14,080 --> 00:00:19,799
So any hardware you want to use needs to be addressed by a Linux kernel module.

4
00:00:19,799 --> 00:00:23,799
And these modules work with specific device types.

5
00:00:23,799 --> 00:00:28,840
Kernel modules are included in Inidra MFS, and Inidra MFS is created when you install

6
00:00:28,840 --> 00:00:30,040
Linux.

7
00:00:30,040 --> 00:00:33,599
So it's created according to the hardware that was found and makes sure that all the

8
00:00:33,599 --> 00:00:37,200
essential drivers are available while booting.

9
00:00:37,200 --> 00:00:42,240
There's also a part of the hardware that can be loaded by the plug-and-play manager.

10
00:00:42,240 --> 00:00:48,599
And this plug-and-play manager is systemd-udevd.

11
00:00:48,599 --> 00:00:54,360
So automatic on-demand device initialization is done by systemd-udevd.

12
00:00:54,360 --> 00:01:01,080
And systemd-udevd is defined by rules in uselib-udevrules.d and etc-udevrules.d.

13
00:01:01,080 --> 00:01:02,080
And that's pretty cool.

14
00:01:02,080 --> 00:01:07,279
You can customize these rules to make sure that specific actions will happen when a specific

15
00:01:07,279 --> 00:01:10,040
device is plugged in.

16
00:01:10,040 --> 00:01:16,279
So if you want a message to be logged to your syslog or a file to be created or whatever,

17
00:01:16,279 --> 00:01:21,919
if a device is plugged in, systemd-udevd-rules is what you need to do.

18
00:01:21,919 --> 00:01:27,680
That's beyond what you need to know for Linux Plus, so I won't explain it right here.

19
00:01:27,680 --> 00:01:33,480
So systemd-udevd detects devices and will load the required kernel modules.

20
00:01:33,480 --> 00:01:37,959
And there's also a manual way of doing it, and that would be modprobe.

21
00:01:37,959 --> 00:01:42,800
And if you want to interface with devices, many but not all of the devices have a device

22
00:01:42,800 --> 00:01:45,400
node file in slash dev.

23
00:01:45,400 --> 00:01:50,959
If you are going to use a hard disk, for instance, you use commands like mount slash dev slash

24
00:01:50,959 --> 00:01:51,959
sda1.

25
00:01:51,959 --> 00:01:59,440
Well, the dev sda1 is referring to your first partition, and this first partition addresses

26
00:01:59,440 --> 00:02:05,519
the appropriate kernel module to make sure that the device is initialized.

27
00:02:05,519 --> 00:02:10,880
And in this, the device nodes in the slash dev directory have a major number, and they

28
00:02:10,880 --> 00:02:12,440
have a minor number.

29
00:02:12,440 --> 00:02:16,119
And that indicates which kernel driver to use.

30
00:02:16,119 --> 00:02:21,839
And also, hardware-related parameters are stored in slash sys and its subdirectories.

31
00:02:21,839 --> 00:02:26,320
Let me show you a little bit of what is going on in this slash dev directory.

32
00:02:26,320 --> 00:02:32,639
So the part that I need you to be aware of is ls minus l slash dev slash, well, just

33
00:02:32,639 --> 00:02:33,639
slash dev.

34
00:02:33,639 --> 00:02:36,479
Here we can see all these device nodes.

35
00:02:36,479 --> 00:02:40,880
And in my list of device nodes, I'm looking up my storage device.

36
00:02:40,880 --> 00:02:45,880
I have an NVMe disk, and my NVMe disk is right here.

37
00:02:46,639 --> 00:02:48,440
And there's 259 comma 0.

38
00:02:48,440 --> 00:02:49,440
This is what matters.

39
00:02:49,440 --> 00:02:54,240
259 is the major, and the minor is 0.

40
00:02:54,240 --> 00:02:56,479
So the major addresses the driver.

41
00:02:56,479 --> 00:03:02,039
So here we can see 259 comma 1 for partition number 1, and so on.

42
00:03:02,039 --> 00:03:04,960
All of these devices have a major.

43
00:03:04,960 --> 00:03:09,720
And if you want to find out what that is, you need to have a look at the PROCFILE system,

44
00:03:09,720 --> 00:03:14,460
because in the PROCFILE system, there is a file with the name devices.

45
00:03:14,460 --> 00:03:18,139
The PROCFILE system is about the current kernel state.

46
00:03:18,139 --> 00:03:22,860
If you investigate the PROCFILE system, you can learn so much about what is going on on

47
00:03:22,860 --> 00:03:23,860
your system.

48
00:03:23,860 --> 00:03:26,820
I'm going to use less on devices.

49
00:03:26,820 --> 00:03:31,100
And there we can see that it starts with a list of character devices.

50
00:03:31,100 --> 00:03:37,500
And then there is a list of block devices, where 259 is identified as a block ext.

51
00:03:37,500 --> 00:03:42,779
And block ext, well, that addresses the kernel functionality that is required.

52
00:03:42,779 --> 00:03:47,259
So there is a kernel module that makes sure that this device can be used.

