1 00:00:00,000 --> 00:00:01,920 [No audio] 2 00:00:01,920 --> 00:00:06,690 Linux boot process. So in this lesson, we 3 00:00:06,690 --> 00:00:10,410 will learn how the system boots up. So 4 00:00:10,980 --> 00:00:14,220 I'm sure you probably wondered that when 5 00:00:14,220 --> 00:00:17,160 you press the power button on your 6 00:00:17,160 --> 00:00:21,000 laptop or your computer, then after 7 00:00:21,000 --> 00:00:23,250 a few minutes, a few seconds your 8 00:00:23,250 --> 00:00:25,650 computer come up, you get a login prompt 9 00:00:25,740 --> 00:00:27,330 and your system started. But have you 10 00:00:27,330 --> 00:00:29,880 ever wondered what exactly happens under 11 00:00:29,880 --> 00:00:32,939 the hood? Meaning you start up your car 12 00:00:33,240 --> 00:00:35,820 and ignites the spark and start up your 13 00:00:35,820 --> 00:00:38,070 car, right, but what happened exactly 14 00:00:38,460 --> 00:00:42,570 behind the scene? So I want to cover 15 00:00:42,570 --> 00:00:44,310 that because it's one of the very 16 00:00:44,310 --> 00:00:47,310 important lessons. And some of the 17 00:00:47,340 --> 00:00:49,980 things in this lesson are important in 18 00:00:49,980 --> 00:00:52,860 terms of interview, a lot of people ask 19 00:00:52,860 --> 00:00:54,990 you questions about what happen, or 20 00:00:54,990 --> 00:00:59,190 tell us the sequence of boot process. In 21 00:00:59,220 --> 00:01:01,680 this picture, you will see exactly the 22 00:01:01,680 --> 00:01:05,670 six steps that a system takes place in 23 00:01:05,670 --> 00:01:08,850 order to bring your system to a level 24 00:01:08,880 --> 00:01:11,700 where you will be able to log in. The 25 00:01:11,700 --> 00:01:15,030 first one is every time you press the 26 00:01:15,030 --> 00:01:17,880 power button on your computer, it goes 27 00:01:17,880 --> 00:01:21,780 to BIOS. What BIOS stands for is, basic 28 00:01:21,810 --> 00:01:24,810 input and output of a system. At this 29 00:01:24,810 --> 00:01:28,110 stage, it performs some system integrity 30 00:01:28,110 --> 00:01:30,690 checks, loads and execute bootloader 31 00:01:30,690 --> 00:01:34,350 program. It looks for bootloader like 32 00:01:34,620 --> 00:01:37,470 floppy disk or CD ROM or your hard drive, 33 00:01:37,500 --> 00:01:40,080 it tries to find out how to boot, where's 34 00:01:40,080 --> 00:01:42,360 it located, where do I have to go to 35 00:01:42,360 --> 00:01:45,750 bring the system up. The next thing that 36 00:01:45,750 --> 00:01:49,830 it does, it goes to MBR. Now MBR stands 37 00:01:49,830 --> 00:01:53,670 for master boot record. It is located in 38 00:01:53,670 --> 00:01:56,220 the first sector of the bootable disk, 39 00:01:56,730 --> 00:02:01,350 typically like DEV, HDA, or SDA Linux. So 40 00:02:01,350 --> 00:02:03,750 this is the first sector on your disk 41 00:02:03,810 --> 00:02:06,630 where it is located to start the computer. 42 00:02:06,900 --> 00:02:11,580 MBR is somehow like 512 megabytes in 43 00:02:11,850 --> 00:02:15,240 just bytes and sizes, very small. And 44 00:02:15,240 --> 00:02:18,870 this, it contains information about GRUB. 45 00:02:19,320 --> 00:02:21,900 The next step it does its goes to GRUB. 46 00:02:22,050 --> 00:02:25,110 GRUB stands for grand unified boot 47 00:02:25,170 --> 00:02:28,170 loader. If you have multiple kernel 48 00:02:28,170 --> 00:02:30,570 images installed on your system, you can 49 00:02:30,570 --> 00:02:33,690 choose which one to be executed. So 50 00:02:33,690 --> 00:02:35,490 there could be older version of Kernel, 51 00:02:35,490 --> 00:02:37,320 newer version of your Kernel, you could 52 00:02:37,320 --> 00:02:40,380 start it on any of the Kernel, and that 53 00:02:40,410 --> 00:02:44,820 option is given to you by GRUB. And GRUB 54 00:02:44,820 --> 00:02:47,880 configuration files are located in slash 55 00:02:47,880 --> 00:02:50,790 boot slash grub, and the file is 56 00:02:50,790 --> 00:02:53,850 grub.conf. You can modify it if you want 57 00:02:53,850 --> 00:02:56,670 to change the order of your system 58 00:02:56,670 --> 00:02:59,970 startup. The next one, after the GRUB 59 00:03:00,000 --> 00:03:02,880 comes the Kernel. The Kernel is the one 60 00:03:02,880 --> 00:03:05,160 that mounts the root filesystem as 61 00:03:05,160 --> 00:03:09,000 specified in the root equal in grub.conf 62 00:03:09,000 --> 00:03:11,310 file. That's exactly in the 63 00:03:11,340 --> 00:03:15,270 grub.conf file is, it actually execute the 64 00:03:15,300 --> 00:03:20,522 init program. Kernel executes the slash sbin, 65 00:03:20,522 --> 00:03:25,470 slash init program, then it starts 66 00:03:25,500 --> 00:03:29,700 the initial RAM disk, and initial RAM 67 00:03:29,700 --> 00:03:32,820 disk which is initrd is used by 68 00:03:32,820 --> 00:03:35,040 Kernel as a temporary root filesystem 69 00:03:35,070 --> 00:03:37,800 until Kernel is booted and the real 70 00:03:37,800 --> 00:03:41,040 root filesystem is mounted. It 71 00:03:41,070 --> 00:03:43,650 also contains necessary drives compiled 72 00:03:43,680 --> 00:03:46,290 inside which helps us to access the hard 73 00:03:46,290 --> 00:03:49,230 drive partition and other hardware. The 74 00:03:49,230 --> 00:03:52,110 next one goes through the the boot 75 00:03:52,110 --> 00:03:55,530 process is init. It looks like, the 76 00:03:55,530 --> 00:03:58,770 slash etc inittab. This is the file 77 00:03:59,130 --> 00:04:02,490 to decide the Linux run level. So if you 78 00:04:02,490 --> 00:04:04,980 wanted to boot your system in a 79 00:04:04,980 --> 00:04:06,900 different run levels, let's say there 80 00:04:06,900 --> 00:04:09,780 are six run levels, actually seven run 81 00:04:09,780 --> 00:04:12,270 levels. There is 0 for a halt, 1 for 82 00:04:12,270 --> 00:04:15,600 single user mode, 2 for multiuser, 83 00:04:16,230 --> 00:04:20,550 3 for full multiuser mode, and 5 84 00:04:20,579 --> 00:04:24,089 is unused if sorry, 4 is unused, 85 00:04:24,329 --> 00:04:27,510 5 is to boot the system in x11 and 86 00:04:27,510 --> 00:04:29,790 6 is to reboot. These are the run 87 00:04:29,790 --> 00:04:32,640 levels that are defined inside of the 88 00:04:32,700 --> 00:04:35,083 init, slash inittab file. 89 00:04:35,111 --> 00:04:44,777 [No audio] 90 00:04:44,777 --> 00:04:48,160 Once it does that, then the runlevel program 91 00:04:48,160 --> 00:04:50,400 begins to start, and every 92 00:04:50,400 --> 00:04:54,030 run level program has its own directory, 93 00:04:54,300 --> 00:04:59,970 and that directory is /etc/rc.d/rc, 94 00:05:00,000 --> 00:05:02,160 enter digit, which is run level digit, 95 00:05:02,190 --> 00:05:06,240 and .d. Every file, every boot order 96 00:05:06,570 --> 00:05:10,650 is in these files. So here are the run 97 00:05:10,650 --> 00:05:13,500 levels. We could go over a few of them 98 00:05:13,710 --> 00:05:16,800 in our Linux environment. So let me log 99 00:05:16,800 --> 00:05:19,920 into my Linux machine, clear the screen. 100 00:05:21,300 --> 00:05:24,000 I want to become root, because some of 101 00:05:24,000 --> 00:05:26,730 these files can only be accessed through 102 00:05:26,730 --> 00:05:29,820 root. So the first one is BIOS, which is 103 00:05:29,820 --> 00:05:32,280 located on the disk. The second one is 104 00:05:32,280 --> 00:05:35,190 MBR, and let's go to the Kernel, which 105 00:05:35,220 --> 00:05:38,160 is sbin/init. So we'll go etc, 106 00:05:38,640 --> 00:05:40,500 sorry, sbin/init. 107 00:05:40,500 --> 00:05:49,769 [Author typing] 108 00:05:49,769 --> 00:05:51,719 Then you have other run programs, we 109 00:05:51,719 --> 00:05:53,609 could go to the other run programs like 110 00:05:54,179 --> 00:06:00,839 /etc/rc .d/, and here you see all 111 00:06:00,839 --> 00:06:02,849 the run levels. If you wanted to start your 112 00:06:02,849 --> 00:06:05,069 computer and run level five. So let's 113 00:06:05,069 --> 00:06:06,869 see which run level we are in?who minus 114 00:06:06,899 --> 00:06:08,789 r, we are in run level five. So we'll go 115 00:06:08,789 --> 00:06:13,889 into rc5.d. And here it's 116 00:06:13,889 --> 00:06:16,439 telling it to start the console, which 117 00:06:16,439 --> 00:06:18,989 is the GUI, and start the network, which 118 00:06:18,989 --> 00:06:20,969 is network. So this is what exactly run 119 00:06:20,969 --> 00:06:23,699 level five is. And that's how your 120 00:06:23,699 --> 00:06:25,829 computer is started, you get the login 121 00:06:25,829 --> 00:06:29,579 prompt, and there are also many many 122 00:06:29,579 --> 00:06:31,709 different documentation online you can 123 00:06:31,709 --> 00:06:34,289 find out about how the system boots up. 124 00:06:34,709 --> 00:06:37,589 And of course I will encourage you to go 125 00:06:37,589 --> 00:06:40,139 look them up and understand exactly how 126 00:06:40,139 --> 00:06:41,699 Linux boot process works. 127 00:06:41,699 --> 00:06:43,264 [No audio]