LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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-08-2010, 10:06 PM   #1
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 801

Rep: Reputation: 247Reputation: 247Reputation: 247
How can I disable or configure udev for initrd?


I've recently updated my Slackware 13.1 system to the Slackware current. Although I have created my "initrd" image without specifying the "-u" option to "mkinitrd" it still starts up "udev".

That is causing me some difficulty because I am using "dmraid" to detect my RAID arrays. I had created my own device names such as "/dev/sdr2" for my root partition. With 13.1 I had no problem, since "udev" was not started by the "initrd" unless the "-u" option was provided. The current version seems to start up "udev" even without that option.

Is there a way to disable "udev" in the "initrd", or is there a way to specify custom "udev" rules for an "initrd"? I tried placing a "10-local.rules" file in the "etc/udev/rules.d" directory of the "initrd-tree" but that file had no effect on the device names generated by "udev" during the "initrd".

Here is my script that creates the "initrd".

Code:
ROOTDEVNAME="/dev/sdr2"	# Name of root device
LINUXVER="2.6.35.7-smp"		# Linux modules version
CLIBVER="2.12.1"		# C library version
ROOTDIR="/boot/initrd-tree"	# Location of root filesystm
# Get most of the needed programs from the normal mkinitrd
mkinitrd -k $LINUXVER -c -r "$ROOTDEVNAME" -f ext3
# Create root device
cp -a "$ROOTDEVNAME" "$ROOTDIR/dev"
# Copy scripts and programs
cp -p init "$ROOTDIR"
cp -p /etc/udev/rules.d/10-local.rules "$ROOTDIR/etc/udev/rules.d"
chmod u=rwx,g=rx,o=rx "$ROOTDIR/init"
cp -p /sbin/dmraid "$ROOTDIR/sbin"
for lib in \
   "libdevmapper.so.1.02" \
   "libc.so.6" "ld-linux.so.2" \
   "ld-$CLIBVER.so" "libc-$CLIBVER.so" \
   "libudev.so.0" "libudev.so.0.7.0"
   do
   if [ -e "/lib/$lib" ] ; then
      cp -Pp "/lib/$lib" "$ROOTDIR/lib/$lib"
   else
      echo "Library file not found \"/lib/$lib\""
      exit 1
   fi
done
# Make the compressed image file
mkinitrd
The bold line above is one that I added in an attempt to provide rules to "udev" for the "initrd". It had no apparent effect (see rules file below).

In Slackware 13.1 and previous versions, the "/dev/sdr2" device was found in the "dev" directory of the "initrd" image because my script creates it. The current version runs "udev" and does not see the actual "dev" directory. I have been able to get the system to boot by substituting the name "/dev/dm-2" instead of "/dev/sdr2" but I would like to use the same name that I use for the other partitions "/dev/sdrN" (N=1 to 7).

The "init" script is slightly modified to include one extra statement. Here is an excerpt of the modified section.

Code:
# Sometimes the devices need extra time to be available.
# A root filesystem on USB is a good example of that.
sleep $WAIT

# Find any dmraid detectable partitions
dmraid -ay

# If udevd is available, use it to generate block devices
# else use mdev to read sysfs and generate the needed devices 
if [ -x /sbin/udevd -a -x /sbin/udevadm ]; then
  /sbin/udevd --daemon
  /sbin/udevadm control --property=STARTUP=1
  /sbin/udevadm trigger --subsystem-match=block --action=add
  /sbin/udevadm settle --timeout=10
  /sbin/udevadm control --property=STARTUP=
else
  [ "$DEVTMPFS" != "1" ] && mdev -s
fi
The added lines are in bold and run "dmraid". I verified that I have the current "init" script with only the addition of "dmraid" being different.

Here is my normal "udev" rules file, named "10-local.rules" that works after Linux is booted.

Code:
# /etc/udev/rules.d/10-local.rules:  local device naming rules for udev

KERNEL=="dm-0", NAME="sdr", OPTIONS+="last_rule"
KERNEL=="dm-1", NAME="sdr1", OPTIONS+="last_rule"
KERNEL=="dm-2", NAME="sdr2", OPTIONS+="last_rule"
KERNEL=="dm-3", NAME="sdr4", OPTIONS+="last_rule"
KERNEL=="dm-4", NAME="sdr5", OPTIONS+="last_rule"
KERNEL=="dm-5", NAME="sdr6", OPTIONS+="last_rule"
KERNEL=="dm-6", NAME="sdr7", OPTIONS+="last_rule"
KERNEL=="dm-7", NAME="sdr8", OPTIONS+="last_rule"
It does not have any effect when I put it in the "rules.d" directory for the "initrd-tree". It does work after Linux boots, but by then the root device has been named "/dev/dm-2" and continues to appear that way.

