GRUB is a multi-system boot manager that can guide Linux and Windows or other systems. After years of teaching experience, I found that most linux beginners cannot grasp GRUB usage in a short time.
GRUB is a multi-system boot manager that can guide Linux and Windows or other systems. After years of teaching experience, I found that most linux beginners cannot grasp GRUB usage in a short time, to help more beginners master GRUB in the shortest time, it is necessary to rewrite the GRUB getting started document;
Starting from the working principle, this article focuses on GRUB menu. the lst statement also details the GRUB command line boot system. these are applicable to Windows and Linux GRUB;
1. what is the multi-operating system boot manager and GRUB;
1. what is the multi-operating system boot manager and working principle;
The system boot guide manager is the first program that runs after the computer is started. it is used to load and transmit data to the operating system kernel. Once the kernel is mounted, even if the task of the system boot manager is completed and exited, other parts of the system boot, such as the system initialization and startup process, are completely controlled by the kernel;
Briefly, boot loader is the first software program that runs when a computer starts. it is responsible for loading and transferring control to the operating system kernel software (such as the Hurd or the Linux ). the kernel, in turn, initializes the rest of the operating system (e.g. GNU ).
GRUB and LILO are the most common operating systems in Linux, BSD, or other Unix operating systems;
Windows also has a similar tool NTLOADER. for example, after Windows 98 is installed on the machine, we can install another Windows XP, when the machine starts, there is a menu for us to choose whether to enter Windows 98 or Windows XP. NTLOADER is a multi-system boot guide manager. NTLOADER can also guide Linux, but it is very troublesome;
In Powerpc-based machines, if the Linux Powerpc version is installed, most of them use the YT t multi-boot manager. for example, the Apple machine currently uses the IBM Powerpc processor, therefore, if you want to install Macos and Linux Powerpc on an Apple machine, most of them use yaboot to guide multiple operating systems;
Currently, machines in the X86 architecture are still mainstream, so GRUB and LILO are still our most commonly used multi-operating system boot manager;
2. what is GRUB? why should I select GRUB;
1) What is GRUB;
Gnu grub is a multi-operating system startup manager. Gnu grub is derived from GRUB (GRand uniiedbootloader. GRUB was initially designed and applied by Erich Stefan Boleyn;
Gnu grub is a Multiboot boot loader. It was derived from GRUB, GRand uniied Bootloader, which was originally designed and implemented by Erich Stefan Boleyn.
2) "GRUB is too difficult to use"-misunderstandings about GRUB;
Is GRUB really hard to use? No, via LinuxSir. the Org community has been running for nearly four years. I have found that most new beginners still do not know GRUB very well. of course, this is also the responsibility of the Chinese Linux community, although it also has a Chinese translation of GRUB, linux beginners may not understand it;
We are delighted to see LinuxSir. many of the brothers in the Org community have either written or are writing GRUB practice documents, and some of them have summarized some basic knowledge of GRUB, such as the GRUB study notes of probing's brother. because each person may have different styles when writing a document, different people may have different styles when writing the same document. today, I am also a beginner-level tutorial, as we won't write any advanced tutorials in North China, we have to ask the experts for advice. thank you first;
3) Why select GRUB;
The operating system is developed based on the CPU in the X86 architecture. The system boot manager not only has GRUB but also LILO, but you can only choose one of the multiple system boot managers; two cannot be used at the same time;
At present, these two multi-system boot managers are the most commonly used and used in mainstream Linux distributions. some brothers like GRUB, such as me, and some others like LILO;
Mainstream distribution systems based on RPM packages, such as Fedora, Redhat, and Centos, default GRUB boot in the latest version; Slackware is still using LILO; the latest Debian release version also uses GRUB;
At present, GRUB has gradually replaced LILO, and GRUB 2.0 is under development. Therefore, we have reason to use GRUB and I have reason to write GRUB tutorials;
2. select and install the GRUB software package version;
1. select GRUB and GRUB for Linux;
GRUB not only has the Linux version but also the Windows version. we will introduce it one by one;
As mentioned above, GRUB is available in most Unix operating systems. GRUB can guide almost all operating systems in the X86 architecture. GRUB has powerful functions, ease of use is the biggest selling point of GRUB. thanks to the advantages of the Windows operating system, we know a lot about NTLOADER in Windows, and GRUB in the open-source community is a bit quite simple, this leads to the "psychological fear" in use. The main reason why beginners are not familiar with GRUB is that they do not have much knowledge or knowledge about GRUB; whether it is WINGRUB or GRUB in Linux, the most convenient operation is GRUB Command line operations. when it comes to Command line operations, beginners may be afraid of this; in fact, there is no difficulty. you should be able to operate low-level writers such as North and South;
2. Windows WINGRUB of GRUB;
For details about how to use WINGRUB to guide installation of Fedora 4.0, see: how to use WINGRUB to guide installation of Linux
3. install the GRUB Linux software package;
In fact, for Linux GRUB, almost all mainstream Linux distributions are packaged. if you have installed Linux and GRUB appears after the boot, it proves that you have installed GRUB; the installation of Linux's GRUB package is not the focus of this article;
If GRUB is not installed in your Linux system, or LILO is used, and GRUB is used, you can use the GRUB software package that comes with the system installation disk to install GRUB, or download and install the software from the software warehouse of the relevant release version;
GRUB Linux versions are currently packaged in all major releases; for example, Fedora/Redhat/Centos/Mandrive/Mandriva/SuSE and other systems with RPM Package management mechanisms, you can run the following command to install the SDK;
See Fedora/Redhat package management guide
[Root @ localhost ~] # Rpm-ivh grub *. rpm
For Slackware, you can use the following method to install it;
[Root @ localhost ~] # Installpkg grub *. tgz
For other release versions, use their own software package management tools;
Of course, you can also install the source code package on any Linux release version. for the installation method of the source code package;
See: how to compile and install the source code package software
[Root @ localhost ~] # Tar zxvf grub * .tar.gz
[Root @ localhost ~] # Cd grub-xxx
[Root @ localhost ~] #./Configure; make install
Check whether GRUB is successfully installed. you can test whether the following two commands exist;
[Root @ localhost ~] # Grub
[Root @ localhost ~] # Grub-install
If you cannot find these two commands, the path of your executable program may not be set;
Of course, you can use absolute paths; for example, the following;
[Root @ localhost ~] #/Usr/sbin/grub
[Root @ localhost ~] #/Usr/sbin/grub-install
If you still cannot find where the GRUB software package is installed, you can use the following command to solve and find it;
[Root @ localhost ~] # Updatedb note: This takes a long time; it is the index slocate library, and then it is searched through locate;
[Root @ localhost ~] # Locate grub
For example, we found something similar to the following;
[Root @ localhost ~] # Locate grub
/Sbin/grub-md5-crypt
/Sbin/grub
/Sbin/grub-install
/Sbin/grub-terminfo
In general, the path contains bin or sbin, which are executable programs; sbin is a management command that can be used by Super-authorized users; to use these commands, you must switch to the root user. for example:
[Beinan @ localhost ~] $ Su-note: switch to the root user and switch to its home directory;
Password:
[Root @ localhost ~] #/Sbin/grub note: run the grub command using an absolute path;
3. install and write the hard disk MBR in GRUB configuration in Linux;
1. install GRUB-install during grub configuration in Linux;
What is the use of the grub-install command? In fact, some files in the software package we have installed are copied to/boot/grub. after the GRUB software package is installed, it is also a necessary process; the installation of the GRUB software package we mentioned earlier, but now we are talking about the installation in the GRUB configuration process. although install is used in foreign languages, the meaning is different;
First, run fdisk-l to confirm whether it is the hard disk identifier;
In this process, we mainly confirm the hard disk ID, whether it is/dev/hda,/dev/hdb, or other;
[Root @ localhost ~] # Fdisk-l
Disk/dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/hda1*1 970 7791493 + 7 HPFS/NTFS
/Dev/hda2 971 9729 70356667 + 5 Extended
/Dev/hda5 971 2915 15623181 B W95 FAT32
/Dev/hda6 2916 4131 9767488 + 83 Linux
/Dev/hda7 4132 5590 11719386 83 Linux
/Dev/hda8 5591 6806 9767488 + 83 Linux
/Dev/hda9 6807 9657 22900626 83 Linux
/Dev/hda10 9658 9729 578308 + 82 Linux swap/Solaris
If/dev/hda appears through fdisk-l, we need to use the following command to install it;
[Root @ localhost ~] # Grub-install/dev/hda
Installation finished. No error reported.
This is the contents of the device map/boot/grub/device. map.
Check if this is correct or not. If any of the lines is incorrect,
Fix it and re-run the script 'grub-install \'.
(Fd0)/dev/fd0
(Hd0)/dev/hda
If your fdisk-l has/dev/hdb, run the following command;
[Root @ localhost ~] # Grub-install/dev/hdb
Install/dev/hda and/dev/hdb to/dev/hda;
[Root @ localhost ~] # Grub-install/dev/hda
It is worth noting that if you have a/boot partition, you should use the following method to install it;
[Root @ localhost ~] # Grub-install -- root-directory =/boot/dev/hda
[Root @ localhost ~] # Grub-install -- root-directory =/boot/dev/hdb
Note: for details, refer to/dev/hda or/dev/hdb. refer to fdisk-l. if both of them have, whether the/boot partition is placed on the first or second hard disk depends on the actual situation;
2. set the/boot partition of GRUB and write it into MBR ;;
In Linux, it is not enough to install the GRUB software package and install grub to/boot during the configuration process. you must write GRUB into MBR. sometimes we reinstall Windows, windows will rewrite MBR, so GRUB will disappear; if this happens, you need to proceed;
[Root @ localhost ~] # Grub
The grub> prompt appears, which is the grub command line mode. if a prompt appears during startup, there is no system that cannot be booted, unless your system is severely damaged. If only GRUB is damaged, the GRUB command line can guide the operating system;
Next, let's look at the example. we need to find/boot/grub/stage1 and input it after grub>;
Grub> find/boot/grub/stage1
(Hd0, 6)
(Fd0) Note: This is a soft Drive. Currently, it is rarely used. if you need it, check the grub doc;
Note:
(Hd0, 6) This is the partition where/boot is located. do not misunderstand it as the partition where Linux/is located. this is worth noting;
(Fd0) Note: This is a soft Drive. Currently, it is rarely used. if you need it, check the grub doc;
Grub> root (hd0, 6) Note: This is the partition where/boot is located;
Grub> setup (hd0) Note: write GRUB to MBR;
Note:
The above steps are based on find/boot/stage1, and you will understand it after a careful look; now we usually seldom list the/boot partition as a separate partition during installation; however, some may also like this, so it is necessary to say something better;
4. syntax of menu. lst in GRUB configuration file;
For GRUB, if menu is not configured. lst, whether in Linux GRUB or WINGRUB, has command lines available, which can also guide the operating system. some of them always think menu. if the lst configuration is incorrect, or grub> command line mode appears after the machine is started, the system needs to be re-installed. In fact, this is not necessary at all. you only need to learn how to use the GRUB command line, there is no need to reinstall the system;
Menu. the lst is located in the/boot/grub Directory, that is,/boot/grub/menu. you can use vi or your favorite editor to edit an lst file. if you do not use vi, you can still learn it. how can you use it in a simple way? After all, this document is not about vi usage;