一、BIOS方式,grub2安裝
查看磁盤情況
E:\grub-2.02-for-windows>wmic diskdrive list brief Caption DeviceID Model Partitions Size INTEL SSDSCKKF256H6L \\.\PHYSICALDRIVE0 INTEL SSDSCKKF256H6L 3 256052966400 SanDisk Ultra USB Device \\.\PHYSICALDRIVE1 SanDisk Ultra USB Device 2 30746096640
grub2 mbr安裝
E:\grub-2.02-for-windows>grub-install.exe --target=i386-pc \\.\PHYSICALDRIVE1 Installing for i386-pc platform. Installation finished. No error reported.
二、UEFI方式,grub2安裝
grub2 UEFI安裝
1、給Sandisk Ultra U盤在末段分一個 FAT32 格式的分區,並且改變分區類型為:
0xEF Partition with an EFI file system 【可能需要】
2、導入EFI目錄到U盤ESP分區的根目錄,導入grub程序文件到U盤ESP分區的boot目錄。
C:\WINDOWS\system32>f: D:\>cd grub-2.02-for-windows D:\grub-2.02-for-windows>grub-install.exe --target=x86_64-efi --efi-directory=d: --boot-directory=d:\boot --bootloader-id=boot --modules="part_msdos fat normal" Installing for x86_64-efi platform. Installation finished. No error reported.
把D盤替換成U盤ESP分區實際盤符
3、把ESP分區下\EFI\boot\目錄下的grubx64.efi文件改名為bootx64.efi
4、編寫grub.cfg配置文件,復制對應的ESP分區下\boot\grub目錄下
set timeout=300
#set prefix=(${root})/boot/Grub/
menuentry "BIOS Windows Boot Manager" {
echo "BIOS Windows Boot Manager"
#set root=(hd0,msdos1)
insmod ntldr
ntldr (hd0,msdos1)/boot/bootmgr
}
menuentry "BIOS Install CentOS71511"{
echo "BIOS Install CentOS71511 Minimal"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ quiet
initrd /isolinux/initrd.img
}
menuentry "BIOS Install CentOS71511 ks"{
echo "BIOS Install CentOS71511 Minimal ks"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ inst.ks=hd:LABEL=ULTRA:/isolinux/ks.cfg quiet
initrd /isolinux/initrd.img
}
menuentry " "{
configfile
}
menuentry "EFI Windows Boot Manager" {
echo "EFI Windows Boot Manager"
#search --file ($root)/efi/Microsoft/boot/bootmgfw.efi --set=root
terminal_output console
chainloader (hd0,msdos1)/efi/Microsoft/boot/bootmgfw.efi
}
menuentry 'EFI Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
echo "EFI Install CentOS71511 Minimal"
set root=(hd0,msdos1)
linux /isolinux/vmlinuz inst.stage2=hd:LABEL=ULTRA:/ quiet
initrd /isolinux/initrd.img
}
menuentry " "{
configfile
}
menuentry "DiskGenuis Tool"{
set root='(hd0,msdos1)'
linux16 /boot/Grub/memdisk
initrd16 /PE/imgs/DG_x64.img
}
menuentry "Maxdos Toolbox"{
set root='(hd0,msdos1)'
linux16 /boot/Grub/memdisk
initrd16 /PE/imgs/maxdos9.img
}
menuentry 'Reboot' --class reboot {
echo 'Rebooting ...'
reboot
}
menuentry 'Shutdown' --class halt {
echo 'Shutdown ...'
halt
}