At the time the "initrd" tries to mount the root device the "/dev/sdr2" device has not yet been created by the normal "udev" rules. In the past I had solved that problem by creating "/dev/sdr2" in the "dev" directory of the "initrd" and the "/dev" directory of the root file-system. In previous versions of Slackware, the device "/dev/dm-2" did not exist until after the "initrd" and normal "init" script had finished.

The "menu.lst" file for "grub" has this entry to boot Linux.

Code:
title Linux
root (hd0,1)
kernel /boot/vmlinuz vga=791 root=/dev/sdr2 ro vt.default_utf8=0 load_ramdisk=1 ramdisk_size=4096
initrd /boot/initrd.gz
When I specify "root=/dev/dm-2" the system will boot, but "root=/dev/sdr2" no longer works after upgrading to current.

It will be helpful for me to understand "udev" issues related to an "initrd" because I will eventually try to use "mdadm" instead of "dmraid". So far I have only been able to get my system to boot from the RAID array using "dmraid" and I often run into new problems when I update Linux. Still, Slackware has proven to have the best support for booting from my RAID array because of the user community, documentation and flexibility.

Last edited by Erik_FL; 11-08-2010 at 10:08 PM.
 
Old 11-08-2010, 10:29 PM   #2
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 801

Original Poster
Rep: Reputation: 247Reputation: 247Reputation: 247
Partly solved - can configure udev rules for initrd

It occurred to me that perhaps even though "udev" was starting, it was not being completely included in the "initrd" because of the omission of the "-u" option to "mkinitrd". I added "-u" and now the "initrd" does pay attention to the rules in its "etc/udev/rules.d" directory. Those "initrd" rules apparently stay in effect until the normal "udev"
rules are invoked. I am able to boot using the "/dev/sdr2" name again.

Changes in bold below.

Code:
ROOTDEVNAME="/dev/sdr2"	# Name of root device
LINUXVER="2.6.35.7-smp"		# Linux modules version
CLIBVER="2.12.1"		# C library version
ROOTDIR="/boot/initrd-tree"	# Location of root filesystm
# Get most of the needed programs from the normal mkinitrd
mkinitrd -k $LINUXVER -c -r "$ROOTDEVNAME" -f ext3 -u
# Create root device
cp -a "$ROOTDEVNAME" "$ROOTDIR/dev"
# Copy scripts and programs
cp -p init "$ROOTDIR"
cp -p /etc/udev/rules.d/10-local.rules "$ROOTDIR/etc/udev/rules.d"
chmod u=rwx,g=rx,o=rx "$ROOTDIR/init"
cp -p /sbin/dmraid "$ROOTDIR/sbin"
for lib in \
   "libdevmapper.so.1.02" \
   "libc.so.6" "ld-linux.so.2" \
   "ld-$CLIBVER.so" "libc-$CLIBVER.so" \
   "libudev.so.0" "libudev.so.0.7.0"
   do
   if [ -e "/lib/$lib" ] ; then
      cp -Pp "/lib/$lib" "$ROOTDIR/lib/$lib"
   else
      echo "Library file not found \"/lib/$lib\""
      exit 1
   fi
done
# Make the compressed image file
mkinitrd
Although I don't really care about disabling "udev" in the "initrd" I am wondering why the pseudo-file-system is created when "-u" is not specified to "mkinitrd". Perhaps "dmraid" is now somehow triggering the creation of the pseudo-file-system for "dev" even though the other "udev" files are not present. In the past the "-u" option would never work with "dmraid" and now apparently it must always be used. The interesting thing is that I haven't changed the version or binary for "dmraid". I guess this could be a kernel change or bug fix.

Hopefully I will not have too many issues with "mdadm" and I can move to 64-bit Slackware in the near future.
 
  


Reply

Tags
dmraid, initrd, udev


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to disable udev for a faster boot? whitehead1415 Linux - Hardware 4 01-09-2010 06:31 AM
disable initrd on debian sharK9R Linux - Newbie 4 06-04-2009 10:15 AM
how can I add udev into initrd? randomsel Slackware 1 06-29-2008 09:27 PM
How do I disable a device that was enabled in udev? Woodsman Slackware 5 03-29-2008 09:03 PM
Can I disable rc.udev with 2.4 kernel shepper Slackware 2 09-18-2005 09:45 PM


All times are GMT -5. The time now is 05:26 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration