Fixing Linux Crashes and GRUB Issues After Updates

·

4 min read

Fixing Linux Crashes and GRUB Issues After Updates

If you're encountering system crashes after rebooting following an update or upgrade, this guide will help you troubleshoot and resolve the issue. The following steps outline the process I used to fix the problem on my system successfully.

Let us look into the GRUB configuration first.

GRUB configuration

To fix your GRUB configuration by booting into a live USB environment, follow these steps:

  1. Create a Bootable USB:

    First, you’ll need a bootable USB drive with a Linux distribution. You can use tools like Rufus (on Windows) or dd (on Linux) to create this.

    Rufus is simply a GUI which can be used to make USB bootable.

    dd is used in a shell in a Linux system with the command line of

    sudo dd if=path/to/file.iso of=/dev/<device-name> bs=1M status=progress

  2. Boot from USB

    Insert the USB drive into your computer and boot from it entering the BIOS setup or using the boot menu. The menu is often accessed by pressing keys like F2, F10, F12, ESC during boot which is dependent upon the vendor.

  3. Open a Terminal

    Once you’ve booted into the live environment as a guest, then fire up the terminal to perform the remaining steps.

  4. Identify Partitions

    Identify the partitions of your installed Linux system. You can use the GUI gparted which can be installed using the command sudo apt install gparted or can be used lsblk or fdisk -l command to list the partitions. Look for your root partition and your EFI or boot partition (if applicable).

  5. Mount the Partitions

    Mount the necessary partitions. You’ll need to mount the root partition and the EFI/boot partition(if applicable).

    Let us assume /dev/sda2 is your root partition and /dev/sda1 is your EFI/boot partition then we can use the following command to mount:

    sudo mount /dev/sda1 /mnt/boot/efi #only if you have EFI file

    sudo mount /dev/sda2 /mnt

  6. Bind Mount System Directories

    Bind mount the necessary system directories. The bind option of the mount command allows you to remount part of a file hierarchy at a different location while it is still available at the original location.

    sudo mount —bind /dev /mnt/dev

    sudo mount —bind /proc /mnt/proc

    sudo mount —bind /sys /mnt/sys

    sudo mount —bind /run /mnt/run

  7. Chroot into Mounted System

    Change root into the mounted system:

    sudo chroot /mnt

  8. Edit GRUB Configuration

    Now, you can edit the GRUB configuration file. Open the GRUB configuration file located /etc/default/grub using any text editor, such as nvim, vim, nano or any other editor.

    using nano: nano /etc/default/grub

    using vim: vim /etc/default/grub

    Find the line that sets the GRUB timeout and change it. For example, change

    GRUB_TIMEOUT=0 to GRUB_TIMEOUT=10.

    Save the file and exit the editor (in nano, you can save by pressing CTRL+O, to exit CTRL+X; in vim or nvim press esc and then type :wq which will save and exit.

  9. Update GRUB

    To apply the changes you made just runt the command

    update-grub

  10. Exit Chroot and Umount Partitions

    Exit the Chroot environment and unmount the partitions

    exit

    sudo umount /mnt/boot/efi

    sudo umount /mnt/dev

    sudo umount /mnt/proc

    sudo umount /mnt/sys

    sudo umount /mnt/run

    sudo umount /mnt

  11. Reboot

    Finally, reboot your system

    sudo reboot

Remove the USB drive and let your system boot normally. The GRUB menu should now appear with the updated timeout value. By these steps, you should be able to edit your GRUB configuration and fix the issue with the boot menu not showing.

Update error system not rebooting

For this case, Follow the above steps up to 7 then run

sudo apt update && sudo apt upgrade

using the above command you can be able to recover your system.

If the system still through the error then follow the steps:

  1. Connect to internet

    Make sure your PC is connected to the internet either by ethernet or wireless.

  2. Manually Download the deb files

    When running the command sudo apt update or sudo apt upgrade when there is any error like suppose libglibd-2.0-0. If so, then visit the link https://packages.debian.org/stable/libs/libglibd-2.0-0 from where depending upon your system you have to download manually and install using dpkg.

    Repeat the process until update or upgrade stops throwing errors. After the success of update and upgrade move to next step.

  3. Reboot

    After the success in update and upgrade of the system reboot the system and remove USB and let your system boot normally.

Whether it's editing the GRUB timeout, addressing boot menu visibility, or recovering from update errors, these methods provide a reliable way to troubleshoot common issues. If you continue to encounter problems, make sure to check for specific error messages, consult the community for guidance and do proper research before you apply. By applying the above methods, the problem within my system was solved.