(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/nvme0n1 --part 1 --label Ubuntu --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
 
# set boot order
efibootmgr --bootorder 0,1,2,9,A,B,C
 
# install grup
grub-install --efi-directory=/mnt/efi
 
# mount efivarfs
mount -t efivarfs efivarfs /sys/firmware/efi/efivars

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/