Skip to content

sscansan/Fedora_kernel_restore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Fedora_kernel_restore


  1. Ensure You Have the Correct Boot Partition

You mentioned that the boot partition is located on /dev/nvme1n1p2. Let's confirm the structure of your partitions again to ensure the boot partition is mounted in the right place.

  1. Run the following command to verify your partitions:

sudo lsblk

Look for your /dev/nvme1n1p2 partition, which should be the boot partition.


  1. Create the Correct Mount Point

Before mounting the boot partition, we need to make sure the /mnt/boot directory exists.

  1. Make sure you're in the /mnt directory (or use it as the root of your mounted system):

cd /mnt

  1. Create the /mnt/boot directory if it doesn't already exist:

sudo mkdir -p /mnt/boot


  1. Mount the Boot Partition

Now that the /mnt/boot directory exists, mount your boot partition to this directory:

sudo mount /dev/nvme1n1p2 /mnt/boot

If you also have a separate EFI partition (which is typically required for UEFI boot), ensure it's mounted correctly too. Here's how to mount the EFI partition:

  1. Create the /mnt/boot/efi directory (if it doesn't exist already):

sudo mkdir -p /mnt/boot/efi

  1. Mount the EFI partition to /mnt/boot/efi:

sudo mount /dev/nvme1n1p1 /mnt/boot/efi


  1. Chroot and Continue with Kernel Reinstallation

Once the boot and EFI partitions are mounted correctly, you can proceed with the chroot process to reinstall the kernel:

  1. Bind the necessary directories:

sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo mount --bind /run /mnt/run

  1. Chroot into the mounted system:

sudo chroot /mnt


  1. Reinstall or Update the Kernel

Now that the partitions are mounted and you're inside the chroot, reinstall the kernel:

  1. Refresh your package metadata:

sudo dnf update --refresh

  1. Reinstall the kernel and necessary modules:

sudo dnf reinstall kernel kernel-core kernel-modules


  1. Rebuild the GRUB Configuration

After reinstalling the kernel, rebuild the GRUB configuration to ensure your system boots correctly.

For UEFI systems, run:

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg


  1. Exit Chroot and Reboot

  2. Exit the chroot environment:

exit

  1. Unmount all partitions:

sudo umount /mnt/run /mnt/sys /mnt/proc /mnt/dev /mnt/boot /mnt/boot/efi

  1. Reboot the system:

sudo reboot


  1. Verify the Kernel

After rebooting, check that your system is running the correct kernel:

uname -r


–----------------

  1. Verify if /bin/bash Exists

It seems that the root filesystem (/mnt) might not be correctly mounted, or there's an issue with the directory structure.

  1. Check the mounted partitions:

From the live USB, run the following to ensure your root filesystem (/dev/mapper/myroot) is mounted correctly:

sudo lsblk

This should show that /dev/mapper/myroot is mounted at /mnt.

  1. Verify the files inside the chroot environment:

Check if /mnt/bin/bash exists:

ls /mnt/bin/bash

If the output is No such file or directory, it means the root filesystem wasn't properly mounted, or it's missing necessary files.


  1. Recheck the Mounting Process

Make sure all necessary partitions are mounted correctly. Follow these steps:

  1. Unlock the LUKS partition (if you haven't already):

sudo cryptsetup luksOpen /dev/nvme1n1p3 myroot

  1. Mount the root partition: Mount the unlocked LUKS partition to /mnt:

sudo mount /dev/mapper/myroot /mnt

  1. Check the contents of /mnt: Verify that /mnt/bin/bash exists:

ls /mnt/bin/bash

If /mnt/bin/bash is still missing, your root partition may not be mounted correctly.

  1. Mount the boot partition:

sudo mount /dev/nvme1n1p2 /mnt/boot

  1. Mount the EFI partition (if applicable):

sudo mount /dev/nvme1n1p1 /mnt/boot/efi


  1. Bind Necessary Directories Before Chroot

If the root filesystem is properly mounted and /bin/bash exists, but chroot still fails, make sure you're binding the necessary directories:

  1. Bind /dev, /proc, /sys, and /run to /mnt:

sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo mount --bind /run /mnt/run

  1. Try to chroot again:

sudo chroot /mnt


  1. Alternative: Use /bin/sh Instead of /bin/bash

If /bin/bash is missing but /bin/sh exists, you can try using /bin/sh instead of /bin/bash as the shell for chroot.

To do this, run the following:

sudo chroot /mnt /bin/sh

This should allow you to access the chroot environment even if /bin/bash is not available.


  1. Reinstall Kernel After Successful Chroot

Once inside the chroot environment (using either /bin/bash or /bin/sh), proceed to reinstall the kernel and update the GRUB configuration.

  1. Update the system and reinstall the kernel:

sudo dnf update --refresh sudo dnf reinstall kernel kernel-core kernel-modules

  1. Rebuild the GRUB configuration:

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg


  1. Exit Chroot and Unmount

After making the necessary changes, exit the chroot environment and unmount the partitions:

  1. Exit the chroot environment:

exit

  1. Unmount the partitions:

sudo umount /mnt/run /mnt/sys /mnt/proc /mnt/dev /mnt/boot /mnt/boot/efi

  1. Reboot:

sudo reboot


  1. Verify the Kernel

After rebooting, verify that your system is running the correct kernel:

uname -r

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published