(U)EFI

# check if EFI is enabled
ll /sys/firmware/efi
 
# install efibootmgr
sudo apt-get install -y efibootmgr
 
# list entries
efibootmgr -v
 
# create entry
efibootmgr --create --disk /dev/sda --part 1 --label "Ubuntu /dev/sda" --loader \\EFI\\UBUNTU\\GRUBX64.EFI
 
# delete entry
sudo efibootmgr --delete-bootnum -b 0006
 
# delete all non default entry
for BOOT_ID in $(efibootmgr | grep Boot0 | egrep -v "Built-in|PXE" | cut -d" " -f1 | awk '{print substr($0,5,4)}'); do
    efibootmgr -b ${BOOT_ID} -B
done
 
# install grup
grub-install --efi-directory=/mnt/efi

Links
https://wiki.archlinux.de/title/UEFI_Installation
https://www.gnu.org/software/parted/manual/html_node/set.html
https://www.systutorials.com/docs/linux/man/8-grub-install/