If you have leftover boot entries from old OS installations (like Windows, another Linux distro, etc.), you can clean them up in Linux by following these steps:
1. Check Current Boot Entries
Run the following command to list all available boot entries:
sudo efibootmgrYou will see output like this:
BootCurrent: 0001
BootOrder: 0001,0002,0003,0004
Boot0001* Ubuntu
Boot0002* Windows Boot Manager
Boot0003* Fedora
Boot0004* ManjaroThis shows all boot entries stored in your system’s UEFI firmware.
2. Remove Unwanted Boot Entries
To remove a specific boot entry, use:
sudo efibootmgr -b XXXX -BReplace XXXX with the actual boot number. For example, to remove the Windows Boot Manager (Boot0002):
sudo efibootmgr -b 0002 -B3. Delete Leftover OS Files (If Necessary)
If you previously installed another OS, its files might still be present in the EFI partition. To remove them:
Mount the EFI Partition
First, check which partition is the EFI partition:
lsblkTypically, it’s something like /dev/sdX1 or /dev/nvme0n1p1. Mount it:
sudo mount /dev/sdX1 /mntDelete Unused Boot Directories
Navigate to the EFI boot folder:
cd /mnt/EFI
lsYou might see folders like Ubuntu, Microsoft, Fedora, etc. If you want to remove, say, Fedora:
sudo rm -rf FedoraThen unmount:
sudo umount /mnt4. Update GRUB (If Using GRUB Bootloader)
If the old OS still appears in GRUB but is no longer installed, update GRUB:
sudo update-grub # Debian/Ubuntu
sudo grub2-mkconfig -o /boot/grub2/grub.cfg # RHEL/Fedora5. (Optional) Reset Boot Order
If your system still prioritizes an old OS in the boot order, you can change it:
sudo efibootmgr -o 0001,0004 # Adjust based on your preferred orderFinal Step: Reboot
After everything, reboot your system:
sudo rebootNow your boot menu should be clean! Let me know if you need further clarification. 🚀