GRUB application

GRUB application

  • CentOS 6 boot process:
    POST –> Boot Sequence(BIOS) –> Boot Loader (MBR) –> Kernel(ramdisk) –> rootfs –> switchroot –> /sbin/init –>(/etc/inittab, /etc/init/*.conf) –> set the default run level –> system initialization script –> close or start the corresponding level Service–>Start the terminal
  • GRUB (Boot Loader): boot loader, program
    1grub: GRand Unified Bootloader
    grub 0.x: grub legacy
    grub 1.x: grub2
    2.grub legacy:
    stage1: mbr
    stage1_5: the sector after mbr, so that the bootloader in stage1 can recognize the file system on the partition where stage2 is located;
    stage2: disk partition ( /boot/grub/)
    Configuration file: /boot/grub/grub.conf <-- /etc/grub.conf
    The stage2 and kernel are usually placed in a basic disk partition;
    Function:< br>(1) Provide menu and interactive interface
    e: edit mode, used to edit menu;
    c: command mode, interactive interface;
    (2) load the kernel or Operating system
    Allows to pass parameters to the kernel
    Can hide this menu
    (3) Provides a protection mechanism for the menu
    Authentication for editing the menu
    Authentication for enabling the kernel or operating system
    3. The command line interface of grub:
    help: Get help list
    help KEYWORD: Detailed help information
    find (hd#,#)/PATH/TO/SOMEFILE:
    root (hd#,#)
    kernel /PATH/TO/KERNEL_FILE: Set the kernel file used during this boot; you can also add many cmdline parameters that the kernel supports;
    For example: init=/path/to/init, selinux=0
    initrd /PATH/TO/INITRAMFS_FILE: set the ramdisk to provide additional files for the selected kernel;
    boot: boot the selected kernel Kernel;
    Manually start the system on the grub command line interface:
    grub> root (hd#,#)
    grub> kernel /vmlinuz-VERSION-RELEASE ro root=/dev/DEVICE
    grub> initrd /initramfs-VERSION-RELEASE.img
    grub> boot
    Identify hard disk device:
    (hd#,#)
    hd#: Disk number, use numbers Representation; numbering from 0
    #: partition number, represented by numbers; numbering from 0
    (hd0,0)

    4. Install grub:
    (1) grub-install
    grub-install –root-directory=ROOT /dev/DISK
    (2) grub
    grub> root (hd#,#)
    grub> setup (hd#)< br>grub legacy configuration file
    Configuration file: /boot/grub/grub.conf

    Configuration item:
    default=#: Set the default boot menu item; place a single item (title ) Numbering starts from 0;
    timeout=#: Specify the length of time the menu item waits for option selection;
    splashimage=(hd#,#)/PATH/ TO/XPM_PIC_FILE: specify the path of the menu background picture file;
    hiddenmenu: hide the menu;
    password [--md5] STRING: menu editing certification;
    title TITLE: define the menu item "title", It can appear multiple times;
    root (hd#,#): grub searches for stage2 and the device partition where the kernel file is located; it is the "root" of grub;
    kernel /PATH/TO/VMLINUZ_FILE [PARAMETERS]: start
    initrd /PATH/TO/INITRAMFS_FILE: the ramfs file matched by the kernel;
    password [--md5] STRING: authentication when starting the selected kernel or operating system;

  • grub encryption:
    Generate grub password:
    grub-md5-crypt
    grub-crypt
    Crack root password:
    When starting the system, set it to run Level 1
    Enter single user mode:
    (1) Edit grub menu (select the title to be edited, and then use the e command);
    (2) Add after the selected kernel
    1, s, S or single are all possible;
    (3) In the line where the kernel is located, type the "b" command;

Leave a Comment

Your email address will not be published.