chroot 調整系統 - MBR

  1. gdisk 查看開機硬碟 /dev/sda 的分割狀況,/dev/sda2 的掛載 /boot 的開機目錄。
    bash-4.4# gdisk -l /dev/sda
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sda: 937703088 sectors, 447.1 GiB
    Model: INTEL SSDSC2BW48
    Sector size (logical/physical): 512/512 bytes
    Disk identifier (GUID): 2CC0140B-213C-4298-ADF8-603284119E49
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 937703054
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 3693 sectors (1.8 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048           43007   20.0 MiB    EF00  EFI System
       2           43008         1026047   480.0 MiB   EF02  BIOS boot partition
       3         1026048       937701375   446.6 GiB   8E00  Linux LVM
    
  2. parted 將 /dev/sda2 分割區的 flags boot 關閉,bios_grub 開啟。
    bash-4.4# parted /dev/sda
    GNU Parted 3.2
    Using /dev/sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) set 2 boot off
    (parted) set 2 bios_grub on
    (parted) q
    Information: You may need to update /etc/fstab.
    
  3. grub2-install 安裝 bios 開機到硬碟,此例為 /dev/sda。若硬碟由其他系統管理,例如還原卡,則必須安裝到 bios boot 分割區,此例為 /dev/sda2,無法安裝時可使用 –force 選項強制安裝。
    bash-4.4# grub2-install --target=i386-pc /dev/sda
    
  4. 退出系統。
    bash-4.4# exit
    exit
    
  5. RHEL9 測試,如上第 2 個 partition 設定為 BIOS boot partition,grub2-install 後這個 partition 無法掛載且無法開機,必須另外新增大小 1M 的第 1 個 BIOS boot partition,再 grub2-install,則 BIOS 及 UEFI 開機都沒問題。