Linux Kernel and Initrd Basics Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so this is part of a series there should be an annotation on the screen to the full playlist coming out a new video every week and if you watch last week's video hope you did hopefully did we worked with mounting ISO files and I gave three examples then but I downloaded another one just to show you as we get into here a little bit more I downloaded a Linux Mint ISO cinnamon I think it was version 15 or so that I downloaded and today we're going to look at a little more on the bootloader and how things start up when you start booting a Linux operating system in this case is OS so we're gonna start off with the tiny core the core current ISO because it's the simplest looking to start off with so we will mount that to the ISO using sudo mount - OH loop once again depending on your system that you may or may not need that it may auto detect that it's a loopback mount and again it should be a read-only because an ISO is basically as far as the system is concerned that's a CD and it's not writable so that's normal that warning there we'll go into that folder and again with the tiny core there's in the root directory of the ISO there's only one directory in there one folder there's no file so we'll go into that boot and we'll list out what's in there and there's two files and a folder and what these are is Oh Linux is part of the Sisley niché's suite ISO Linux is your bootloader in this case and common for CDs you know once you install Linux to your hard drive you have different boot loaders but most common right now is probably grub and then there's also lilo or something like that what grub is the most common well for CDs you're going to find iso linux to be the most common and we'll go into that folder in a second what are these two other files well this right here and these names can change from distribution to distribution but there are some common news names that they are but this is your actual Linux kernel if you're unsure again you can use the file command and give it the file name and hit enter and it will tell you right here this is an x86 boot sector so it's it's the Linux kernel you know from that there's other ways you can look at that file that we'll get into future tutorials but the file command is very helpful you look here this one this court dot GZ you're like oh it's a it's a gzip file well it's actually more than that and again the extension is mainly for the end user the computer doesn't really care too much about extensions and if we were to file that file file the core GZ it'll give us a little more information you can see here that yes it is a gzip compressed data file well what was it compressed what's inside it well it's actually it was a file called core dot CP io which is a just another type of archiving it's it's it's an image so basically we you create they created an image and then they use gzip to compress it down to make it smaller which is common gzip is not the only option when it comes to compression compressing the file systems there's actually a few different ones but you when you are creating an image for booting depending on what you have compiled into the kernel the colonel may gzip is fairly common but there's other compressions that if you don't compile that into the kernel it won't be able to extract this core GZ which more commonly will be labeled in it's Rd that's a initrd which stands for initial Ram disk which we will get into in here in a second let's go into the i/o so Linux folder and we list in here we can see a few different files the main one the first one we're interested in is the ISO Linux config so we will less that so we can look at it and you can see plain text and if you've ever messed with a grub file it's it's somewhat similar but you can see here it's the first thing it's doing when the bootloader loads because is Olynyk says your bootloader in this case it's displaying the contents of this file which we'll look at in a moment and then it's saying the default is micro core which you can see there's two labels here these are different boot options the default is micro core which is this first one here that the default does not have to be the first one in the list that's why you can indicate it here it could be the fifth one on the list but whatever you dinde kate here will be the default and it will default to that after a certain time out so you can set a timeout here and after a certain amount of time it will default to whatever the timeout I heard the default is before we start looking at our labels here let's quickly look down at the bottom here you have f1 f2 f3 f4 and then you have these other options here and you see f2 f2 those are actually other files in the current directory and those are just other messages that when you press f2 it will display this message when you press f1 it will display this message which is actually already displayed by default but if you were to go into one of the other displays you can get back to it by hitting f1 so we'll look at all those in a moment but if we look at our labels here and these two are very similar you don't really have much options with this tiny little distribution here you have your kernel which we've already said was our ZM lin a--'s file in this case again it could be called pretty much whatever you want that but whatever it's called you have to tell it in here and also you notice it says /boot because it's in the boot folder you could rename that folder something else but it's saying okay the computer will mount this iso or it basically it's going to be a CD at that point is going to look at the the CD and it's going to say ok load the bootloader which we'll get into all you know how you add a bootloader to the image in future tutorials hopefully and then it's going to say okay the kernel is this file here so if it was in the main directory you wouldn't need the boot part of this or if you called the folder something else you would go that route as well now again we started talking about the initial Rd which is the initial Ram disk now when a Linux system starts booting the bootloader is loaded and then the bootloader will take the kernel this file up here and put that in RAM and then it will take the initial Ram disk which is this file which we were just looking at and put that in RAM and what this is it is a very basic miniscule filesystem of Linux and once that's loaded to ram it needs to be load to ram so that the kernel can use files on it to mount the real filesystem and do some other stuff that the kernel can't do on its own well I don't you can create the kernel way that it doesn't need that I've read that I've never actually seen that I don't know if that's true but 99% of the time it's going to load it's going to uncompress and load this image into Ram and then it will basically start running that and then later on in the process it will mount their true filesystem which will kind of override the initial Ram disk so that's what the in the initial Ram disk is and we're going to have a lot of fun playing around with that in future tutorials but again going back down here we have filenames and these this as f2 and f3 they don't have to be called that once again this is a config file you're pointing it towards yeah that this f2 file this f3 file this f4 file and if we cut them out we can cat out the the first one is the boot message which shows up by default it was at the top of our config file there which is our default little message here for tiny core and it says right here you can press ENTER to choose an option or you can press f2 and if you were to press f2 in this case it would display what's in the f2 file or the f3 file so that's how when you boot a CD and it gives you different options that's where all those options the menus are displayed anyway and then you can run those options obviously so let's get out don't want to spend too much time on one distribution I just want to show you that they're all very similar but different at the same time all depending on how the the creator wants to organize stuff so it's basically the same thing but organized differently so we're going to quickly unmount that ISO and now let's mount the mini mini ISO which is the Debian net boot now remember when we went into the initial folder for the tiny core there was only one folder in the root directory which is boot well when we go into this ISO and list out the main directory you notice there is a lot of stuff here and one of the reasons for that is that its bootloader is and it's image it's its initial Ram disk image and it's kernel is all just put into the main directory here once again it's all depending on how the developer wants to organize stuff but again we do have our iso linux config file here and if we were to less that out to display it you can see it's actually shorter than the other one why is it shorter well because Debian the net boot CD gives you a lot more options so what they've done is broken it down with different config files so you can see the first thing this config file does is it loads the menu config sets a default but you know that the labels aren't here but because they're in another file and it's the default prompt time out to 0 which I believe if it's zero that means it never times out it waits forever until the user picks an option so let's look at that menu config file so we'll say less the menu dot config because these one's a bit bigger and it has these menu options which actually are setting up the height shift and width so it's kind of changing where things are going to be displayed rather than just displaying a text message we have a menu title in here and then we start including other config files you can see there's a lot of config files because you have a lot more option with this CD and the only label in here is the help menu because the Debian CD actually has sub menus with options in them too so they've just broken them all down into different config files and they include them so including them is basically like typing them here they could technically all be in this one file really long file but they decide to break it up to keep it a little more organized so I'm going to look at this one in particular this ad text if I less that out you can see that we have two main options here we have expert and auto they have labels here and you they also have just like before we have our Linux kernel which in this case is just called Linux which we'll look at that in a second here you notice there is no folder because everything is inside that root directory on the ISO on the CD when you're booting it then we have our appending here which within it has a few different options for the boot process but the main one we're interested in and most of these tutorials is again the initial in it Rd the initial Ram disk and again this is it's called as I said most commonly it's going to be labeled in it are dgz or just in it Rd I think in some cases it might be in it FS or Ram FS or something like that technically can be called whatever you want but you have to make sure you put it into your config file properly let's exit out of that again you can see those files in this main folder and again if I was to use the file command and say Linux it says that it is a Linux boot sector well it says the Linux file is a boot sector doesn't say that if it's a Linux boot sector and if I was to file our own it Ram disk or initial Ram disk you can see here again this one is a GC compressed data file but it was an it Rd it was the name of the eyal so once we extract that out there then we can run file on again it will tell us what type of compression I'm going to guess that it's probably a listed IP cpio file a archive but I don't know for sure every zijn we saw that before I believe is because the original file was had that extension this one does not but once we uncompressed what we're going to do in a future tutorial we could run a file on it again and find out more about and there's actually other programs that we can actually scan through these files with so again very similar as far as the bootloader goes but as far as where they put the files and name the files very difference don't let that confuse you basically always look for this iso linux config file and it will tell you what where the kernel is and the initiative so let's get out of that image let's unmount that let's mount the mint ISO now and we'll go into the ISO folder and you can see once again this one's different not everything's in the root directory which i think was kind of sloppy looking but whatever it does have a boot folder but it's got other stuff again also with the Debian one some of these are like this one this mint for Windex see these are files for and this auto run those are for Windows you put the CD into Windows it will auto run if we probably that mint for Windows so yeah if you were running a version of Windows that allowed the auto run I think they somewhat remove that basically that's an install process for Windows users but again we're interested in the iso linux folder so we're going there and we'll look at here and again this one has a lot less options than the the net boot for debian let's look again what's less iso config a lot of stuff going on in this config file a lot of this is just making the splash screen you know making the menu look pretty we have it it's default is this menu option it's timeout is set to this we have our background is a JPEG which was on the sea and we're title and then we have like color settings for different portions of the menus and then we get into our our stuff here and here we can see our kernel for Linux Mint is inside Casper seems going to be for Ubuntu and it's called vm li and uz that's our kernel and that's a very common name for it sometimes it will have more information especially once you install to your hard drive well maybe what version of the kernel it is will say like - 3.3 or whatever kernel version it is but again it doesn't matter what you call it as long as in your config file you point to it again you have a lot more append options here because you have lots of different options in here and again of course our initial Ram disk is also in that Casper file and it's called a nish Ram disk dot LZ in this case so let's quit out of that go back a directory go into our Casper folder here list and here is our kernel here is our Ram disk our initial Ram disk let's file that out and you can see it's still it's saying that it's a GZ compression I don't know if it's a different type of GZ compression since it's labeled LZ but again it all depends on what's compiled into the kernel that you're allowed to and I can look more into that I'm just showing you in this tutorial how different things are set up showing you where the kernels are and where the RAM disks are but you notice if we list this out and we bring it up you can see there's a file system dot squash FS here which is another type of file system and it's 847 megabytes that is your actual root filesystem once your full operating system is loaded and on a CD in this case what happens is it's going to load your boot loader which is going to load your kernel to ram and this initial Ram disk and then from there it's going to mount this file system but not uncompress it's when you're running a live CD it's pretty much uncompressing on the fly in most cases if you were to completely uncompress this it's going to be probably about three times its size so it's going to be probably over two gigs once it's installed to your hard drive technically you could put the full operating system inside your initial Ram disk and load it to ram and there are operating as well the last two operating systems did that are our tiny core and our Debian net boot CD but those are both very small images you could technically reconfigure Ubuntu or Linux Mint to load the full operating system to ram then you can take the CD out and unplug the flash drive it will probably be pretty fast because everything's already uncompressed in RAM but you got to remember it's in this case gonna be taken up about two gigs so if you have a four gig four gigs of RAM you only have two gigs to work with which is still plenty if you're just you know working with a live CD but you could run out of space very fast also to uncompress that and copy it all to ram will take a couple of minutes so your boot time will be a couple of minutes so but talking about that let's go in to will unmount that and we'll mount our slit as iso and we will go into our boot folder list in there and you'll see our seal as I was saying earlier here's our kernel and it's version this is also a kernel image here if I file that out BeeZee image and if I list them out they're both the same size it almost looks like they have the same kernel on there twice maybe I haven't looked into that I know is that right before I started recording this tutorial and if we were to go into our iso linux folder we can see we got a bunch of config files but we'll do our main ISO config file here it also has some formatting for the menus and we get down here and we start looking at some of these and if we look here you can see our kernel is the beezy image file so I'm not sure why they have that other image file on there but you notice their initial Ram disk is in their boot folder but that it says root file system for GZ and then it says comma and it does three and two and one and so they actually have four different initial Ram disk now why is this now I've done tutorials on slits has in the past and it was an older version of slit as this is slit as 4.0 and I did tutorials on version 3 and with version 3 they had different distributions of a different different I think they call them Kooks when it comes to slit eyes they had a image that was like a just under 10 megabytes which was just a shell one that was 15 that did just X then they had one that was probably about twenty that did you know X in a browser and then around 30 megabytes which was their full operating system well what they did with version 4.0 is that you can basically tell it what file systems to load over top of each other so this is loading the full desktop with all its files the next option is gtk only so it's basically the GUI but without the desktop interface I believe so you notice that one is missing here so basically jeez and then what will go down will say just X so it has X but really no other GUI applications installed which is just four and three and then we have their base which is just four so basically instead of having all these different images ISO images they put them all on one so you still only have a 35 megabyte CD for the full operating system but when you get to your boot menu you can choose whether you want to load and again this operating system so small it does load to ram at least at the default setting i'ma look more into that in a second if we want just the shell with no GUI stuff it only loads file system which would is our initial Ram disk for well if you want just X well it's going to load for and then once for is uncompressed Sun going to uncompress 3 well if you want X with some gtk stuff well it's going to compress all three of these will do 4 and then 3 basically put them all in Ram on top of each other mounting them all up there and there are options they have some other ones where they boot from I guess not in the seed you also also have low Ram versions of slit as that don't uncompress to ram at all it will actually run it off like other live CDs so anyway I I thought that was really neat the way that slit has decided to do that instead having all these different CDs it's so small this we're going to be very rare cases where you have some sort of media that will hold 8 megabytes but not 35 so why not put them all on the same disc it doesn't matter you can choose what loads to Ram then you take the disc out so if you want that really lightweight 10 megabyte shell only you choose that and the disc comes out it's all in RAM and it runs so I thought that was really neat so let me quit out of here rest is pretty much the same by the way there's that splash JPEG so when this distribution boots up it will display that image and yeah you got other options there you help menus and stuff like that it has a few different language options but all from those config files which are plain text and here are all those files so if I list these out real quick you can see that if we were to just do the base OS it's actually I said it was about 10 that would be the full ISO if they had that with all the boot loaders and everything but the actual file system is just under 5 megabytes so you would have a full shell just under 5 megabytes if you want to just X you would have another it would do the four and then on top of that add eight and then if you wanted gtk it was another six megabytes on top of that and then if you want the full desktop web browser and a bunch of other tools is another 13 megabytes on top of that so genius the way they did that kudos to them and that's kind of this tutorial is kind of long but I just wanted to show you all the different ways that you can do the same thing basically and how different developers decide to organize things differently and what you can do and really point out that where what the kernel is and what the initial Ram disk is um because you would see those will probably a lot if you've ever messed with your bootloader configure and maybe you didn't know exactly what what is this an ish Rd well it's the initial Ram disk and it's basically a very miniscule school simple Linux file system that's loaded to ram that allows the rest of the operating system to load because the kernel itself needs tools which are in going to be in that file system to load and we're going to be looking at that stuff a lot more in the future so I know story I don't know how long I've been going for but it's probably been kind of long I hope you enjoyed it be sure to subscribe you know be sure to check out the full playlist again a new week new video every Monday for a while now so the playlist there should be an annotation on the screen if you're watching the playlist and you get to a video that you can't access it's because it hasn't published yet next week it will be published I've got to say that our people will ask why they can't access it and we're going to be doing a lot of uncompressing these files manipulating them recompressing them different types of installs but I want to get show you what these are and that's that's I love this sort of stuff I love small distributions I love tweaking around with them and I hope that you enjoy it as well if you do if you if you like these type of tutorials we're going to get more in depth in future tutorials be sure to like this video so that I know you guys are enjoying it comments are great below questions probably not the best place put them in the comments check out my website for a link to the IRC channel which is a good place to ask questions I am far from being a professional on on this sort of stuff but I know a little bit and I'll be glad to help you in any way I can and be sure to subscribe and check back next week for next week's video thank you for watching please visit films by Chris calm that's chris decay there should be a link in the description and I hope that you have a great day you
Info
Channel: Kris Occhipinti
Views: 50,303
Rating: 4.9765053 out of 5
Keywords: Computer, Linux (Operating System), bash, script, Bash (Unix Shell), program, shell, Cpio, Ubuntu, linux, tutorial, Arm Cpu, Basic, unix, Squashfs, admin, Linux Kernel (Software)
Id: boxF9t29xZQ
Channel Id: undefined
Length: 27min 32sec (1652 seconds)
Published: Mon Jan 13 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.