LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-04-2007, 10:35 AM   #1
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Rep: Reputation: 35
Slackware 12, changing to generic kernel on raid1, mkinitrd issue


I'm trying to set up a workstation to have /boot on raid1 (/dev/md1) and / on raid0 (/dev/md0).. to do this I've first installed using the huge.smp kernel, created a raid-viable lilo, rebooted (works fine), then linked System.map, config and vmlinuz in /boot to their generic-smp versions. This won't work for 2 reasons: the root filesystem is reiserfs, and support for that is not compiled into generic-smp. So I need an initrd. That brings me to the second problem: initrd doesn't have raid support built in.

To fix this I mainly followed this article:

http://apropos.wordpress.com/2007/07...-raid-und-lvm/

So what I did was edit /usr/share/mkinitrd/initrd-tree.tar.gz to include /sbin/mdadm and /etc/mdadm.conf (this has the output from mdadm -D --scan appended), and add /sbin/mdadm -A --scan to the included init script, to assemble the raids before mounting the root filesystem.

I created my initrd using mkinitrd -c -k 2.6.21.5-smp -m reiserfs -r /dev/md0 -f reiserfs and checked the resulting /boot/initrd-tree to make sure it contained sbin/mdadm and etc/mdadm.conf and the modified init script.. which it did. I added initrd = /boot/initrd.gz to my lilo config, ran it, and rebooted.

Kernel panic.

It shows it has loaded the reiserfs module, but mdadm has failed to create /dev/md0 and /dev/md1, so mounting the root obviously fails.

I'm stumped, because I've used the exact same procedure on a similar machine and it worked fine.

Can anyone offer any insight as to why it can't assemble the arrays? It has the required program, /sbin/mdadm, and it has the information needed, /etc/mdadm.conf. I've also tried to assemble the arrays explicitly using mdadm -assemble /dev/md0 /dev/sda3 /dev/sdb3 in init, instead of mdadm -A --scan, but I got the same result.
 
Old 11-04-2007, 11:57 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
When you use Software RAID and have RAID built into the kernel, like with the huge(smp) and generic(smp) kernels, and you set your partition types to "fd" (Linux RAID autodetect) then you should have no need for mdadm in the initrd because the kernel will take care of everything.

Eric
 
Old 11-04-2007, 12:22 PM   #3
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by Alien Bob View Post
When you use Software RAID and have RAID built into the kernel, like with the huge(smp) and generic(smp) kernels, and you set your partition types to "fd" (Linux RAID autodetect) then you should have no need for mdadm in the initrd because the kernel will take care of everything.

Eric
Thanks for your reply. If only it were that simple. I double checked in cfdisk at install time to make sure all the partitions were set as FD (they were), and while raid support is built into both flavors of the kernel, simply making an initrd with just reiserfs in it is not enough.

In the meantime, I've also tried with the latest mkinitrd package from -current, both with and without added mdadm, and got the same results. All that changed was that I now get a prompt after it panics, but it doesn't accept input.
 
Old 11-04-2007, 12:48 PM   #4
TransAMrit
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Hi there. I had similar issues with a new Slack 12 box at work recently. My box worked fine with the same type of solution that you had, although my etc/mdadm.conf was more generic:

$ cat etc/mdadm.conf
DEVICE /dev/sd*
ARRAY /dev/md0 super-minor=0
ARRAY /dev/md1 super-minor=1

I then added "/sbin/mdadm --assemble --scan" to the "init" file.

If these changes don't help, the next thing I would suggest is to simply add a "sh" line to "init", so you get a usable shell. Then try using mdadm from there and debug it interactively.
 
Old 11-04-2007, 01:15 PM   #5
Piter PUNK
Slackware Contributor
 
Registered: Aug 2007
Location: Sao Paulo - Brazil
Distribution: Slackware
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by [GOD]Anck View Post
In the meantime, I've also tried with the latest mkinitrd package from -current, both with and without added mdadm, and got the same results. All that changed was that I now get a prompt after it panics, but it doesn't accept input.
Hi,

With the current's initrd you got the "Kernel Panic" and *after* the panic a shell prompt? This is very strange. Can you try:

LILO: your-kernel-image rescue

This will start the initrd with a rescue shell. A better place to debug something, and saw if the /dev/mdX devices are in place, if you can mount it, etc.

Probably, like most of ppl (including me), you don't have a serial or lanconsole enabled. If you can hand copy (or take a good picture -) of the error, i will be happy.

Thanks!

Piter PUNK
 
