I have now installed the Debian 12 live environment on the USB drive and installed my own assembled Linux system (root file system compiled through busybox, grub.cfg created by myself, and Linux kernel compiled by myself) on the hard drive /dev/sda
using the live environment. I encountered a problem when executing:grub-install --target=x86_64-efi --root-directory=/mnt --boot-directory=/mnt/boot /dev/sda --force --efi-directory=/boot/efi --recheck
, the following message is reported:`
I found a similar problem(https://unix.stackexchange.com/questions/405472/cannot-find-efi-directory-issue-with-grub-install), but following the above steps did not solve my problem.
I am a beginner and I am not sure where I wrote the problem.
1#,Divided the hard drive /dev/sda
into three partitions:
/dev/sda1
/dev/sda2
/dev/sda3
2#,Set sda1 as efi partition at the same time:
$sudo fdisk /dev/sda -l
...
Device Start End Sectors Size Type
/dev/sda1 ..... EFI System
/dev/sda2 ..... Linux System
/dev/sda3 ..... Linux System
3#,Format these 3 partitions:
/sbin/mkfs.fat -F32 /dev/sda1
/sbin/mkfs.ext4 /dev/sda2
/sbin/mkfs.ext4 /dev/sda3
4#, Mount them separately in different paths:
mount /dev/sda1 /mnt/boot/efi
mount /dev/sda2 /mnt/boot
mount /dev/sda3 /mnt
5#,chroot
and enter a new bash
sudo chroot /mnt/
bash-5.2# grub-install --target=x86_64-efi --root-directory=/mnt --boot-directory=/mnt/boot /dev/sda --force --efi-directory=/boot/efi --recheck
Installing for x86_64-efi platform.
grub-install:error:/boot/efi does't look like an EFI partition.