LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 03-16-2007, 04:51 PM   #1
synx
LQ Newbie
 
Registered: Mar 2007
Location: limbo
Distribution: Debian unstable
Posts: 3

Rep: Reputation: 0
Detecting the CD drive (or other hardware) without udev?


I'm learning how to make an initrd for a liveCD, and I'm running into a bootstrapping problem. udev is darned hard to set up, with many dependancies, and I'd like to do that later in the boot process after I've mounted the liveCD. But in order to access the liveCD in the first place, I need to detect which hardware is the CD drive, and which device is associated with it. In addition I need to know what drivers the computer may need to access this CD drive (i.e. if it's a SCSI drive on a strange host bus).

My plan is (was) to collect all the possible drivers I might need, then insmod them one by one, then rmmod the ones that failed. Once I insmod the right module, the kernel will report it has detected new CD hardware, and I can break out of the CD detection loop, and continue to prepare my root file system. I looked at Morphix's initrd, and briefly at the debian-installer's "detect-cd" script, and though it seemed like they were doing something like that, one thing kept eluding me.

How does the kernel report when it has detected new hardware, and that the hardware is a CD drive?

I'm pretty sure it has something to do with creating a /sbin/hotplug program, and once I insmod the right driver, the kernel will ...exec /sbin/hotplug? With informative device info in... environment variables? I can't find any documentation about hotplug though, except that it's important for enabling udev. I don't want to do udev though because at this stage I'm only in a temporary root, and I'll have the real root setup later, which udev can populate. One concern I have though is the possible race condition: if I insmod a module, how long do I pause the script before checking if a /dev/cdrom symlink has appeared? There seem to be programs for that waiting period related to udev, such as udevsettle. Is there any way I could make a temporary stripped down udev setup perhaps, just for detecting the cd drive?

After I've got the CD device, I was going to mount it on /static, and make a tmpfs filesystem on /dynamic, then unionfs both of them together, and use the unionfs as my real root. Then I can pull out udev, and run init, and the whole shebang to get the computer up and running, but before I have the CD device mounted on /static, all I want to do is detect the CD hardware with a minimum of auxiliary kernel modules needed to communicate with it.
 
Old 03-16-2007, 10:31 PM   #2
synx
LQ Newbie
 
Registered: Mar 2007
Location: limbo
Distribution: Debian unstable
Posts: 3

Original Poster
Rep: Reputation: 0
Well, here's what I've got so far. When I run
Code:
$ udevinfo -a -p $(udevinfo -q path -n /dev/hdd)
on my own CD/DVD drive (/dev/hdd), the first entry has no information whatsoever about the fact it's a CD drive. The "parent device" on the other hand, has ATTRS{media} of "cdrom". If I can match by the parent device then I can use that (and udev) to identify the hardware that are CD drives. It'd be nice if I could make them all /dev/cdrom/N : N=0-999 in case of multiple CD drives, then just loop through searching each for the right format and root filesystem. I don't see how to do that though, as udev .rules files don't seem to have any kind of loop or counter support.

Seems like a simplified udev configuration is the best way to do it, even in an initrd. Correct me if I'm wrong of course.
 
  


Reply

Tags
cdrom, detection, hotplug, kernel, livecd, udev



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
"Detecting Hardware for CD-ROM Drive" hangs on alt install for 6.10 burnsah Ubuntu 1 01-11-2007 12:25 PM
Stopping Hardware detection from detecting external hard drive thepasty Linux - Hardware 0 04-30-2004 02:06 PM
Detecting new hardware Xris718 Linux - General 2 01-27-2004 05:41 PM
Detecting new hardware deepesh General 2 06-15-2002 04:20 AM
Detecting new hardware deepesh Linux - Hardware 2 06-15-2002 04:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07: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
Open Source Consulting | Domain Registration