11 feb 2012

Recovery / Reinstall GRUB CentOS - Scientific Linux - RHEL || Recuperar / Reinstalar GRUB en CentOS - Scientific Linux - RHEL

Well, the guide in CentOS wiki, and RHEL docs, about recovery / reinstall GRUB, does not work fine (and are incomplete), not in CentOS 6.x and SL6.x. After a windows reinstall or resize on the partition that contains /boot, the system may no boot properly. So, materials:

1) Live CD or DVD of Fedora 13 or 14 (not 15 or higher) or 1 live CD or DVD of CentOS 6.x or SL6.x
2) Patience

Steps:

1.- Insert the Live Media into CD-ROM Drive and boot it
2.- After the system is completely started, open a terminal and log in as root using su command
3.- Check what partition contain the /boot, i asume that /boot is into / partition, for /boot in other partition, go to point 4.

A) fdisk -l and see what partition is the / that contains the /boot, for example.

 Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        5100    40857600    7  HPFS/NTFS
/dev/sda3   *        5100        7081    15912960   83  Linux
/dev/sda4            7081       60802   431512576    5  Extended
/dev/sda5            7081       28047   168408064   83  Linux
/dev/sda6           28047       28302     2048000   82  Linux swap / Solaris
/dev/sda7           28302       60802   261053440    7  HPFS/NTFS

In the example case, /dev/sda3 is the / and /boot partition, so:

B) Execute step by step the next command

mount /dev/sda3 /mnt
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt

Done, the system has changed to /mnt live CD, DANGER, ANY CHANGE IN THE DISK IS THE REAL SYSTEM, NOT THE LIVE SYSTEM!!!

Reinstall grub in /dev/sda, executing:

grub-install --recheck /dev/sda && sync

Now is done, execute: shutdown -h now, remove the Live CD and start the system.

4.- In case that /boot is a separated partition to /, do this:

mount /dev/sda3 /mnt  (Assuming that /dev/sda3 is / root partition and NOT /boot)
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt

and NOW, mount /boot with:  mount /dev/sdaX /boot (when X is number of /boot partition)

grub-install --recheck /dev/sda && sync
Now is done, execute: shutdown -h now, remove the Live CD and start the system.


----------------------------------------------------------------------------------

Saludos, espero que les haya gustado / ayudado.

Greets, I hope you liked it or it has been useful

No hay comentarios:

Publicar un comentario

Dejá tu comentario