How to Re-install GRUB Loader on Oracle Linux 5/6

GOAL

Under some rare conditions, you may get a GRUB loader corruption.

This article illustrates how to re-install the GRUB loader on Oracle Linux 5 or 6.

Symptoms

1) The GRUB menu is not shown when booting the server

2) Boot the server into rescue mode using installation DVD, and check the header of the booting disk

If the GRUB loader is corrupted:

# file -s /dev/sda
/dev/sda: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 64998927 sectors; partition 2: ID=0x82, starthead 254, startsector 64998990, 2104515 sectors

While a good one looks like:

# file -s /dev/sda
/dev/sda: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 64998927 sectors; partition 2: ID=0x82, starthead 254, startsector 64998990, 2104515 sectors, code offset 0x48

The output may vary from different releases, but the key point is that the first output is missing ‘code offset 0x48‘, which is a indicator of GRUB Stage 1 code.

SOLUTION

For native Oracle Linux:

Let’s assume that the booting disk is sda, the / partition is sda2, and /boot partition is sda1.

1) Boot the server into rescue mode, and mount the filesystem automatically, Please refer to: How to Boot Oracle Linux into Rescue Mode
The / partition would be mounted under /mnt/sysimage automatically.
If not, mount it manually:

# mount /dev/sda2 /mnt/sysimage

 

2) Mount the /boot partition and /dev manually, to prepare the chroot environment:

# mount /dev/sda1 /mnt/sysimage/boot
# mount -o bind /dev /mnt/sysimage/dev
# chroot /mnt/sysimage

 

3) Re-install the GRUB loader

# grub-install /dev/sda

For Oracle Linux on Engineered System Exadata:

1) Boot the server with Exadata diagnostics iso
The / partition would be mounted under /mnt/cell automatically.
2) Mount the /boot partition and /dev manually, to prepare the chroot environment

# mount /dev/sda1 /mnt/cell/boot
# mount -o bind /dev /mnt/cell/dev
# chroot /mnt/cell

 

3) Re-install the GRUB loader

# grub-install /dev/sda

Comment

*

沪ICP备14014813号

沪公网安备 31010802001379号