h1. GRUB Bootloader Reinstallation from a Live Environment
h2.
h2. Overview
Use this procedure to reinstall GRUB on a Linux system that is unable to boot. The process uses a live boot environment, mounts the target system, enters a chroot environment, and reinstalls GRUB on the target disk.
h2. Prerequisites
* Boot the server using a Linux live environment (example: R1Soft BMR boot CD).
* Log in as the root user:
{code:bash}
sudo -i
{code}
h2. Procedure
h3. 1. +Create a Mount Point+
{code:bash}
mkdir /r1soft
{code}
h3. 2. +Mount the Target Filesystem+
h3. Standard Root Partition
{code:bash}
mount /dev/sda1 /r1soft
{code}
h3. LVM Root Partition if applicable
First, scan for volume groups and activate them with:
{code:bash}
vgscan
vgchange -ay
{code}
Next, mount the logical volume with:
{code:bash}
mount /dev/vgname/lvname /r1soft
{code}
h3. Separate Boot Partition if applicable
{code:bash}
mount /dev/sda2 /r1soft
mount /dev/sda1 /r1soft/boot
{code}
h3. 3. +Prepare the Chroot Environment+
{code:bash}
mount --bind /proc /r1soft/proc
mount --bind /sys /r1soft/sys
mount --bind /dev/pts /r1soft/dev/pts
mount --bind /dev /r1soft/dev
mount --bind /run /r1soft/run
{code}
h3. 4. +Enter the Chroot Environment+
{code:bash}
chroot /r1soft
{code}
h3. 5. +Back Up Existing GRUB Directory+
*Debian-Based Systems*
{code:bash}
mv /boot/grub /boot/grub_bak
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
mv /boot/grub2 /boot/grub2_bak
{code}
h3. 6. +Reinstall GRUB+
*Debian-Based Systems*
{code:bash}
grub-install /dev/sda
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
grub2-install /dev/sda
{code}
Replace */dev/sda* with the appropriate boot disk if different.
h3. 7. +Regenerate GRUB Configuration+
*Debian-Based Systems*
{code:bash}
update-grub
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
grub2-mkconfig > /boot/grub/grub.cfg
{code}
h3. 8. +Reboot and Validate+
# Exit the chroot environment.
# Reboot the server.
# Remove the live media.
# Confirm the operating system boots successfully.
h2.
h2. Overview
Use this procedure to reinstall GRUB on a Linux system that is unable to boot. The process uses a live boot environment, mounts the target system, enters a chroot environment, and reinstalls GRUB on the target disk.
h2. Prerequisites
* Boot the server using a Linux live environment (example: R1Soft BMR boot CD).
* Log in as the root user:
{code:bash}
sudo -i
{code}
h2. Procedure
h3. 1. +Create a Mount Point+
{code:bash}
mkdir /r1soft
{code}
h3. 2. +Mount the Target Filesystem+
h3. Standard Root Partition
{code:bash}
mount /dev/sda1 /r1soft
{code}
h3. LVM Root Partition if applicable
First, scan for volume groups and activate them with:
{code:bash}
vgscan
vgchange -ay
{code}
Next, mount the logical volume with:
{code:bash}
mount /dev/vgname/lvname /r1soft
{code}
h3. Separate Boot Partition if applicable
{code:bash}
mount /dev/sda2 /r1soft
mount /dev/sda1 /r1soft/boot
{code}
h3. 3. +Prepare the Chroot Environment+
{code:bash}
mount --bind /proc /r1soft/proc
mount --bind /sys /r1soft/sys
mount --bind /dev/pts /r1soft/dev/pts
mount --bind /dev /r1soft/dev
mount --bind /run /r1soft/run
{code}
h3. 4. +Enter the Chroot Environment+
{code:bash}
chroot /r1soft
{code}
h3. 5. +Back Up Existing GRUB Directory+
*Debian-Based Systems*
{code:bash}
mv /boot/grub /boot/grub_bak
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
mv /boot/grub2 /boot/grub2_bak
{code}
h3. 6. +Reinstall GRUB+
*Debian-Based Systems*
{code:bash}
grub-install /dev/sda
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
grub2-install /dev/sda
{code}
Replace */dev/sda* with the appropriate boot disk if different.
h3. 7. +Regenerate GRUB Configuration+
*Debian-Based Systems*
{code:bash}
update-grub
{code}
*AlmaLinux/RHEL-Based Systems*
{code:bash}
grub2-mkconfig > /boot/grub/grub.cfg
{code}
h3. 8. +Reboot and Validate+
# Exit the chroot environment.
# Reboot the server.
# Remove the live media.
# Confirm the operating system boots successfully.