grub

dom fedora UI無法開啟,需改用更改開機選單(使用終端機模式)
記錄一下修改方式


更新記錄

item note
20160912 第一版
20170125 如何設定grub2的開機圖

目錄


如何設定grub2的開機圖

在fedora24上面測試,流程如下
1.設定/etc/default/grub
2.關閉GRUB_TERMINAL_OUTPUT
3.更新/boot/grub2/gurb.cfg

使用工具(grub-customizer),選擇開機圖檔

  • fedora24如何設定開機圖示
    使用工具設定,安裝方式如下
    不過設定之後無圖示,還在了解為什麼跑不出

    1
    dnf install grub-customizer
  • 注意使用圖片限制如下

    • JPG/JPEG images must be 8-bit (256 color).
    • Images should be non-indexed, RGB.
  • /etc/default/grub 設定前

    1
    2
    3
    4
    5
    6
    7
    8
    [root@localhost default]# cat grub 
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="rhgb quiet"
    GRUB_DISABLE_RECOVERY="true"
  • /etc/default/grub 設定後

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    [root@localhost ~]# cat /etc/default/grub 
    GRUB_TIMEOUT="5"
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT="saved"
    GRUB_DISABLE_SUBMENU="true"
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="rhgb quiet"
    GRUB_DISABLE_RECOVERY="true"

    export GRUB_COLOR_NORMAL="light-gray/black"
    export GRUB_COLOR_HIGHLIGHT="magenta/black"
    GRUB_BACKGROUND="/root/pc200-logo-640.png"
    #GRUB_GFXMODE="saved"
    #GRUB_THEME="/boot/grub2/themes/system/theme.txt"
    #GRUB_HIDDEN_TIMEOUT="0"

其它更改設定檔,關閉終端輸出模式

即關閉GRUB_TERMINAL_OUTPUT設定

  • 關閉終端輸出模式,設定檔如下
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    [root@localhost ~]# cat /etc/default/grub 
    GRUB_TIMEOUT="5"
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT="saved"
    GRUB_DISABLE_SUBMENU="true"
    #GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="rhgb quiet"
    GRUB_DISABLE_RECOVERY="true"

    export GRUB_COLOR_NORMAL="light-gray/black"
    export GRUB_COLOR_HIGHLIGHT="magenta/black"
    GRUB_BACKGROUND="/root/pc200-logo-640.png"
    #GRUB_GFXMODE="saved"
    #GRUB_THEME="/boot/grub2/themes/system/theme.txt"
    #GRUB_HIDDEN_TIMEOUT="0"

更新boot區grub設定檔

  • 記得一定要更新boot區設定檔,不然設定不會有效

    1
    grub2-mkconfig -o /boot/grub2/grub.cfg
  • 增加設定內容如下

[grub gfxterm]

Grub

  • GRUB2 是新一代的 GRand Unified Bootloader (GRUB/開機引導程式)

如何更改開機選單(使用終端機模式)

  • 開機選單中,按下e (即編輯開機選單中內容)

  • cat boot/grub2/grub.cfg

    1
    linux16 /vmlinuz-4.3.4-200.fc22.x86_64 root=LABEL=dom-root-160219 ro rd.lvm.lv=fedora/swap rhgb quiet
  • 增加single如下,即可以使用終端機模式
    記得ctrl + x 直接執行

    1
    linux16 /vmlinuz-4.3.4-200.fc22.x86_64 root=LABEL=dom-root-160219 ro rd.lvm.lv=fedora/swap rhgb quiet single

Partitioning

  • Partitioning a hard drive divides the available space into sections that can be accessed independently
  • The required information is stored in a Partition table scheme such as MBR or GPT.
  • Tables are modified using a Partitioning tool which must be compatible to the chosen scheme of partitioning table
    Available tools include fdisk and parted.

Partition table

  • GUID Partition Table (GPT) is an alternative, contemporary, partitioning style; it is intended to replace the old Master Boot Record (MBR) system.
  • PC開機順序: BIOS->POST->MBR->Boot sector->OS
    MBR是硬碟的第1個Sector, 每個Sector是512Byte
  • The MBR (which is always located on the first sector of a hard disk) contains that disk’s Master (or Primary) Partition Table
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     [root@localhost boot]# parted -s /dev/sdb print
    Model: ATA SATADOM-SV 3SE (scsi)
    Disk /dev/sdb: 4012MB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 127MB 126MB primary ext4 boot
    2 127MB 4012MB 3885MB primary ext4

Grub Partition

  • Preliminary Requirements for GRUB2 / BIOS 系統

    • GPT specific instructions
      partition type (“EF02”)

    • MBR aka msdos partitioning specific instructions
      Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition)

    • UEFI 系統
      Unified Extensible Firmware Interface
      UEFI started as Intel’s EFI in versions 1.x.

  • /boot

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [root@localhost boot]# ls -l
    total 26482
    drwxr-xr-x 3 root root 1024 Feb 19 2016 boot
    -rw-r--r-- 1 root root 161946 Jan 25 2016 config-4.3.4-200.fc22.x86_64
    drwxr-xr-x 4 root root 1024 May 22 2015 efi
    -rw-r--r-- 1 root root 17689548 Feb 19 2016 initramfs-4.3.4-200.fc22.x86_64.img
    drwx------ 2 root root 12288 Feb 19 2016 lost+found
    -rw------- 1 root root 3192611 Jan 25 2016 System.map-4.3.4-200.fc22.x86_64
    -rwxr-xr-x 1 root root 6056008 Jan 25 2016 vmlinuz-4.3.4-200.fc22.x86_64

其它

如何查得grub2版本

1
2
[root@localhost grub2]# grub2-install --version
grub2-install (GRUB) 2.02~beta3

參考