Grub2, chroot on mdadm RAID 1

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Grub2, chroot on mdadm RAID 1

Post by ^rooker »

Trying to install GRUB on 2TB harddisks, GPT with software RAID 1...

grub-install in chroot of mounted md127 throws error:
grub-install /dev/sda
/usr/sbin/grub-probe: error: no such disk.
Auto-detection of a filesystem of /dev/md127 failed.
I had to install "mdadm" on the target (chroot) system.
Next error:

Code: Select all

$ grub-probe -d /dev/md127
Returned:
grub-probe: error: no such disk.
Changed to metadata version of the mdadm RAID to 0.90.

Had to add "--recheck". Then it worked:

Code: Select all

$ grub-install --recheck /dev/sda"
Uncomfortable.

Links:
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Re: Grub2, chroot on mdadm RAID 1

Post by ^rooker »

Workaround for initial boot (OS root on first partition of "md/0") - with mdadm metadata version 1.2 (!)

Code: Select all

ls
ls (md/0,msdos1)/
set root=(md/0,msdos1)
ls /
set prefix=(md/0,msdos1)/boot/grub
insmod mdraid
insmod linux
normal
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Re: Grub2, chroot on mdadm RAID 1

Post by ^rooker »

The above notes seem to be incomplete. At least, the didn't work like that the 2nd time I ran into the same problem.

Here are new notes:
  • target system =Debian 6 (Squeeze)
  • Partition the disks for target system:
    20GB (filetype "fd" = Linux raid autodetect)
    Leave rest unpartitioned. Starting at sector 2048 (1TB disks)
  • Create the mdadm RAID1 for the target system:
    mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
    20 GB (ext4) (5% reserved for root)
  • mount target system (Debian Squeeze) on Live distro (Ubuntu 14.04)
  • mount sys,proc,dev on target system:
    mount -o bind /sys <target>/sys
    mount -o bind /proc <target>/proc
    mount -o bind /dev <target>/dev
  • chroot to the target system
On the chrooted target system:
  • grub-mkdevicemap -n
  • update-grub
  • grub-install /dev/sda
    grub-install /dev/sdb
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply