what the blog?

{upgrade in progress..}

3

howto reinstall GRUB in rescue mode while using lvm / mdadm

This article is how to activate LVM and mdadm software raid in rescue and reinstall GRUB boot loader, since the boot CD will not do this job for you. By following the steps, you may able to do system recovery or disk operation.

RedHat 5.x

Activate the RAID

mkdir /etc/mdadm
mdadm --examine --scan > /etc/mdadm/mdadm.conf
mdadm -A --scan

RedHat 4.x

Activate the RAID

vi /etc/mdadm.conf

DEVICE /dev/sda1 /dev/sdb1 /dev/sda2 /dev/sdb2

scan it

mdadm --examine --scan >> /etc/mdadm.conf

or put it in /etc/mdadm.conf maunally

DEVICE /dev/sda1 /dev/sdb1 /dev/sda2 /dev/sdb2
ARRAY /dev/md0 level=raid1 devices=/dev/sda1,/dev/sdb1
ARRAY /dev/md1 level=raid1 devices=/dev/sdb2,/dev/sdb2

LVM2

Activate LVM

If your root partition located on logical volume.

lvm pvscan
lvm vgscan
lvm lvscan
lvm vgchange -ay

Reinstall GRUB?

Example Case A:

/boot on md0
/ on md1

Prepare the environment

mkdir /mnt/sysimage
mount /dev/md1  /mnt/sysimage
mount -o bind /dev /mnt/sysimage/dev
mount -o bind /proc /mnt/sysimage/proc
chroot /mnt/sysimage /bin/bash
mount /dev/md0 /boot

Install GRUB

grub
grub>root (hd0,0)
grub>setup (hd0)

Example Case B:

/boot on md0
/ on /dev/VolGroup00/LogVol00

Prepare the environment,

mkdir /mnt/sysimage
mount /dev/VolGroup00/LogVol00  /mnt/sysimage
mount -o bind /dev /mnt/sysimage/dev
mount -o bind /proc /mnt/sysimage/proc
chroot /mnt/sysimage /bin/bash
mount /dev/md0 /boot

Install GRUB

grub
grub>root (hd0,0)
grub>setup (hd0)
linuxlvmmdadm

levin • April 28, 2010


Previous Post

Next Post

Comments

  1. rwheindl November 24, 2010 - 12:03 am Reply

    Excellent Tutorial! Just what I was looking for. Thank you very much.

  2. Anthony_A December 19, 2010 - 3:30 pm Reply

    Thanks a lot to your tutorial you solved my problem.

    • levin December 19, 2010 - 4:02 pm Reply

      Glad to help!!

Leave a Reply