[[restoring-bootloader-using-live-disk]] = Restoring the bootloader using the Live disk. Sometimes, especially after a secondary operating systems has been installed, the master boot record gets damaged which then prevents the original Linux system from booting. If this happens, it is necessary to reinstall *GRUB2* to recreate the original settings. The process not only discovers all installed operating systems, but usually adds them to the *GRUB2* configuration files, so they will all become bootable by *GRUB2*. .Before you start * Get the Fedora Live ISO from link:https://download.fedoraproject.org/pub/fedora/linux/releases/[getfedora.org]. * Prepare a bootable device using the downloaded ISO, either a CD or a USB. .Procedure . Boot the Fedora live system from the bootable device you have created. . Open the terminal. . Examine the partition layout and identify the `boot` and the `root` partition. + ---- sudo fdisk -l ---- == BTRFS filesystem If your `root` partition is encrypted by LUKS, it must be decrypted: . Make sure the crypt module is in use: + ---- sudo modprobe dm-crypt ---- . Decrypt the `root` partition: + ---- sudo cryptsetup luksOpen myvolume ---- + The decrypted device (i.e. `myvolume`) will be accessible under `/dev/mapper/`. Mount the `root` partition: * For LUKS: + ---- mount /mnt -o subvol=root ---- * For non-LUKS: + ---- mount /mnt -o subvol=root ---- Mount the `boot` partition: ---- mount /mnt/boot ---- Mount system processes and devices into the `root` filesystem: ---- mount -o bind /dev /mnt/dev mount -o bind /proc /mnt/proc mount -o bind /sys /mnt/sys mount -o bind /run /mnt/run ---- On UEFI systems, bind the efivars directory and mount the EFI system partition: ---- mount -o bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars mount /mnt/boot/efi ---- Change your filesystem to the one mounted under `/mnt/`: ---- chroot /mnt/ ---- Re-install GRUB: * On UEFI systems, several packages are required: + ---- dnf reinstall shim-* grub2-efi-* grub2-common ---- * On BIOS systems, specify the disk where GRUB should be installed: + ---- grub2-install ---- Re-generate the GRUB configuration file: ---- grub2-mkconfig -o /boot/grub2/grub.cfg ---- Sync and exit the chroot: ---- sync && exit ---- Reboot the system. == LVM filesystem If your `root` partition is encrypted by LUKS, it must be decrypted: . Make sure the crypt module is in use: + ---- sudo modprobe dm-crypt ---- . Decrypt the `root` partition: + ---- sudo cryptsetup luksOpen myvolume ---- . Scan the LVM volumes for the volume group corresponding to the `root` partition: + ---- sudo vgscan ---- . Activate the volume group: + ---- sudo vgchange -ay ---- . Find the root volume: + ---- sudo lvs ---- + The root volume will be accessible under `/dev/`. Create a `root` directory under `/mnt`: ---- mkdir -p /mnt/root ---- Mount the logical volume of the `root` partition: * For LUKS, substitute the root volume from above: + ---- mount /mnt/root ---- * For non-LUKS, use `lsblk` to find the `lvm` that corresponds to the `root` partition (the `lvm` should be under `/dev/mapper/`): + ---- mount /mnt/root ---- Mount the `boot` partition: ---- mount /mnt/root/boot ---- Mount system processes and devices into the `root` filesystem: ---- mount -o bind /dev /mnt/root/dev mount -o bind /proc /mnt/root/proc mount -o bind /sys /mnt/root/sys mount -o bind /run /mnt/root/run ---- On UEFI systems, bind the efivars directory and mount the EFI system partition: ---- mount -o bind /sys/firmware/efi/efivars /mnt/root/sys/firmware/efi/efivars mount /mnt/root/boot/efi ---- Change your filesystem to the one mounted under `/mnt/root`: ---- chroot /mnt/root/ ---- Re-install GRUB and re-generate the GRUB configuration file: * On UEFI systems, several packages are required: + ---- dnf reinstall shim-* grub2-efi-* grub2-common grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg ---- * On BIOS systems, specify the disk where GRUB should be installed: + ---- grub2-install grub2-mkconfig -o /boot/grub2/grub.cfg ---- Sync and exit the chroot: ---- sync && exit ---- Reboot the system.