Old 11-04-2007, 06:25 PM   #6
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
I ran through the whole sequence again just to be sure, and to get the exact error messages. First, I used the original, unmodified mkinitrd package in Slackware 12.0 to create an initrd with reiserfs as follows:

Code:
mkinitrd -c -k 2.6.21.5-smp -m reiserfs -r /dev/md0 -f reiserfs
/lib/modules/2.6.21.5-smp exists, /dev/md0 is my root partition, made up of /dev/sda3 and /dev/sdb3 in a raid0 configuration that I created with mdadm during install.

I symlinked System.map, config and vmlinuz to their respective "generic-smp" versions, edited and updated lilo, then rebooted. This is what I got:

Code:
mount: mounting /dev/md0 on /mnt failed
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
Kernel panic - not syncing. Attempted to kill init!
Unless there is some flaw in my method, this at least proves that it does not in fact work "out of the box", following the README.initrd and using the supplied mkinitrd package.

Then, I put the install disk back in, booted into my system with the hugesmp.s kernel, and upgradepkg'd the mkinitrd package using the latest version in -current, 1.2.0-i486-1. I created a new initrd, updated lilo, rebooted again and got this:

Code:
mount: mounting /dev/md0 on /mnt failed: No such file or directory
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
You can try to fix it. Type 'exit' when things are done.

/bin/sh: can't access tty; job control turned off
/ $
I can't type at this prompt, and I can't ctrl+alt+del or anything, it just hangs here. It does *not* explicitly say "Kernel panic", apologies for misleading you by saying so earlier. Still, the total lack of response makes me suspect something is quietly panicking in the background..

I rebooted once more, using LILO: Linux rescue to get initrd into rescue mode, and I ended up with a similar "you can fix it" type message, the same /bin/sh message and the same unworkable prompt.

I also tried TransAMrit's suggestion; unfortunately it gave me the same result as with my own mdadm.conf.

Thanks for the feedback so far, I'll be more than happy to supply more information / do more testing to help solve this!
 
Old 11-05-2007, 01:57 PM   #7
TransAMrit
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by [GOD]Anck View Post
I also tried TransAMrit's suggestion; unfortunately it gave me the same result as with my own mdadm.conf.
Did you also try the "sh" suggestion? At the same point where you added the call to mdadm in init, add a call to sh, so you can get into a shell and do things like poke around /dev and see if all your nodes exist, run mdadm with various options to try and provoke some useful error message, etc.
 
Old 11-05-2007, 05:31 PM   #8
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by TransAMrit View Post
Did you also try the "sh" suggestion? At the same point where you added the call to mdadm in init, add a call to sh, so you can get into a shell and do things like poke around /dev and see if all your nodes exist, run mdadm with various options to try and provoke some useful error message, etc.
I have, and I got an unusable prompt again.. I am using a USB KVM so just in case, I tried with a keyboard plugged in to the machine directly as well, no luck.
 
Old 11-05-2007, 06:57 PM   #9
XGizzmo
Member
 
Registered: Mar 2007
Distribution: Slackware
Posts: 264

Rep: Reputation: 69
I sent Pat a patch for this very issue but never heard anything back, this works for me but YMMV.

Code:
diff -C 3 -H -b -E -d -I '^#' -r -N -- backups/slackware/slackware-12.0/source/a/mkinitrd/mkinitrd home/gizzmo/Desktop/new.mkinitrd/mkinitrd
*** backups/slackware/slackware-12.0/source/a/mkinitrd/mkinitrd	Fri Jun  8 01:22:58 2007
--- home/gizzmo/Desktop/new.mkinitrd/mkinitrd	Sat Aug 11 01:19:43 2007
***************
*** 52,57 ****
--- 52,58 ----
            where the actual root device name in /etc/fstab is:
              /dev/mapper/cryptroot
    -L      Add support for LVM partitions
+   -M      Add support for md raid	
    -V      Display version number
  
  A simple example:  Build an initrd for a reiserfs root partition:
***************
*** 195,200 ****
--- 196,205 ----
        LVM=1
        shift
        ;;
+     -M)
+       MD=1
+       shift
+       ;;
      *) # unknown, prevent infinite loop
        shift
        ;;
***************
*** 238,243 ****
--- 243,262 ----
    fi
  fi
  
