In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
GRUB (Boot Loader): basic applications
Grub: GRand Unified Bootloader
Version: grub 0.x: grub legacy Legacy grub version
Grub 1.x: grub2
Take centos6 as an example
Grub is installed in MBR
Grub legacy:
Stage1: mbr
Stage1_5: in the sector after mbr, let bootloader in stage1 recognize the file system on the partition where stage2 resides
Stage2: stored in disk partition (/ boot/grub/)
Configuration file for grub: / boot/grub/grub.conf root (hd#,#)
Grub > kernel / vmlinuz-VERSION-RELEASE ro root=/dev/DEVICE (specify the kernel version and the directory where the root is located. Note here that root must be the partition file of the device where your root is located, which can be viewed through the df command)
Grub > initrd / initramfs-VERSION-RELEASE.img
Grub > boot
Configuration file: / boot/grub/grub.conf
Configuration items:
Default=#: sets the menu item that starts by default; the menu item (title) number starts from 0
Timeout=#: specifies the length of time for the menu item to wait for the option to be selected; (if the user chooses for more than 5 seconds, he or she will choose by himself.)
Splashp_w_picpath= (hd#,#) / PATH/TO/XPM_PIC_FILE: indicates the path of the menu background picture file
Hiddenmenu: hiding menus
Password [--md5] STRING: menu Editor Certification
Title TITLE: defines the "title" of a menu item, which can appear multiple times
Root (hd#,#): grub finds the device partition where the stage2 and kernel files are located; is the "root" of grub
Kernel / PATH/TO/VMLINUZ_FILE [PARAMETERS]: boot kernel
Initrd / PATH/TO/INITRAMFS_FILE: kernel matching ramfs file
Password [--md5] STRING: authenticates when starting a selected kernel or operating system
If authentication is required when booting, the following command can help us generate a password string
Grub-md5-crypt command: help us generate the corresponding password string to be protected
To enter single-user mode:
(1) Edit the grub menu (select the title to edit, and then use the e command)
(2) move the menu to the kernel item and append it after the selected kernel
1, s, S or single is fine; then enter to return to the menu item
(3) in the line of kernel, type (click) "b command"
After the system is damaged, you can follow the following methods to repair it when there is no restart.
Install grub:
(1) grub-install: install the grub command grub-install-install GRUB on your drive
Grub-install [OPTION] install_device
Grub-install-root-directory=ROOT / dev/DISK
The system did not restart to repair using the following:
(2) grub
Grub > root (hd#,#) # this method must be implemented with a grub directory
Grub > setup (hd#)
Create a disk to provide a system that can run bash separately
1. First, add a disk and partition to create a file system, which is set to / dev/sdb1 (for boot and grub installation), / dev/sdb2 (for swap partition), and / dev/sdb3 (for root).
2. Install grub
[root@localhost ~] # mkdir / mnt/boot
[root@localhost ~] # mount / dev/sdb1 / mnt/boot
[root@localhost ~] # ls / mnt/boot
Lost+found
[root@localhost] # grub-install-- root-directory=/mnt / dev/sdb
# # install grub and specify the directory where the root is located
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map / mnt/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/sda
(hd1) / dev/sdb
[root@localhost ~] # ls / mnt
Boot sysroot
[root@localhost ~] # ls / mnt/boot
Grub lost+found
# shows that grub has been successfully installed
[root@localhost ~] # ls / mnt/boot/grub/
Device.map iso9660_stage1_5 stage1 xfs_stage1_5
E2fs_stage1_5 jfs_stage1_5 stage2
Fat_stage1_5 minix_stage1_5 ufs2_stage1_5
Ffs_stage1_5 reiserfs_stage1_5 vstafs_stage1_5
[root@localhost ~] # cp / boot/vmlinuz-2.6.32-573.el6.x86_64 / mnt/boot/vmlinuz
# copy kernel
[root@localhost ~] # cp / boot/initramfs-2.6.32-573.el6.x86_64.img / mnt/boot/initramfs.img
[root@localhost ~] # vim / mnt/boot/grub/grub.conf
Default=0
Timeout=5
Title Centos (express)
Root (hd0,0) # # here the first partition identified as the first disk in the newly created system
Kernel / vmlinuz ro root=/dev/sda3
# sda3 is also used here instead of sdb3, which is the third partition of the disk for the new system
Initrd / initramfs.img
# Editing grub configuration file
# # the above is the grub configuration stage, and the following is to create the root file
[root@localhost ~] # mkdir / mnt/sysroot
[root@localhost ~] # ls / mnt
Boot sysroot
[root@localhost ~] # mount / dev/sdb3 / mnt/sysroot
# Mount the partition sdb3 and place it as the root file
[root@localhost ~] # ls / mnt/sysroot
Lost+found
[root@localhost ~] # cd / mnt/sysroot
[root@localhost sysroot] # ls
Lost+found
[root@localhost sysroot] # mkdir-pv etc bin sbin lib lib64 dev proc sys tmp var usr home root mnt media
# # create the necessary directories under the root
Mkdir: created directory `etc'
Mkdir: created directory `bin'
Mkdir: created directory `sbin'
Mkdir: created directory `lib'
Mkdir: created directory `lib64'
Mkdir: created directory `dev'
Mkdir: created directory `proc'
Mkdir: created directory `sys'
Mkdir: created directory `tmp'
Mkdir: created directory `var'
Mkdir: created directory `usr'
Mkdir: created directory `home'
Mkdir: created directory `root'
Mkdir: created directory `mnt'
Mkdir: created directory `media'
[root@localhost sysroot] # ls
Bin etc lib lost+found mnt root sys usr
Dev home lib64 media proc sbin tmp var
# there is no program in the file at this time, so let's copy the bash in and start it as init
[root@localhost sysroot] # cp / bin/bash / mnt/sysroot/bin/
[root@localhost sysroot] # ldd / bin/bash
Linux-vdso.so.1 = > (0x00007ffcb40d4000)
Libtinfo.so.5 = > / lib64/libtinfo.so.5 (0x0000003d61800000)
Libdl.so.2 = > / lib64/libdl.so.2 (0x0000003d5ac00000)
Libc.so.6 = > / lib64/libc.so.6 (0x0000003d5b000000)
[root@localhost sysroot] # cp / lib64/libtinfo.so.5 / mnt/sysroot/lib64
[root@localhost sysroot] # cp / lib64/libdl.so.2 / mnt/sysroot/lib64
[root@localhost sysroot] # cp / lib64/libc.so.6 / mnt/sysroot/lib64
[root@localhost sysroot] # cp / lib64/ld-linux-x86-64.so.2 / mnt/sysroot/lib64
# copy everything that bash depends on to the appropriate directory
[root@localhost sysroot] # chroot / mnt/sysroot
Bash-4.1#
# detect the root system
# # configuration root has been successful
A simple system is configured, and then create a virtual machine and mount the disk on it, but when using manual startup at the same time, edit the kernel option in the grub menu item to add selinux=0 in front of the init and press enter to return to the menu item and click "b command" to start.
Note: there is no command here. To use the command, you need to copy the relevant files to the system.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.