00:00:00 - Okay, welcome to section 102.2. In this nugget we're
00:00:04 - going to talk about installing and managing boot loaders or boot managers.
00:00:08 - We're going to talk about two. One is LILO or LILO -- I think LILO, I'm
00:00:12 - not sure exactly how to say it. The other one is GRUB. Now
00:00:15 - LILO is very rarely, if at all, used anymore. But you may run
00:00:19 - across a couple situations that you find LILO to be the
00:00:23 - installed boot manager. So we're going to go over that, even if briefly,
00:00:26 - just so that you understand how to manage that. And then the LPIC,
00:00:29 - the LPIC
00:00:31 - Class actually specifically mentions GRUB as the boot loader
00:00:35 - that you should be able to configure. So we're going to go over that in some
00:00:37 - length, and lastly we're going to talk about how to back up the master boot
00:00:41 - record or the MBR. All right, so let's look at a computer
00:00:45 - and we're going to try and take a peek at what LILO would look
00:00:48 - like if you run across a computer with it installed.
00:00:52 - Okay, if you run across a computer that has LILO installed, generally the
00:00:55 - configuration file is stored in a file called /etc/lilo.conf,
00:01:00 - all right. It'll look something like this. Now it looks similar to some
00:01:05 - of the GRUB stuff that we saw in a few nuggets back and that we're
00:01:08 - going to look at here in just a couple minutes. But let's go
00:01:10 - over what's talked about here, all right. Boot is what device it's
00:01:14 - going to boot from. In this case, it is SDA, the first serial
00:01:18 - ATA or SCSI device, so A. Map is what
00:01:23 - the LILO command actually creates a map file to say what's
00:01:27 - mapped where. This is generally where it's kept, you just leave that alone. Install, this is
00:01:31 - the default and generally leave this boot.b as
00:01:36 - the default. If you leave install off, it's going to default to that
00:01:38 - anyway. Prompt is whether or not it prompts the user if, you know,
00:01:43 - to even say, hey, do you want a choice or do you just want me to boot directly. So
00:01:46 - generally you see prompt just in case you want to have a couple choices.
00:01:49 - That leads us to the timeout. It'll time out and boot the default in
00:01:54 - 50 seconds, in this case. You can make this however long or
00:01:56 - short you want. The message is neat. It'll add whatever text
00:02:01 - is in this message to your boot screen. So you can have a file
00:02:04 - called boot/message that says, like, Welcome to Sean's computer, please
00:02:08 - be nice, et cetera, et cetera.
00:02:10 - And then LBA talks about the type of drive. It's an
00:02:12 - LBA drive using large blocks so it can address the entire
00:02:15 - drive. Default is what default label it boots after that timeout
00:02:21 - at 50 seconds or, you know, or no timeout at all if
00:02:23 - you don't have a prompt thing there. It's going to boot the label
00:02:27 - Linux by default, which you'll notice down here. So let's move on. We have two
00:02:30 - different operating systems or two stanzas that we've defined
00:02:33 - here. The first one is vmlinuz-2.6.28-11-generic.
00:02:37 - This is the kernel, the kernel image
00:02:42 - and that is specified as to where it's located. This boot directory
00:02:46 - is located on this SDA device, right. So that's where it's
00:02:51 - at. Label again, Linux we talked about, the initial RAM disk
00:02:55 - we talked about a few nuggets back what that means, and that
00:02:58 - shows where it's at. It's stored in this boot directory. Read-only
00:03:02 - mean it's going to, it's going to mount that root disk --
00:03:06 - not that root disk, that RAM disk -- read-only along with the kernel. And then the
00:03:10 - root device, /dev/sda1. That's the actual -- that's where
00:03:13 - this boot directory is located. Again, on hard drive one, the
00:03:16 - first hard drive, is where this
00:03:20 - LILO is going to be installed and then on this partition
00:03:24 - is where it's going to find this boot folder. Does that make sense? All right.
00:03:28 - So that's the stuff we specify in this, and then this is just an example
00:03:32 - of what a DOS image. So you had DOS6 installed on the
00:03:36 - fifth partition, the first extended partition, so /dev/sda5.
00:03:39 - It just gives it the label of DOS, and we'll call it
00:03:44 - other because this should be listed as long as this is an active
00:03:47 - and bootable partition, all right. So that's what our config
00:03:50 - file looks like.
00:03:52 - And to install it, basically you just type LILO. It will go through
00:03:57 - and it'll give us a couple warnings, all right. The initial RAM disk
00:04:00 - is too big to fit between the kernel and the 15M-16M
00:04:04 - memory hole. This is a limitation on a lot of older computers,
00:04:07 - and it's working around. It's saying that okay, we'll just assume
00:04:10 - that BIOS supports this and most likely BIOS does, depending
00:04:13 - on, you know, how old your operating system is, your
00:04:16 - computer hardware is. But what it's done, it's added, it says added
00:04:20 - Linux ?, right. It doesn't know what version
00:04:24 - or what kind of Linux, it's just Linux. It didn't add DOS because
00:04:28 - /dev/sda5 where I said DOS is located doesn't really
00:04:31 - have DOS installed. I wouldn't even know how to begin to install
00:04:34 - DOS anymore. But it would just add another menu option to
00:04:37 - that. And then to access that once the computer boots
00:04:41 - up, it's as simple as hitting the tab button. It'll give you all
00:04:45 - the different boot options you have and you can add kernel
00:04:47 - flags at the end, all right. It looks pretty similar to GRUB when it boots
00:04:50 - up but much, much simpler. And basically, that's all you need to
00:04:55 - know about LILO. If you come across one, that's how to configure it in
00:04:58 - this file, that's how to install it on the master boot record, and
00:05:01 - then when it boots up you'll see a little prompt you can hit Tab to
00:05:05 - see all the different boot options. And that's LILO in a nutshell.
00:05:08 - But let's move on to GRUB, because GRUB is the Grand Unified
00:05:12 - Bootloader, and that's what's really focused on in the
00:05:16 - LPIC exams and pretty much every computer you're going to be
00:05:19 - managing now. So let's talk about that next.
00:05:22 - All right, GRUB is a little more extensive. Well it can be configured
00:05:24 - to boot from a floppy drive and all that kind of stuff. The
00:05:27 - menu or the configuration file is actually almost always
00:05:31 - stored -- let's open it up and look --
00:05:35 - in the -- not et cetera -- in the boot directory.
00:05:39 - Inside there there's a GRUB directory and there's a file called menu.lst.
00:05:42 - Now it's important to know this file is generally
00:05:47 - where it's kept but in some systems they do a symbolic link to like
00:05:51 - etc/grub.conf or boot/grub.conf. This is generally
00:05:56 - the actual file where it's kept.
00:05:58 - So if we edit this, we see well a bunch of options. Hiddenmenu means
00:06:02 - it doesn't show you the menu by default. Default is actually
00:06:07 - telling which stanza or which group, which one of these stanzas
00:06:12 - down here is the default that it boots to. Now it's important to note
00:06:15 - that zero is the first one. Again, if it said default one that
00:06:20 - would actually boot the second stanza by default. So zero
00:06:23 - is the first stanza. Timeout is how many seconds it gives us
00:06:27 - to pick if we want something other than the default. All these
00:06:29 - can be changed, of course. Now down here we see all these different
00:06:32 - stanzas or boot options. Now what I have, I have a couple
00:06:36 - different versions of the kernel -- every kernel. A new kernel
00:06:41 - would require a new stanza. You'll see this is the version I'm running
00:06:44 - right now, 2.6.28-16, and it's
00:06:48 - created, when I installed, that two stanzas. Now the difference
00:06:53 - between these two, this one is generic, this is the title that
00:06:56 - shows up, and you'll see this is one that says the same thing but
00:06:59 - in recovery mode. The difference is in what flags they put
00:07:03 - at the end of the kernel. So this long kernel which actually
00:07:06 - wraps around, you'll see it specifies the root device
00:07:10 - by the UUID, which we talked about before. But
00:07:13 - it could also just use,
00:07:16 - it could also do something like if you look down here, Windows
00:07:19 - just specifies a hard drive partition. But back up here the root
00:07:23 - partition is there and these are the kernel options in the
00:07:27 - standard boot. Read-only is how it mounts the kernel in the
00:07:31 - kernel file right here. Quiet means it doesn't give
00:07:35 - a whole bunch of text on the screen for us, and splash means
00:07:38 - that it gives us that fancy Ubuntu splash screen, all graphic
00:07:42 - and pretty. Then the init RAM disk is right here. Now
00:07:45 - let's at the second stanza, which is recovery mode is what
00:07:49 - they call it. We learned a few nuggets back that recovery mode and
00:07:53 - run level 1 are generally the same thing. So basically
00:07:56 - this is going to boot into run level 1, and how it does that
00:08:00 - is with the kernel flags. Instead of ro quiet splash,
00:08:04 - it's ro and single. Single is the command that it, you know,
00:08:08 - it's been compiled to boot into single user mode or run level
00:08:12 - 1. So that's the difference between these two stanzas. Now the
00:08:16 - same exact thing for this older kernel that was upgraded. Here
00:08:19 - we have kernel just a different revision, but again all the
00:08:22 - same things are in here single, single user mode, et cetera. Let's scroll
00:08:27 - down a little bit and show you two more things. This memtest86+,
00:08:31 - this is a tiny little, I guess it's a complete
00:08:36 - operating system. But this is in a lot of Linux distributions.
00:08:39 - It's a tiny little operating system that boots up and its sole purpose
00:08:43 - is to test RAM. Very useful if you're questioning your
00:08:46 - RAM or if you have a new server a lot of times it's good to
00:08:48 - run that just to check the memory. So that shows up as a menu
00:08:52 - option and it boots the system strictly right into that. And then
00:08:55 - we've also added this other one -- Windows. And now dual boot systems
00:08:59 - are pretty common. It's important to know that GRUB can boot
00:09:02 - a multitude of operating systems, and this is a very simple
00:09:06 - example of what a stanza booting Windows would look like. Again,
00:09:09 - the title is just an arbitrary thing. We can, you know, anything
00:09:13 - we do here is can name it Windows XP or whatever you want
00:09:17 - to call this, whatever it might be.
00:09:19 - Root is where the partition is that has the Windows install.
00:09:23 - Now Windows generally only has one partition. That's, you know, the
00:09:26 - C drive, if you're a Windows person. And this says hd1,
00:09:31 - which is the generally the second hard drive. Again, that zero, one
00:09:35 - thing we have going, and the first partition. So this would be an
00:09:38 - example if I had Windows on a separate hard drive, the second
00:09:41 - hard drive -- this is what it would look like for the root. And
00:09:43 - then chainloader +1. This is because Windows is a
00:09:47 - little bit finicky and generally it wants its own boot loader. So
00:09:50 - what GRUB does then is it loads the Windows boot loader that's on the master
00:09:55 - boot record or on the first couple, first sector on this particular
00:09:59 - partition. Now there are some other options if Windows won't boot
00:10:02 - quite right, but that's not really the focus of this. This is
00:10:05 - of this, you know, I mean this is LPIC training, this isn't Windows
00:10:08 - training. But this is how you would start Windows. This is a GRUB
00:10:11 - stanza that would do that. A lot of operating systems,
00:10:15 - if they detect Windows, they will automatically add a stanza
00:10:17 - like this to GRUB. It's pretty easy to detect and to add to
00:10:21 - it. So that's what a GRUB thing looks like, and let's say
00:10:26 - we wanted to make changes and stuff. It's always -- now some changes
00:10:29 - require you to reinstall onto the master boot record,
00:10:34 - the MBR; some don't. But let's go ahead and quit this. The way to
00:10:38 - install it onto a master boot record, or let's say you want
00:10:41 - to install it on, you know, a different device like a floppy drive
00:10:44 - or something, what you would do is run the command grub --
00:10:47 - I need to run it as root, though.
00:10:51 - Grub-install and then the device you want to install it on. Now again,
00:10:55 - we -- the device is going to be for our case, it's going to be
00:10:59 - /dev/sda, which is the first SCSI or
00:11:04 - serial ATA drive, so A is the first one. So sda.
00:11:09 - That's hd0, if you were paying attention inside the grub.lst
00:11:14 - command. Anyway, you type that and it's going to
00:11:18 - give you this, what it found here. Installing GRUB to sda
00:11:22 - or hard-drive zero like we just talked about. Installation finished.
00:11:26 - No error reported. This is the contents of the device map, okay.
00:11:30 - What it does is it maps out a file the grub installed in this. You
00:11:33 - don't need to do this. And it found these drives. Now you'll notice it didn't find
00:11:37 - my Windows drive, because quite honestly I don't have Windows on this
00:11:40 - virtual machine. I just made that up so that you would
00:11:42 - see what it would look like. But it would find this other hd1,
00:11:46 - if we had actually had a Windows installed.
00:11:49 - So if any lines are incorrect, fix it and rerun the script 'grub-install'. So it gives
00:11:52 - you feedback to make sure it's all installed properly. We just
00:11:55 - put the GRUB boot loader on the master boot record and it's
00:11:58 - pointing to again, this GRUB boot thing on the root directory in --
00:12:04 - or on the boot directory on that, on that root that we specified
00:12:07 - inside. So it's a little bit confusing, but what you can do
00:12:11 - is play with it. And the scary thing is if you play
00:12:16 - with it, though, you can actually write bad stuff to your master
00:12:19 - boot record and not be able to boot anymore. That's going to bring us
00:12:22 - to the very last step, the last thing I want to show you.
00:12:26 - It's important to understand how master boot records and boot loaders work,
00:12:30 - and the best way to do that is to play around with them. It's
00:12:32 - just a great way to learn. But before you do that, you should
00:12:35 - have a way to
00:12:37 - restore things if it goes bad. So let's clear this screen. What I'm
00:12:40 - going to do is show you how you can back up your master boot record.
00:12:46 - The first thing you want to do is make sure you're backing up
00:12:49 - the right master boot record. Especially if you have several
00:12:52 - hard drives, you're not exactly sure what the name of the
00:12:55 - hard drive is. For example, an IDE drive is going to be generally
00:12:58 - dev/hda, whereas a serial ATA or SCSI
00:13:02 - drive is going to be dev/sda. So run the mount command.
00:13:06 - Just mount and it will show you what is mounted on the system. Now you'll
00:13:10 - see right up here,
00:13:12 - dev/sda partition 1 is mounted on root, all right. So we
00:13:16 - know that our root partition is on SDA, and that's what we're going
00:13:20 - to back up. So that's just, the mount is a nice way to double-check,
00:13:24 - especially if your GRUB command file or your GRUB configuration
00:13:28 - file uses that UUID, that Universally Unique Identifier.
00:13:33 - Sometimes you don't know what kind of drive that's
00:13:35 - pointing to. So looking at and to see what is actually mounted on what device is
00:13:39 - a great way to make sure you're backing up and writing to the
00:13:41 - correct hard drive. So anyway, we know that. Now we're going
00:13:45 - to back it up. Now we're going to use another Linux command
00:13:48 - you may not be familiar with, but it's called dd. And this
00:13:52 - basically just writes sector to sector or sector
00:13:55 - by sector write to whatever you want, to and from. We're going
00:13:58 - to do, I'm going to write this out and then explain what it is. So
00:14:02 - if=/dev/hda
00:14:11 - of=/root/backup.mbr
00:14:17 - bs=512
00:14:22 - count=1.
00:14:26 - So run the command. Ooh, yeah, no such file or directory.
00:14:33 - See what I did? Good thing I checked
00:14:38 - to make sure.
00:14:40 - If you look up here, see I made the mistake I was just teaching you how not to make.
00:14:43 - And I'm actually going to leave this in the video to show you how easy it is to make mistakes.
00:14:46 - But sda is my hard drive, not hda. So the device sda is what I'm going to
00:14:53 - up. So we'll hit Enter. Oh, permission denied. I need to be super
00:14:56 - user to do this.
00:15:00 - Okay, so let's look and see what's happened. First of all, I typed
00:15:03 - the wrong type of hard drive, and I should have not because
00:15:07 - I just showed you how to avoid that. Then I went and I typed the
00:15:09 - correct thing, right. Dd Input file, it considers sda a
00:15:14 - file. So the input file is /dev/sda, that first hard drive is a serial
00:15:20 - ATA drive. OF is output file. I know it looks like if
00:15:25 - and of, but it's output file; equals -- I just put it in a file called,
00:15:29 - in the root directory called backup.mbr, all right. It
00:15:33 - doesn't matter what you name the file or where you put it, as
00:15:35 - long as it's somewhere backed up. BS is block size, okay.
00:15:39 - How big is the actual block size and 512 is the
00:15:43 - size we want for the master boot record. So block size equals
00:15:46 - 512. And count=1. Now we're just going to backup
00:15:51 - one block, that first back up or that first, that first
00:15:56 - sector there, that first master boot record is all we're backing up.
00:15:59 - If we left this off, it would back up the entire hard drive
00:16:03 - to this file called backup.mbr.
00:16:05 - So it's important to put that count there at the end, all right. And then
00:16:08 - of course I wasn't root, so it gave me permission denied, but when I actually was it
00:16:12 - did all the proper commands. It says one record in and one record
00:16:16 - out. 512 bytes copied. So now if we --
00:16:22 - I am going to become root just to clarify things. So now I'm root.
00:16:26 - CD to my home directory. Inside here you're going to see
00:16:31 - a file backup.mbr. So that's a backup. You can copy that to a floppy
00:16:35 - drive somewhere in the network. It's generally safe here on
00:16:38 - the hard drive because we're just going to be messing with
00:16:40 - the master boot record. Okay, now let's say we totally mess up our
00:16:44 - computer, we've written like an image file to the boot record
00:16:48 - instead of this backed up MBR file. What you can
00:16:50 - do is do it backwards. Okay, now I'm not, or I'm root now so I don't need to
00:16:54 - type pseudo, but we'll use that same dd command. So dd, but
00:16:59 - this time the input file is going to be
00:17:03 - this file that we're in here, backup.mbr and our output
00:17:08 - file is going to be /dev/sda. Again, that sda
00:17:13 - is the hard drive that we're booting from. Block size equals
00:17:18 - 512, count=1.
00:17:22 - Do this, it's going to copy right to our boot directory, or right to
00:17:27 - our master boot record on our initial hard drive. Now since playing
00:17:31 - with the master boot record is really about the easiest way
00:17:35 - to learn how to do it, playing with GRUB, I would suggest
00:17:38 - now that you know how to back it up and you can restore it,
00:17:40 - to play with it to learn it a little bit better. Now you can restore
00:17:43 - the master boot record from a live booted
00:17:45 - CD or like from a live booted floppy. As long as you know which
00:17:49 - hard drive you're writing to and where the file is kept, it's
00:17:52 - not difficult to fix whatever you might mess up in your
00:17:55 - master boot record. All right, so let's go back over, make sure
00:17:58 - we covered everything, and then we'll move on to the next nugget.
00:18:02 - Okay, so we covered LILO. Again, just a little bit just so
00:18:05 - the you know how to manage things if you come up to it. And
00:18:08 - realize that it writes everything to the master boot record,
00:18:11 - all right. We can back up a LILO boot record the same way that we
00:18:14 - did the GRUB record.
00:18:16 - GRUB is the most largely used
00:18:20 - boot loader. It's the Grand Unified Bootloader. And we showed how to
00:18:24 - do that, how to set up stanzas, how to boot multiple operating systems
00:18:27 - with it. And then very important, I showed you how to back
00:18:31 - up your master boot record. When we did that, we learned a couple
00:18:34 - commands. We learned the dd command, which is really, really
00:18:38 - important; and showed you the mount command. And when you run
00:18:43 - mount with no flags or nothing at the end, mount just shows you what's
00:18:47 - currently mounted. So that's a great way to make sure that
00:18:49 - you're backing up and restoring to the proper hard drive. All right,
00:18:53 - so you are now experts on installing boot loaders and with special
00:18:58 - focus on GRUB because the LPIC requirements specifically
00:19:01 - mention GRUB as the boot loader that you should be comfortable
00:19:04 - configuring. Okay, I hope this has been informative for you and
00:19:08 - I would like to thank you for viewing.