简介:
还在折腾PXE启动,UEFI的在WDS,一直无法正常启动,也不知道哪里的问题。反正以后还要在WDS上面加多一层引导,前面用的grub4dos grub4dos uefi。
可能是不支持吧,所以折腾一下GRUB2吧。
安装linux
我习惯使用fedora,现在用的是39的版本。
安装包
dnf install grub2-common grub2-pc grub2-efi-x64-cdboot grub2-efi-x64-modules
分区
Make sure it's the right drive! (check the capacity and the partitions) :
sudo fdisk -l /dev/sdX
Open fdisk :
sudo fdisk /dev/sdX
Press the following keys (THIS WILL ERASE ALL DATA FROM THE SELECTED DRIVE!) :
o
<enter>
# Create a new empty DOS partition table
n
<enter>
# Create a new partition
p
<enter>
# Select primary partition type
1
<enter>
# Set partition number to 1
<enter>
# Start partition at the first possible sector (default)
<enter>
# Set partition end to the last possible sector (default)
Note: if fdisk (newer versions only) asks whether the partition signature should be deleted, then answer yes.
t
<enter>
# Change partition type
e
f
<enter>
# Set partition type to EFI (FAT-12/16/32)
a
<enter>
# Enable the bootable flag on partition 1
w
<enter>
# Write the partition table
Create a fresh filesystem in the newly created partition :
sudo mkfs.fat -F32 /dev/sdX1
Mount the filesystem :
sudo mount -o umask=000 /dev/sdX1 /mnt
写入bios引导
sudo grub2-install --no-floppy --boot-directory=/mnt/boot --target=i386-pc /dev/sdX
写入UEFI引导
sudo grub2-install --removable --boot-directory=/mnt/boot --efi-directory=/mnt --target=x86_64-efi /dev/sdX
引导菜单
/mnt/boot/grub/grub.cfg
menuentry 'Xubuntu 22.04 amd64'{ #rmmod tpm #uncomment if grub version is >=2.04 in UEFI mode (see https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311) set isofile="/isos/xubuntu-22.04.3-desktop-amd64.iso" #search --set=root --file $isofile #uncomment if the bootloader and OS files are on different partitions loopback isoloop $isofile linux (isoloop)/casper/vmlinuz locale=fr_FR console-setup/layoutcode=fr boot=casper iso-scan/filename=$isofile quiet -- initrd (isoloop)/casper/initrd }
随便写一个,能看见就好了。
后面继续学习如何写grub2的引导菜单配置。
总结
和参考资料介绍的略不一样,主命令变为了grub2-install
安装的包名字也变了。