+ # Include md raid support in initrd
+ if [ ! -z "$MD" ]; then
+   if [ -f /sbin/mdadm ]; then
+     mkdir -p $SOURCE_TREE/sbin
+     cp /sbin/mdadm $SOURCE_TREE/sbin/mdadm
+     ( cd $SOURCE_TREE/dev
+       mkdir -p $SOURCE_TREE/etc/mdadm
+       mdadm -E -s >> $SOURCE_TREE/etc/mdadm/mdadm.conf
+    )
+   else
+     echo "mdadm static binary is missing, md raid support isn't installed"
+   fi
+ fi
+ 
  # Include cryptsetup (LUKS) support in initrd
  if [ ! -z "$CRYPT" ]; then
    if [ -e /sbin/cryptsetup.static ]; then
This adds a -M option for mdadm raid support.

I also forgot to tell you to add this to the init script
edit _initrd-tree.tar.gz and add this to the init script and recreate the tarball

Code:
# Initialize md raid:
if [ -x /sbin/mdadm ]; then
  sleep 5
  mdadm --assemble --scan -c /etc/mdadm/mdadm.conf
fi

Last edited by XGizzmo; 11-06-2007 at 03:15 PM.
 
Old 11-06-2007, 06:47 AM   #10
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
Hi, thank you for your reply. I'm at work so I can't try now but I will do so tonight.. reading through your patch it is mostly the same as what I've been doing all along, except for two differences.

First, you put your mdadm.conf in $SOURCE_TREE/etc/mdadm/mdadm.conf where mine was simply in $SOURCE_TREE/etc/mdadm.conf, same as on the live system.. but that shouldn't make much difference; man mdadm tells me it tries both.

A more interesting difference is that you use mdadm -E where I used mdadm -D.. the man page tells me -D gives details of an MD device, and -E looks at the MD superblock on a device.. that doesn't tell me much. I ran both with -s and got identical output. How does -E differ from -D?
 
Old 11-06-2007, 02:01 PM   #11
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
Tried it.. my mileage does vary, it still won't assemble the raid.

However, I managed to get a usable shell for debugging now. I tried mdadm -D -s and it gave me nothing. mdadm -E -s gave me the correct information, which is also in /etc/mdadm.conf.

I then tried mdadm -A -s, didn't work.. "failed to create /dev/md0".

I checked /proc/partitions, it lists my sda/sdb correctly, so then I checked the /dev tree. This is where it becomes interesting. It has nodes for /dev/md0 and /dev/md1 but they are links to /dev/md/0 and /dev/md/1, respectively, and neither of those exists.

I fiddled around with the --auto=[yes,md] options which supposedly create device nodes when needed, but the man page is cryptic at best here and I may well have gotten it wrong.

I don't really know where to go from here, what should I try next?
 
Old 11-06-2007, 03:07 PM   #12
XGizzmo
Member
 
Registered: Mar 2007
Distribution: Slackware
Posts: 264

Rep: Reputation: 69
That is odd that it can read the info from the superblock but cant assemble the raid. Just to make sure you are rerunning lilo after you edit the initrd?

I also forgot to tell you to add this to the init script
edit _initrd-tree.tar.gz and add this to the init script and recreate the tarball
Code:
# Initialize md raid:
if [ -x /sbin/mdadm ]; then
  sleep 5
  mdadm --assemble --scan -c /etc/mdadm/mdadm.conf
fi

Last edited by XGizzmo; 11-06-2007 at 03:15 PM.
 
Old 11-06-2007, 03:36 PM   #13
[GOD]Anck
Member
 
Registered: Dec 2003
Location: The Netherlands
Distribution: Slackware
Posts: 171

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by XGizzmo View Post
That is odd that it can read the info from the superblock but cant assemble the raid. Just to make sure you are rerunning lilo after you edit the initrd?
Yes, I am.

Quote:
Originally Posted by XGizzmo View Post
I also forgot to tell you to add this to the init script
edit _initrd-tree.tar.gz and add this to the init script and recreate the tarball
Code:
# Initialize md raid:
if [ -x /sbin/mdadm ]; then
  sleep 5
  mdadm --assemble --scan -c /etc/mdadm/mdadm.conf
fi
I kinda figured as much and added that in myself. I also added a call to /bin/sh after the call to mdadm, as per TransAMrit's suggestion.. had to get a PS/2 keyboard to be able to use the shell (doh!) but at least I can do some debugging now.. or I could if I knew where to look next.
 
Old 11-14-2007, 01:59 PM   #14
TransAMrit
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Have you had any luck with this issue? Or are you still stuck?
 
Old 02-14-2008, 07:22 PM   #15
gtoso
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
Cool

