- gdisk 新增 efi 開機分割區。
[root@deyu ~]# gdisk /dev/vda
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************
Command (? for help): p
Disk /dev/vda: 62914560 sectors, 30.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 00720AF6-AAFE-4232-A78D-8E6D57DFF7A6
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 62914526
Partitions will be aligned on 2048-sector boundaries
Total free space is 20930493 sectors (10.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 1026047 500.0 MiB 8300 Linux filesystem
2 1026048 41986047 19.5 GiB 8E00 Linux LVM
Command (? for help): d
Partition number (1-2): 1
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-62914526, default = 41986048) or {+-}size{KMGTP}: 2048
Last sector (2048-1026047, default = 1026047) or {+-}size{KMGTP}: +50M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'
Command (? for help): p
Disk /dev/vda: 62914560 sectors, 30.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 00720AF6-AAFE-4232-A78D-8E6D57DFF7A6
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 62914526
Partitions will be aligned on 2048-sector boundaries
Total free space is 21852093 sectors (10.4 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 104447 50.0 MiB EF00 EFI System
2 1026048 41986047 19.5 GiB 8E00 Linux LVM
Command (? for help): n
Partition number (3-128, default 3):
First sector (34-62914526, default = 41986048) or {+-}size{KMGTP}: 104448
Last sector (104448-1026047, default = 1026047) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'
Command (? for help): p
Disk /dev/vda: 62914560 sectors, 30.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 00720AF6-AAFE-4232-A78D-8E6D57DFF7A6
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 62914526
Partitions will be aligned on 2048-sector boundaries
Total free space is 20930493 sectors (10.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 104447 50.0 MiB EF00 EFI System
2 1026048 41986047 19.5 GiB 8E00 Linux LVM
3 104448 1026047 450.0 MiB EF02 BIOS boot partition
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/vda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
- gdisk 查看分割區。
[root@deyu ~]# gdisk -l /dev/vda
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/vda: 62914560 sectors, 30.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 00720AF6-AAFE-4232-A78D-8E6D57DFF7A6
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 62914526
Partitions will be aligned on 2048-sector boundaries
Total free space is 20930493 sectors (10.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 104447 50.0 MiB EF00 EFI System
2 1026048 41986047 19.5 GiB 8E00 Linux LVM
3 104448 1026047 450.0 MiB EF02 BIOS boot partition
[root@deyu ~]# gdisk /dev/vda
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.
Command (? for help): s
You may need to edit /etc/fstab and/or your boot loader configuration!
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/vda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
- 格式化 efi 分割區。
[root@deyu ~]# mkfs.fat /dev/vda1
- 掛載 efi 分割區。
[root@deyu ~]# mount /dev/vda1 /boot/efi
- 安裝 efi 相關套件。
[root@deyu ~]# dnf install grub2-efi-x64 shim-x64
- 產生開機選單設定檔。
[root@deyu ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Generating grub configuration file ...
done
- 查看 EFI 目錄下的檔案。
[root@deyu ~]# ll /boot/efi/EFI/
total 4
drwx------. 2 root root 1024 Jul 4 15:46 BOOT
drwx------. 3 root root 1024 Jul 4 15:46 centos
[root@deyu ~]# ll /boot/efi/EFI/centos/
total 5804
-rwx------. 1 root root 134 Aug 1 2020 BOOTX64.CSV
drwx------. 2 root root 4096 Mar 3 05:03 fonts
-rwx------. 1 root root 2285336 Mar 3 05:03 grubx64.efi
-rwx------. 1 root root 1162400 Aug 1 2020 mmx64.efi
-rwx------. 1 root root 1238416 Aug 1 2020 shimx64-centos.efi
-rwx------. 1 root root 1244496 Aug 1 2020 shimx64.efi
[root@deyu ~]# ll /boot/efi/EFI/BOOT/
total 1572
-rwx------. 1 root root 1244496 Aug 1 2020 BOOTX64.EFI
-rwx------. 1 root root 362264 Aug 1 2020 fbx64.efi