Installing A New Bootloader
So I recently had a need to install a new bootloader in Ubuntu. I had a machine that was using Systemd bootctl as the bootloader. I was doing that becasuse I primarily used an Arch Linux install on that machine and for some reason I always thought configuring Grub was more difficult then bootctl on Arch. This was probably very foolish thinking and came down to me being to lazy to learn a little about Grub. One issue I always ran into with bootctl was it's inability to read LVM partitions. Why am I using a bootloader that can't read LVM when I insist on using LVM on my machines? Anyway, decided it was time to figure it all out. It's really easy...
Installing Grub On Ubuntu
So if you have installed Ubuntu without a bootloader with ubiquity --no-bootloader
,
here is what you need to do to install Grub2 on a AMD64 EFI system.
apt-get install grub-efi grub-efi-amd-signed
this will install Grub2 and the optional secure boot signed grub image from Canonical.sudo grub-install --bootloader-id=GRUB --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
- bootloader-id can be whatever you want, this is how it will be named in the UEFI list of boot options
- efi-directory is wherever you mount your EFI System Partition, usually
/boot/efi
- target the hardware architecture of the system
- uefi-secure-boot is optional, this installs the signed image we optionally downloaded.
Sometimes this works and sometimes it doesn't. My desktop is happy to have secure boot enabled with this image. My Dell (that came with Ubuntu pre-installed) still won't allow me to keep secure boot on with that image.
sudo update-grub
this command will do several things.- update the grub config file using options in
/etc/default/grub
and/etc/grub.d/
- use
os-prober
to scan the disks for other OS installs and create Grub entires for them as well - run
efibootmgr
and set the default boot option to the bootloader that was just installed
- update the grub config file using options in
That's it. Reboot and your system should automatically boot to the new bootloader and you can boot into your system again.