Quote:
Originally Posted by XGizzmo View Post
I sent Pat a patch for this very issue but never heard anything back, this works for me but YMMV.
Hi, I have seen this forum only now :-(
Somebody knows why this patch isn't merged in official Slack?

Today I had the same problem,
understood that kernel raid autodetect don't run if there is an initrd...
and finally, after several test, I wrote a patch very similar to your one,
the only differences:

generate mdadm.conf at boot time;
fixed a cp (if run mkinitrd without options it copied missed devices in dev/dev);
copy symlinks AND relative devices, so I have /dev/md1 and /dev/md/1:
mdadm automatically create only /dev/mdx,
but my root is autodetected as /dev/md/1 (from mount)
and so I don't need to use -r

My patch:

Code:
--- mkinitrd.orig       2007-11-30 00:41:13.000000000 +0100
+++ mkinitrd    2008-02-14 22:19:56.000000000 +0100
@@ -52,6 +52,7 @@
           where the actual root device name in /etc/fstab is:
             /dev/mapper/cryptroot
   -L      Add support for LVM partitions
+  -R      Add support for RAID partitions
   -V      Display version number
 
 A simple example:  Build an initrd for a reiserfs root partition:
@@ -84,6 +85,9 @@
   for device in $SLOPPY_DEV_LIST ; do
     if [ ! -r $SOURCE_TREE/dev/$device -a -b /dev/$device ]; then
       cp -a --parents /dev/$device $SOURCE_TREE
+      if [ -h /dev/$device ]; then
+        cp -a --parents $(readlink -e /dev/$device) $SOURCE_TREE
+      fi
     fi
   done
   # Make sure a kernel module directory exists:
@@ -101,7 +105,10 @@
   SLOPPY_DEV_LIST=$(cat /proc/partitions)
   for device in $SLOPPY_DEV_LIST ; do
     if [ ! -r $SOURCE_TREE/dev/$device -a -b /dev/$device ]; then
-      cp -a --parents /dev/$device $SOURCE_TREE/dev
+      cp -a --parents /dev/$device $SOURCE_TREE
+      if [ -h /dev/$device ]; then
+        cp -a --parents $(readlink -e /dev/$device) $SOURCE_TREE
+      fi
     fi
   done
   # Wrap the initrd as an initramfs image and move it into place:
@@ -195,6 +202,10 @@
       LVM=1
       shift
       ;;
+    -R)
+      RAID=1
+      shift
+      ;;
     *) # unknown, prevent infinite loop
       shift
       ;;
@@ -238,6 +249,16 @@
   fi
 fi
 
+# Include RAID support in initrd
+if [ ! -z "$RAID" ]; then
+  if [ -f /sbin/mdadm ]; then
+    mkdir -p $SOURCE_TREE/sbin
+    cp /sbin/mdadm $SOURCE_TREE/sbin/mdadm
+  else
+    echo "mdadm binary is missing, RAID support isn't installed"
+  fi
+fi
+
 # Include cryptsetup (LUKS) support in initrd
 if [ ! -z "$CRYPT" ]; then
   if [ -e /sbin/cryptsetup.static ]; then
Code:
--- initrd-tree.orig/init       2007-06-08 07:10:55.000000000 +0200
+++ initrd-tree/init    2008-02-14 18:34:03.000000000 +0100
@@ -77,6 +77,12 @@
   fi
 fi
 
+# Initialize RAID:
+if [ -x /sbin/mdadm ]; then
+  /sbin/mdadm -E -s >/etc/mdadm.conf
+  /sbin/mdadm -A -s
+fi
+
 # Initialize LVM:
 if [ -x /sbin/vgscan ]; then
   /sbin/vgscan --mknodes --ignorelockingfailure

Last edited by gtoso; 02-15-2008 at 08:24 AM. Reason: My English is not so good :-(
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with mkinitrd dwhitney67 Linux - Kernel 2 08-02-2007 05:50 PM
Cannot boot a software raid array with 'generic' kernel (Slackware 12) dieymir Slackware 2 07-11-2007 09:26 PM
SVM RAID1 issue on Solris 10 UltraSoul Solaris / OpenSolaris 2 07-04-2007 08:38 AM
Slackware 10.2 + Kernel (generic) 2.6.13 + Tv LG LTT-200 Capture Card Problems SoulSlave Slackware 10 11-27-2005 03:17 PM
mkinitrd doesnt exist in slackware? Newbie kernel compile question! nmoog Slackware 3 01-08-2004 06:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration