What is the startover manager?
The boot manager is a program stored in the disk start sector, for example, the MBR (Master Boot Record) of the hard disk, after the system is started, if the system starts from the MBR, the Bios (Basic Input / Output System) will Control is transmitted to the MBR. The program stored in the MBR will then run. This program is called a starter manager. Its task is to transmit control to the operating system to complete the startup process.
There are many available boot managers, including GNU GRUB (Grand Unified Boot Loader), Bootmanager, Lilo (Linux Loader), NTLDR (Boot Loader for Windows Nt Systems), and so on. Below I will discuss GNU GRUB and how it is used.
What is grub?
GRUB is a powerful launch manager that loads a variety of operating systems such as Windows, DOS, Linux, GNU Hurd, * BSD, and more.
Currently, LILO is the most popular launch manager that is used to manage boot of multiple systems. However, if you use Lilo, you must remember that when you change its configuration or install a new kernel, you must re-run Lilo. Moreover, LILO flexibility is also inferior to GRUB.
GRUB is flexible. Its latest version, 0.5.96.1, supported file system includes ext2 (a file system used by Linux), FFS (Fast File System Used By * BSD UNIX), Reiserfs (a new log file system developed for Linux, In the 2.4.1 kernel, Minix (a vintage file system developed for the Minix system, is also used in early Linux). Use GRUB, you don't even guide the operating system, you can "see" to these file systems For example, if you want to see the date and time stored in a text file, do not want to guide the entire operating system, you can use the GRUB Shell (prompt "GRUB>"), type the following command:
GRUB> CAT (Partition Number) /Home/god/2003106110531.htm.txt.
You can see all information related to the file, including date and time.
GRUB's best application is that you can easily guide any kernels not on any partition in the list. For example, if you don't add a newly compiled kernel in the launch list, you need to boot it, you can add it first in the list, and then use it after you restart. However, after using GRUB, you can simply load the required kernel image with the GRUB Shell.
Now I will explain three basic steps using GRUB: compile, install, and configure.
Step 1: Compile and install GRUB
You can download the source code of GRUB from ftp://alpha.gnu.org/pub/gnu/grub.
The compressed document can be unpred by the command "TAR-XVZF 2003106110531.htm.tar.gz". The file I got is Grub-0.5.96.1.tar.gz, so I do this:
# TAR-XVZF GRUB-0.5.96.1.tar.gz
This command puts unstopened files and directories in a directory called GRUB-0.5.96.1. Run the following command now:
[root @HEAVEN ~ / GRUB-0.5.96.1] # ./configure
If you want to customize GRUB, make it a popular file system and support for the NIC, or delete the NIC you don't need, you can run the following command:
[root @HEAVEN ~ / GRUB-0.5.96.1] # ./configure --Help This command will output all command options. You can now add or delete support for specific network cards using the -enable and -disable options. (Note: GRUB supports network boot)
In order to start the compilation process, type the following command:
[root @ heaven ~ / grub-0.5.96.1] # make
In order to properly install all files, type the command:
[root @HEAVEN ~ / GRUB-0.5.96.1] # Make Install
To this, you have already prepared for installing GRUB.
Saving GRUB's related files is not a good idea in a directory such as / boot / grub. To do this, follow these steps:
1. By default, all files will be installed in the / usr / share / grub / i386-pc or / usr / local / share / grub / i386-pc directory, depending on your shell variable settings.
2. Create a directory called / boot / grub, then copy the following files to this directory:
STAGE1
STAGE2
* _Stage1_5
I will explain these files later. At the same time, GRUB (possibly in / usr / sbin or / usr / local / sbin directory) is also copied to the / boot / grub directory.
Before installing GRUB, you need to know how GRUB identifies your hard drive and partition information. First, the count starts from 0 instead of from 1. In Linux, your first hard disk connected to the main controller is called "had". "HD0" in the grub. Similarly, in GRUB, your first floppy drive is "fd0". Thus, the first, second, and three partitions on the first block are "HD0, 0", "HD0, 1", "HD0, 2", respectively. Note: The comma is the necessary part of the GRUB partition nomenclature.
In order to integrate the partially spaced portion, it is necessary to use parentheses. For example: (HD0, 0) (HD0, 1) (HD0, 2), etc. (HD0, 0) is the first partition on the hard disk. Similarly, (HD1, 5) is the sixth partition on the second fast hard disk, (HD2, 0) is the first partition on the third hard disk.
MAY Take a long time.
Step 2: Install GRUB
Installing GRUB can be divided into three separate steps:
1. Install "Stage1" into the MBR.
2. Set the address or location of "stage2".
3. Set a menu or option to determine which operating system is started.
Use the following command to start installing GRUB.
[root @HEAVEN / BOOT / GRUB] # ./grub
This command detects the hardware device according to the setting of the BIOS while generating some output information. This will take a long time.
END_REQUEST: I / O Error, DEV 02:00 (FLOPPY), Sector 0
GRUB VERSION 0.5.96.1 (640K Lower / 3072K Upper Memory)
Note: Although it is very surprising, GRUB does have a simple interface - just like supporting row. Tab lists the list of possible commands. In other cases, TAB will list the device or file name. It will be very amazing. Similar to the following prompts appear:
GRUB>
Sorry for forgetting where I got it, if you know, tell me, thanks
Now, I assume that you install Linux in the first extension partition of the first hard disk or / dev / hda5. Remember the grub's naming rules, change the above name to (HD0, 4). Type the following command: GRUB> Install (HD0, 4) / boot / grub / stage1 (hd0) (hd0, 4) / boot / grub / stage2 p (hd0, 4) /boot/grub/Menu.conf
Let us now analyze the details of this order.
INSTALL
A built-in command tells GRUB to install (HD0, 4) / boot / grub / grub / stage1 to the main boot record of the HD0.
(HD0, 4) / boot / grub / stage2
Tell the GRUB Stage2 Image of the image.
P with the following options: (hd0, 4) /boot/grub/Menu.conf
Set the configuration file for the display of the menu. I will discuss the structure of this configuration file.
Below is a summary of this command usage:
1. INSTALL
2. SOURCE_OF_STAGE1
3. WHERE_TO_INSTALL
4. SOURCE_OF_STAGE2
5. P Source_of_configuration_file
Now, you have completed the basic installation work on your hard drive.
Installation on the floppy disk:
In order to install GRUB on the floppy disk, you have to use the "DD" command and understand how it works. To make a GRUB boot disk, you have to put the Stage1 and Stage2 files in the start sector of the floppy disk.
Install the Stage1 to the floppy disk:
Insert a formatted floppy disk, type command:
[root @HEAVEN / BOOT / GRUB] # DD if = stage1 of = / dev / fd0 bs = 512 count = 1
The detailed description of the command is as follows:
IF = Input File
I., stage1
Of = Output File
I., Floppy Drive (this May Be DiffERENT ON Your Computer)
BS = bytes to read and write
Here it is 512 bytes.
Count = how much Times to Perform this Operation
Blocks to the target address each time you copy the number of "BS".
Install the Stage2 to floppy disk
[root @HEAVEN / BOOT / GRUB] # DD if = stage2 of = / dev / fd0 bs = 512 seek = 1
The steps here are the same as the STAGE1, except for a SEEK option. The Seek option will be tonified. For example, the value of the BS in the command is 512 so that seek = 1 means that the first 512 bytes on the floppy disk will start from 513 bytes. This will make the first step not override the first 512 bytes of Stage1.
Now you have completed the basic floppy drive installation.
Step 3: Configure GRUB
In this section, let's take a look at how to enter a variety of operating systems after startup, how to build a menu.conf file.
We start from the startup process supported by GRUB. There are two ways to complete the startup process:
· A. By calling kernel locally
· B. Continuous start or transfer to another guide
A mode startup process
1. Set up the device or tell GRUB your root file system.
2. Quantitative Grub's location and transfer the parameters to the kernel.
3. Restart, try it.
In order to launch Linux, I put the kernel in the / boot / directory of the file name, and the file system is / dev / hda5, or the GRUB (HD0, 4). My startup process is as follows: 1.root (HD0, 4) [this sets the root partition]
2. Keernel / boot / bzimage root = / dev / hda5 [this sets the kernel]
The B mode startup process (this mode assumes that another start manager is installed in the current partition, such as LILO or NTLDR):
1. Set the root partition but don't install it
2. Activate this partition
3. Configure the first sector of the partition that needs to be started
4. Restart, look at the effect.
We try to start Widows installed on / dev / hda1 or (hd0, 0). The process of launching Windows is as follows:
1.Rootnoverify (HD0, 0)
2.makeactive
3.ChainLoader 1 [ 1 sets the first sector of the current root part]
4.Boot [TransferS the control and quits grub]
Menu.conf file: It is used to establish a menu when the startup multi-operating system is started. It is not difficult to build menu.conf. It uses simple English, just like you see this section.
All menu items start at the beginning without comma-separated "title titlename". You can set the TitleName at will.
Setting up the Linux boot menu steps as follows:
1. Set the title
2. Set the root partition
3. Set the corresponding parameters of the kernel
4. start up
A menu example:
Title Debian GNU / Linux 2.2 Kernel 2.4.1
Root (HD0, 4)
Kernel /Boot/bzimage.2.4.1
Boot
# ------
The front of the front is a comment.
Establish a menu that starts Windows or DOS:
Title Windoze
Rootnoverify (HD0, 0)
Makeactive
ChainLoader 1
Boot
# ------
If you have two versions of Windows - one is yourself, another for your family - so that the second cannot be installed, because there is a prompt that Windows has been installed.
There is a simple way to install two versions of Windows, that is, hidden a partition when starting, using the other. You can even set password protection for your partition, so you can prevent others to load your partition. The following describes how to complete two Windows installation, HDA1, and HDA2 or (HD0, 0) and (HD0, 1), and the commands used by Lock, Password, Hide, and UnHide.
Establish a Windows project "My Entry":
Title my entry
LOCK
UnHide (HD0, 0)
HIDE (HD0, 1)
Rootnoverify (HD0, 0)
Makeactive
ChainLoader 1
Boot
# ------
In order to better use the lock command, you need to use the password command at the beginning of the configuration file. The syntax of the Password command is as follows: Password Secret ("Secret" is a password). You can enter your password by pressing the P key.
Establish a Windows project "Family Entry"
Title Family Entry
UnHide (HD0, 1)
HIDE (HD0, 0)
Rootnoverify (HD0, 1)
MakeActiveChainLoader 1
Boot
----
Anyone can start this project without having to enter a password.
This has an interesting trick using the password command. In order to hide certain items in the default menu list or configuration file, you can use the following command to load a customized list:
Password secret
In this command, "Secret" is a password, and /boot/grub/secret-list.conf is a password file. Before doing this, you have to enter the root directory or give a full path name. E.g:
Password Secret (HD0, 4) /BOOT /GRUB/Secret-List.conf
Another more important command is "MAP". When you have two hard drives, an operating system that cannot be started from the second hard disk, such as Windows, you can use the map command. For example, you can map HD0 to HD1, map HD1 to HD0. In other words, you can virtually swap two hard drives and start the required operating system. The command form is as follows:
GRUB> MAP (HD0) (HD1)
GRUB> MAP (HD1) (HD0)
Start freebsd:
Title FreeBSD 4.0
Root (HD0, 4, A)
Kernel / boot / loader
Boot
# ------
Here we call freeBSD starters. Root (HD0, 4, A) is from four parameters because FreeBSD is virtual segmentation for a separate partition. We call the root partition as "a". If FreeBSD occupies the entire second hard drive, it should be root (hd0, a). This is not to call the kernel but call the FreeBSD start manager, it is easier to use than the calling kernel.
(Note: I recommend to try a chain load before using OpenBSD and GNU / HURD.)
Now you have completed basic GRUB compilation, installation, and configuration. The more you know about GRUB, the more you find that GRUB is an easy-to-use and efficient way to control startup.
Various GRUB commands:
Default XX
Indicates that XX is the default startup project
Timeout YY
Indicates that the default startup item will start after YY seconds
Fallback ZZ
After the first startup project fails, the ZZ project will be launched after the Timeout time.
Color
This command will generate a color menu. Its syntax is: Color Normal Current_Serection. Both domains can have two values, like foreground / background. E.g:
Color Green / Black Or Light-Gray / Blue
You can also use the relevant numbers.
Remember: All values start from 0, so 0 is the first.
In my next article, I will talk about the test of GNU / HURD AND OpenBSD, perhaps some of the contents of the network boot. But you have to wait for at least three months or more, but I will talk about my test results. Waiting to see it.