Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux GRUB Manual Installation

In this tutorial, we'll guide you through the manual installation of the GRUB bootloader on a Linux system. This can be useful in cases where GRUB was not installed correctly during the initial OS installation, or when you need to recover a damaged GRUB installation.

Before starting, it's important to note that this tutorial assumes you have a working Linux system installed, but the GRUB bootloader is missing or damaged.

  • Boot into a Linux live environment using a live USB or CD.

  • Open a terminal and identify your target drive and root partition:

sudo fdisk -l

In this tutorial, we'll assume that the target drive is /dev/sda and the root partition is /dev/sda1.

  • Mount the root partition of your installed Linux system:
sudo mount /dev/sda1 /mnt
  • Install GRUB on the MBR (Master Boot Record) or EFI System Partition (ESP), depending on your system type:

For BIOS systems:

sudo grub-install --boot-directory=/mnt/boot /dev/sda

For UEFI systems:

First, mount the ESP (we'll assume it's /dev/sda2):

sudo mkdir /mnt/boot/efi
sudo mount /dev/sda2 /mnt/boot/efi

Then, install GRUB:

sudo grub-install --target=x86_64-efi --efi-directory=/mnt/boot/efi --boot-directory=/mnt/boot --bootloader-id=grub
  • Generate the GRUB configuration file:
sudo chroot /mnt
sudo update-grub
  • Exit the chroot environment and unmount the filesystems:
exit
sudo umount /mnt/boot/efi  # Only needed for UEFI systems
sudo umount /mnt
  • Reboot your system:
sudo reboot

Your system should now boot using the GRUB bootloader.

In summary, manual GRUB installation involves booting into a Linux live environment, mounting the root partition, installing the GRUB bootloader, and generating the GRUB configuration file. This process can help you recover a damaged GRUB installation or properly configure GRUB on a system where it was not installed correctly.

  1. Installing GRUB without a bootloader manager:

    When installing GRUB without a bootloader manager, you are essentially installing GRUB directly to the Master Boot Record (MBR) or the EFI System Partition (ESP) without relying on a separate manager. This is common in scenarios where you want more control over the boot process.

    Example code (MBR):

    sudo grub-install /dev/sdX
    

    Example code (UEFI):

    sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
    
  2. Linux GRUB installation from scratch:

    Installing GRUB from scratch involves compiling the GRUB source code and installing it on the system.

    Example code:

    ./configure
    make
    sudo make install
    
  3. Configuring GRUB manually for custom setups:

    Manually configuring GRUB involves editing the GRUB configuration file (grub.cfg) to customize boot options, kernel parameters, and other settings.

    Example code:

    sudo nano /etc/default/grub
    sudo update-grub
    
  4. GRUB bootloader manual installation process:

    The manual installation process involves understanding the disk layout, specifying the target device, and installing GRUB to the specified location.

    Example code:

    sudo grub-install /dev/sdX
    
  5. Manually installing GRUB on specific partitions:

    Installing GRUB on a specific partition is useful in cases where you want to have multiple operating systems on different partitions.

    Example code:

    sudo grub-install /dev/sdXY
    
  6. GRUB installation commands and options:

    GRUB installation commands include options for specifying the target architecture, installation directory, bootloader ID, etc.

    Example code:

    sudo grub-install --target=i386-pc --recheck /dev/sdX
    
  7. Troubleshooting common issues in GRUB manual installation:

    Troubleshooting may involve fixing issues with the GRUB configuration, resolving dependencies, or checking disk partitions.

    Example code:

    sudo grub-mkconfig -o /boot/grub/grub.cfg
    
  8. Advanced configurations with manually installed GRUB on Linux:

    Advanced configurations may include setting up custom themes, password protection, or configuring specific boot options.

    Example code:

    sudo grub-mkconfig -o /boot/grub/grub.cfg