First, what is Grub?
The full name of Grub is Grand Unified Bootloader, and grub can boot multiple operating systems.
When the boot button is pressed, the chassis will emit a drip, which indicates that BIOS has completed the boot self-check and the hardware is normal.
Next, BIOS will read 512 bytes of data from 0 cylinder, 0 track and 1 sector of hard disk by default to boot the system. However, because the grub program is very large, the start-up process of Grub is divided into two steps:
Firstly, stage 1 is used as the main boot program to locate and load the second stage program and transfer control to stage 2.
Then, it's stage 2.
Grub files are placed under the / boot/grub directory. There is a stage 1, which is 512 bytes in size and just a sector large. This stage 1 is a copy of MBR, and MBR is the master boot record. For example, when using the U disk as a system, first write the master boot record to the U disk, and then burn the iso file.
In addition, you can see a stage 2, which is a larger program to be loaded by stage 1.
Other xxxx_stage 1_5 files, if you look carefully and find that xxx are: e2fs, fat, ffs, jfs, minix, reiserfs, ufs2, vstafs, xfs are all driver files of various file systems, because stage 2 files may be stored in different file systems, so when stage 1 reads stage 2, it will It will determine what file system stage 2 is, and then read stage 2 through this driver.
Next, you can see that there is a link file menu.lst, which links to grub.conf in the same directory. This is the configuration file of grub, that is, / boot/grub/grub.conf. If you modify this file, it will directly affect the next boot.
The content of this document:
Among them:
default=0: The default starts with the first title (here starting from 0), and if windows is installed first on the machine and then linux is installed, there will be two titles.
2. timeout=5: There are 5 seconds to select the title to start by the up and down keys. Actually, it's also in windows.That's the boot.ini file.
splashimage: This is the image that the boot is displayed. If it is a sata disk, the first disk is sda, the second disk is sdb, and the first partition of the first disk is sda1, and the second partition is sda2, so (hd0, 0)/grub/splash.x Pm.gz is / sda1/grub/splash.xpm.gz, that is, / boot/grub/splash.xpm.gz.
This file is a compressed file, which is decompressed at startup.
3. hiddenmenu: Start the standard menu interface that does not display grub.
4. titile: The name of the system to boot.
5. root (hd0,0): denotes the partition in which the kernel resides.
6. Kernel/vmlinuz-2.6.32-504.el6.x86_64: is the / boot/vmlinuz-2.6.32-504.el6.x86_64 file that specifies the path of the kernel, i.e. (hd0,0) partition.
7. RO root=UUID=c1fa03c8-abf9-4d89-a8e0-4571c69955e0 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8rd_NO_MD SYSFONT=arcyrheb-sun16 crash kernel=128M KEYBOARDTYPE=pc KEYTABLE=us_rd_NO_rhgb quiet: It is a parameter that is passed into the inner core.
8. initrd/initramfs-2.6.32-504.el6.x86_64.img: specify the path of initrd file, initrd is boot loader initialized RAM disk, boot loader initialized RAM disk, is the memory disk used for initialization, the temporary file system at system start-up, the kernel through initrd to obtain various device drivers, executable files, and then go to hang. Load the read real file system, and then uninstall the temporary file system, but in many embedded systems, initrd is used directly as an official file system.
Second, what is the operating level of Linux?
There are seven levels of operation: rd0-rd7.
When bios completes the boot-up self-check, it loads mbr, stage 1 above, and the control is transferred to Grub.
Next stage 1 loads the file system driver, such as xxx_stage 1_5, through initrd temporary file system, through which stage 2 is read.
Then stage 2 loads the linux kernel vmlinuz, and then the kernel vmlinuz loads / sbin/init.
And / sbin/init will be initialized according to / etc/inittab, which holds the linux runlevel:
That is to say:
Running level 0: System downtime status, the default operating level of the system can not be set to 0, otherwise it can not start normally.
Running Level 1: Single user working status, root authority, for system maintenance, prohibit remote login
Run Level 2: Multiuser Status (No NFS)
Run Level 3: Complete Multiuser Status (with NFS), Enter Console Command Line Mode after login
Run Level 4: System Not Used, Reserved
Running Level 5:X11 Console, Enter Graphic GUI Mode after Login
Run Level 6: The system shuts down and restarts normally. The default run level cannot be set to 6, otherwise it cannot start normally.
Terminal mode landing
After going through the above two stages, you can login to the system.
By default, linux has six terminals, using the combination key ctrl+alt+F1, you can enter the first terminal, and so on.
And the terminal is called tty, that is, tty1-tty6.
Press CTRL+ALT+F2 and enter the second terminal, tty2, as shown below:
The contents are as follows:
1. The name and version number of the distribution.
2. Kernel version and hardware platform.
3. Host name ggg2.
4. login: Wait for the user name to be entered, where root is entered.
5. password: It is prompted to enter a password.
6. Last Login: It shows the time of the last landing and which tty it was.
7. [root@ggg2 ~]#: root denotes the login user name, ggg2 is the host name, ~denotes the current user's home directory, # denotes that the current user is a super-privileged user root user, and if it is an ordinary user, $.
In addition, by modifying the content of / etc/issue, different text can be displayed when landing at the terminal.
A line "Hello, Linux!" was added at the end. :
Then, after entering exit, it enters tty again, as shown below: