2017-12-13 11:45:40 +00:00
|
|
|
[[restoring-bootloader-using-live-disk]]
|
2018-01-20 17:59:12 +00:00
|
|
|
= Restoring the bootloader using the Live disk.
|
2017-12-13 11:45:40 +00:00
|
|
|
|
2021-01-09 11:33:12 +00:00
|
|
|
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.
|
2017-12-13 11:45:40 +00:00
|
|
|
|
2021-01-09 11:33:12 +00:00
|
|
|
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*.
|
2017-12-13 11:45:40 +00:00
|
|
|
|
|
|
|
.Before you start
|
|
|
|
|
2018-01-20 17:59:12 +00:00
|
|
|
* Get the Fedora Live ISO from link:https://download.fedoraproject.org/pub/fedora/linux/releases/[getfedora.org].
|
|
|
|
|
2017-12-13 11:45:40 +00:00
|
|
|
* 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.
|
2021-01-09 11:33:12 +00:00
|
|
|
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
sudo fdisk -l
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
2021-01-09 11:33:12 +00:00
|
|
|
|
2022-05-22 03:46:58 +00:00
|
|
|
== For Default Installation in LVM.
|
2017-12-13 11:45:40 +00:00
|
|
|
|
|
|
|
. Create the mount point for the root partition.
|
|
|
|
+
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
mkdir -p /mnt/root
|
2021-01-09 11:33:12 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
If you are using the default Fedora layout, there will be one `/dev/sda1`
|
|
|
|
partition that holds the `/boot` directory and one `/dev/mapper/fedora-root`
|
|
|
|
that holds the root file system.
|
2017-12-13 11:45:40 +00:00
|
|
|
|
|
|
|
. Mount the root partition on the mount point.
|
|
|
|
+
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
mount /dev/mapper/fedora-root /mnt/root
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
. Mount the boot partition in the `boot` directory of the filesystem that you have mounted in the previous step.
|
2022-04-14 17:19:42 +00:00
|
|
|
+
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
mount /dev/sda1 /mnt/root/boot/
|
|
|
|
----
|
|
|
|
|
|
|
|
. Mount system processes and devices into the root filesystem in `/mnt/root`.
|
|
|
|
+
|
|
|
|
----
|
|
|
|
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
|
|
|
|
----
|
|
|
|
|
2022-04-14 17:19:42 +00:00
|
|
|
. If you use EFI boot, you may also want to bind the efivars and the EFI system partition:
|
2021-11-21 11:43:49 +00:00
|
|
|
+
|
2022-04-14 17:19:42 +00:00
|
|
|
----
|
|
|
|
mount -o bind /sys/firmware/efi/efivars /mnt/root/sys/firmware/efi/efivars
|
|
|
|
mount <efi system partition> /mnt/root/boot/efi
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
|
2022-04-14 17:19:42 +00:00
|
|
|
. Change your filesystem into the one mounted under `/mnt/root`.
|
|
|
|
+
|
2021-11-21 11:43:49 +00:00
|
|
|
----
|
|
|
|
chroot /mnt/root
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
|
|
|
|
2022-05-22 03:46:58 +00:00
|
|
|
== For Default Installation in BTRFS
|
2021-01-09 11:33:12 +00:00
|
|
|
|
|
|
|
. Create the mount point for the root partition.
|
2021-11-21 11:43:49 +00:00
|
|
|
+
|
2021-01-09 11:33:12 +00:00
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
mkdir -p /mnt/
|
2021-01-09 11:33:12 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
If you are using the default Fedora layout, there will be one `/dev/sda1`
|
|
|
|
partition that holds the `/boot` directory and one `/dev/sda2` that holds the root file system.
|
|
|
|
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
mount /dev/sda2 /mnt
|
|
|
|
mount /dev/sda1 /mnt/root/boot
|
|
|
|
----
|
|
|
|
|
|
|
|
. Change your filesystem into the one mounted under `/mnt/root`.
|
|
|
|
+
|
|
|
|
----
|
|
|
|
chroot /mnt/root
|
2021-01-09 11:33:12 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
IMPORTANT: Home Partition is mounted automatically under `/mnt/home`
|
|
|
|
|
2022-05-22 03:46:58 +00:00
|
|
|
== For Default Installation in LUKS.
|
2021-01-09 11:33:12 +00:00
|
|
|
|
2021-11-21 11:43:49 +00:00
|
|
|
. Make sure crypt module in use:
|
2017-12-13 11:45:40 +00:00
|
|
|
+
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
sudo modprobe dm-crypt
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
|
|
|
|
2021-11-21 11:43:49 +00:00
|
|
|
. Find out which drive it was with the following command:
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo fdisk -l
|
|
|
|
----
|
|
|
|
|
|
|
|
You must mount `/dev/sda3 myvolume`
|
|
|
|
|
|
|
|
. Use `cryptsetup`, device is accessible under `/dev/mapper/myvolume``
|
2017-12-13 11:45:40 +00:00
|
|
|
+
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
sudo cryptsetup luksOpen /dev/sde3 myvolume
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
|
|
|
|
2021-11-21 11:43:49 +00:00
|
|
|
. Scan for LVM volumes and choose the right volume group name that you are looking for:
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo vgscan
|
|
|
|
----
|
|
|
|
|
|
|
|
. If it is eg. Fedora, activate it
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo vgchange -ay system
|
|
|
|
----
|
|
|
|
|
|
|
|
. Find out root volume
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo lvs
|
|
|
|
----
|
|
|
|
|
|
|
|
. Mount it with the following command:
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo mount /dev/system/root /mnt/
|
|
|
|
----
|
|
|
|
|
|
|
|
. To work in the volume use the following commands
|
|
|
|
+
|
|
|
|
----
|
|
|
|
sudo mount --bind /dev /mnt/dev
|
|
|
|
sudo mount --bind /dev/pts /mnt/dev/pts
|
|
|
|
sudo mount --bind /proc /mnt/proc
|
|
|
|
sudo mount --bind /sys /mnt/sys
|
|
|
|
sudo chroot /mnt
|
|
|
|
----
|
|
|
|
|
|
|
|
IMPORTANT: consider mounting `/boot` also.
|
|
|
|
|
|
|
|
== Continue with the follow Procedure.
|
|
|
|
|
2021-01-09 11:33:12 +00:00
|
|
|
. Regenerate the *GRUB2* configuration file and reinstall the bootloader
|
|
|
|
into the MBR, as described in xref:adding-other-operating-systems-grub2[Adding other operating systems to the *GRUB2* menu].
|
2017-12-13 11:45:40 +00:00
|
|
|
|
|
|
|
. Exit this temporary root filesystem.
|
|
|
|
+
|
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
exit
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
. Your bootloader should be now restored. Reboot your computer to boot into your normal system.
|
2021-01-09 11:33:12 +00:00
|
|
|
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|
2021-11-21 11:43:49 +00:00
|
|
|
systemctl reboot
|
2017-12-13 11:45:40 +00:00
|
|
|
----
|