修改 GRUB 開機選單

  1. 由於 EFI 分割區在第一分割區,Linux 開機分割區由第一分割區 (hd0,0) 改到第二個分割區 (hd0,1),所以 GRUB 開機選單必須修改,否則無法開機。先進入工作目錄 /usr/src/ 查 image 的分割區。
    [root@controller ~]# cd /usr/src/
    [root@controller src]# fdisk -l crtefi15g-20190112.img
    
    Disk crtefi15g-20190112.img: 15.7 GB, 15728640000 bytes, 30720000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x55654248
    
                     Device Boot      Start         End      Blocks   Id  System
    crtefi15g-20190112.img1            2048        6143        2048   ef  EFI (FAT-12/16/32)
    crtefi15g-20190112.img2   *        6144      329727      161792   83  Linux
    crtefi15g-20190112.img3          329728    29689855    14680064   8e  Linux LVM
    
  2. 分別掛載 image 的第一及二分割區在 /mnt/efi 及 /mnt/boot。
    [root@controller src]# mount -oloop,offset=1048576 crtefi15g-20190112.img /mnt/efi
    [root@controller src]# mount -oloop,offset=3145728 crtefi15g-20190112.img /mnt/boot
    
  3. 將 efi 及 boot 中開機選單的 hd0,0 改成 hd0,1。
    [root@controller src]# sed -i 's/hd0,0/hd0,1/g' /mnt/efi/EFI/BOOT/BOOTX64.conf 
    [root@controller src]# sed -i 's/hd0,0/hd0,1/g' /mnt/boot/grub/grub.conf
    
  4. 卸載 /mnt/efi 及 /mnt/boot。
    [root@controller src]# umount /mnt/{efi,boot}