6

I am trying to convert my single disk boot to a raid1 boot

So far here is what i have:

  • I sucessfully create the raid 1 as degraded with the new drive alone, I copied all the data on it
  • I can mount that raid 1, see its files etc
  • I already have a raid5 that is working on the same box (although not booting on it)
  • I have installed grub on both drive
  • When grub boot, it loads the kernel alright, but during the kernel boot it fails to load the "root block device"

The kernel tells me : 1 - detected that root device is an md device 2 - determining root devices 3 - mounting root 4 - mounting /dev/md125 on /newroot failed: input/output error. Please enter another root device: ...

At this point, if I enter /dev/sda3 (my "old" root device that isn't converted to raid yet) everything boots fine without the root. The /dev/md125 device is indeed created but it seems to be created after the error happens, as in it creates it after loading the device, when mdadm is loaded.

Somehow it looks like it can't/doesn't load the raid array before it needs to mount it, and I don't know how I can solve that.

My config files (taken from the system once it boots with sda3 as root device):

$ cat /etc/mdadm.conf
ARRAY /dev/md/md0-r5 metadata=0.90 UUID=1a118934:c831bdb3:64188b84:66721085
ARRAY /dev/md125 metadata=0.90 UUID=48ec4190:a80d4dde:64188b84:66721085

$ cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4] [raid0] [raid10]
md125 : active raid1 sdc3[1]
      477853312 blocks [2/1] [_U]

md127 : active raid5 sdd[0] sdf[3] sdb[2] sde[1]
      4395415488 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]

unused devices: <none>

$ cat /boot/grub/menu.lst
default 0
timeout 8
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo Linux 2.6.31-r10
root (hd0,0)
#kernel /boot/kernel-genkernel-x86_64-2.6.31-gentoo-r10 root=/dev/ram0 real_root=/dev/sda3
kernel /boot/kernel-genkernel-x86_64-2.6.31-gentoo-r10 root=/dev/md125 md=125,/dev/sdc3,/dev/sda3
initrd /boot/initramfs-genkernel-x86_64-2.6.31-gentoo-r10

# blkid
/dev/sda1: UUID="89fee223-b845-4e0a-8a0b-e6cf695d5bcf" TYPE="ext2"
/dev/sda2: UUID="a72296a8-d7d4-447f-a34b-ee920fd1a767" TYPE="swap"
/dev/sda3: UUID="97eb0a6a-c385-4a9d-bf74-c0bab1fa4dc1" TYPE="ext3"
/dev/sdb: UUID="1a118934-c831-bdb3-6418-8b8466721085" TYPE="linux_raid_member"
/dev/sdc1: UUID="d36537fd-19a0-b8a3-6418-8b8466721085" TYPE="linux_raid_member"
/dev/sdd: UUID="1a118934-c831-bdb3-6418-8b8466721085" TYPE="linux_raid_member"
/dev/sde: UUID="1a118934-c831-bdb3-6418-8b8466721085" TYPE="linux_raid_member"
/dev/md127: UUID="13a41589-4cf1-4c04-91ca-37484182c783" TYPE="ext4"
/dev/sdf: UUID="1a118934-c831-bdb3-6418-8b8466721085" TYPE="linux_raid_member"
/dev/sdc2: UUID="a1916397-1b48-45d7-9f98-73aa521e882f" TYPE="swap"
/dev/sdc3: UUID="48ec4190-a80d-4dde-6418-8b8466721085" TYPE="linux_raid_member"
/dev/md125: UUID="c947ed64-1d4d-4d1d-b4d2-24669fff916e" SEC_TYPE="ext2" TYPE="ext3"

# mdadm -E
mdadm: No devices to examine

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe975e9fc

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           5       40131   83  Linux
/dev/sda2               6        1311    10490445   82  Linux swap / Solaris
/dev/sda3            1312       60801   477853425   83  Linux

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe975e9fc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1           5       40131   83  Linux
/dev/sdc2               6        1311    10490445   82  Linux swap / Solaris
/dev/sdc3            1312       60801   477853425   83  Linux

Disk /dev/md125: 489.3 GB, 489321791488 bytes
2 heads, 4 sectors/track, 119463328 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

Disk /dev/md125 doesn't contain a valid partition table

2 Answers2

6

When Linux boots up, it first boots a minimal Linux distribution from inside the initramfs. This is just a ram disk with a simple root file system. The initramfs does some initialization, loads all the necessary block device and filesystem drivers, and then mounts the real root file system, pivots into it, and boots from it. It looks like you have your raid device configured properly under the main Linux file system, but not inside the initramfs filesystem.

Its possible to crack open your initramfs (its just a gzip'd cpio archive, make modifications to it and re-archive it. I've often troubleshooted problems like this by changing the initramfs init scripts to just drop to a shell and figure out whats not working. You're initramfs should have been created at the same time as the kernel was built, and usually contains everything needed to bootstrap the system. But especially if the sw raid was added after the system was already running, the build may not have added it properly. Check out the sw raid info in this document:

http://en.gentoo-wiki.com/wiki/Initramfs

bk.
  • 768
  • 1
  • 4
  • 13
  • Thanks, solved my issue. For others: add static mdadm and mdadm.conf in your initramfs, run "MAKEDEV generic" in your raid1 /dev and it should work. –  Mar 12 '10 at 16:22
0

One thing that you need to bear in mind is that Grub doesn't recognise RAID arrays, so you must install grub onto both drives. When Grub starts, it usually boots off the first one, but if something changes to the array, it will try to boot off the second HDD that you won't have grub installed onto.

gbjbaanb
  • 3,852
  • 1
  • 22
  • 27