Mobile hard disk GPT mode to install Linux system support legacy and uefi dual boot

I have done a test before, which is to install fedora-v33 on the mobile hard disk, GPT hard disk mode, thinkpadx230, boot mode is BOTH, UEFI first is installed in legacy mode, it is not pure GPT+UEFI, which makes me very embarrassed . Because I have an idea, I want this system to run in both legacy and UEFI modes. I manually create an EFI partition, and then manually add a boot. It can be realized for the time being. After a long time, there are few relevant information on the Internet. I have seen votry, which is to install with mbr partition first, and then create EFI partition, which realizes the booting of different ISO CD files.
My approach is as follows: first convert the hard drive to GPT mode, use disgenius to separate a 512M UEFI partition (it must be FAT32, this has been tried for a long time, Lenovo’s UEFI mode does not support FAT16 very well), and change the notebook’s BIOS to Legacy first /legacy only or BOTH will do, install linux as usual (I tried fedorav33 and kali2020.4), just use the remaining disk space to install! (Note: fedora-v33 uses btrfs by default. If there is no such driver module in Method A, there will be some problems in startup).
Solution:
A. Use the almighty grubx86.efi generated by uefi for windows, rename it to bootx86.efi and copy it to /EFI/boot/.
After Uefi only starts,
1. After starting, an error
message prompts grub rescue> 2. Enter the ls command to view the partition information; a
message like (hd0, gpt0)... will appear
3. Enter set to view the current configuration;
generally the following information is displayed and it cannot be booted Booting is generally the partition specified by the prefix is ​​wrong:
cmdpath=(hd0,gtp1)/EFI/Manjaro
prefix=(hd0,gpt1)/boot/grub
root=hd0,gpt1
4. Enter the format of the value of ls prefix, such as ls (hd0,gpt3)/boot/grub, if it prompts filesystem unmount, replace gpt3 with something else Numbers, try the partitions displayed by ls one by one until a prompt such as ./ …/ x86_64-efi/ grubenv locale/ themes/ appears;
5. After finding the correct grub partition, such as gpt3, use set prefix=(hd0,gpt3 )/boot/grub set the grub path
6. Then set the root partition set root=hd0,gpt3
7. Then execute the following command, you can enter the system normally ;
insmod normal
normal
starts normally, the analysis is because we did not install grubefi normally, so Special environment variables need to be added in /EFI/grub/grub.cfg:
Set prefix=(hd0,gpt3)/boot/grub
Set root=hd0,gpt3
Since the software is packaged as the default prefix path, it is necessary to manually change the environment variable to start . You can change the batch script of .BAT or .bash when you package it with the software, and change -p to the actual path of your mobile system. Since the disc recognition order of each machine is different, I didn't change it. I changed it and started it by myself, but it was a little more troublesome.
  Of course, you can also make a menu and put it in the /boot/grub/grub.cfg of the esp partition, which is more convenient.

B. Use the /efi/kali2020-mob/grubx86.efi regenerated by linuxt, rename it to bootx86.efi and copy it to /EFI/boot/.
#yum install grub2-efi-x64-modules /#apt-get install grub2-efi-x64-modules
#mkdir /media/efi
#mount /dev/sda1 /media/efi
#grub-install --target=x86_64-efi --efi-directory=/media/efi --bootloader-id=kali2020-mob
may report an error, but
/efi/kali2020-mob/grubx86 has been generated.efi uses linuxt to regenerate /efi/kali2020-mob/grubx86. efi, rename it to bootx86.efi and copy it to /EFI/boot/.
After Uefi only starts, it starts normally.

Guess you like

Origin blog.csdn.net/seaship/article/details/111428690