LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-05-2006, 12:20 PM   #1
stevielawson
Member
 
Registered: Sep 2004
Location: Scotland
Posts: 41

Rep: Reputation: 15
weird problem with mount/cdrom/symlink


I've two drives in my machine, a cdrom (hdc) and a dvd (hdd) which weren't properly detected at installation, so I created the relevant mount points (mount/cdrom, mount/dvd), created the sym-links with 'ln -s /dev/hdc /dev/cdrom' and 'ln -s /dev/hdd /dev/dvd', then edited the fstab so it looks as follows:

Quote:
/dev/hda2 swap swap defaults 0 0
/dev/hda1 / reiserfs defaults,noatime 1 1
/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0
/dev/dvd /mnt/dvd auto noauto,user,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,user 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
/dev/tmpfs /dev/shm tmpfs size=10%,mode=0777 0 0
/dev/usbstore /mnt/usb auto noauto,user,rw,exec 0 0
/dev/usbstore1 /mnt/usb1 auto noauto,user,rw,exec 0 0
But here's the weird thing... my dvd will play both dvds and audio cds fine, but my cdrom won't - I use Audacious to play cds which returns an error message about there being no cd in the drive.
So, I went looking for a possible explanation and found that, in /dev, the link to the cdrom (which should be hdc) is actually to hdd - the dvdrom.
So, I deleted the existing link to hdc and created a new one, all as root. That did the trick - until I rebooted today and found that the same link to hdc I had created yesterday now links to hdd!
Can anyone explain where I'm going wrong, as this has me a bit baffled.
Thanks.
 
Old 03-05-2006, 12:45 PM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
I'd suspect udev to create those links. Do you use udev?
 
Old 03-05-2006, 12:54 PM   #3
stevielawson
Member
 
Registered: Sep 2004
Location: Scotland
Posts: 41

Original Poster
Rep: Reputation: 15
Yes, I think so - how can I check for sure?
I'm actually running Zenwalk 2.2 at the moment which is based on Slackware (I've posted here rather than the Zenwalk site because a) their server is down and b) I've always found the people on this forum to be very helpful).
I had a look at the udev website and, to my amusement, it says:

Quote:
udev allows Linux users to have a dynamic /dev directory and it provides the ability to have persistent device names.
There's nothing very persistent about my device names!
Do you have any suggestions as to how I can stop this happening? I'm assuming I need to somehow make udev accept a fixed symlink to hdc, but how do I achieve that?
Thanks
 
Old 03-05-2006, 01:09 PM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
To check if you use udev, on Slackware you'd check if /etc/rc.d/rc.udev is executable:
Code:
pu@slackw:/$ v /etc/rc.d/rc.udev
-rwxr-x---  1 root root 1396 2004-06-14 08:59 /etc/rc.d/rc.udev*
or check if udevd is running
Code:
pu@slackw:/$ ps -ef | grep udev
root       847     1  0 17:35 ?        00:00:00 udevd
 
Old 03-05-2006, 01:33 PM   #5
stevielawson
Member
 
Registered: Sep 2004
Location: Scotland
Posts: 41

Original Poster
Rep: Reputation: 15
And this is what I get:

Quote:
steve[~]$ ps -ef | grep udev
root 843 1 0 13:36 ? 00:00:00 /sbin/udevd --daemon
steve 2756 2754 0 18:34 pts/0 00:00:00 grep udev
Frankly, I've no idea what most of that means but I guess it means I've got udev running... now all I need to know is how to stop it changing the link to my cdrom.
 
Old 03-05-2006, 01:48 PM   #6
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
The script that controls these symlinks in udev can be found at /etc/udev/scripts/make_extra_nodes.sh

I had a similar problem, in that I have two DVD drives, one DVD and one DVDRW which are located at /dev/hda and /dev/hdb, respectively. On boot up (because of the way the script works) it links /dev/cdrom and /dev/dvd to /dev/hdb, rendering hda pretty useless. I haxx0red the script a little to make links like /dev/cdrom0 and /dev/cdrom1 and then removed the section where it links to /dev/dvd, for clarity.

My version reads (trimmed for readability):

Code:
# If we can, add a default /dev/cdrom and /dev/dvd link:
cdCount=0
if /bin/ls -l /dev | grep -w cdrom 1> /dev/null 2> /dev/null ; then
  ( cd $udev_root
    /bin/ls -l * | grep -w cdrom | cut -f 2 -d : | cut -f 2 -d ' ' | while read optical_device ; do
      # It has to be a cdrom.  Last one wins.
      ln -sf $optical_device cdrom"$cdCount"
          let "cdCount += 1"
      # If it's a DVD, set that link as well:
      #if grep -i dvd /proc/ide/$optical_device/model 1> /dev/null 2> /dev/null ; then
      #  echo ln -sf $optical_device dvd
      #fi
    done
    unset optical_device
    unset cdCount
  )
fi
It's a bit of a hack, but does provide you with sensible-ish /dev/ symlinks. The only real reason for doing this and not using /dev/hdX directly, afaik, is if you tend to move your optical drives around and have them linked in more than just fstab. If you don't intend to move your drives around, I would leave the script as it is and just use /dev/hdc and /dev/hdd.

Hope that helps,
- Piete.
 
Old 03-05-2006, 02:47 PM   #7
stevielawson
Member
 
Registered: Sep 2004
Location: Scotland
Posts: 41

Original Poster
Rep: Reputation: 15
Whoa! Not sure I understood much of that!
I had a look in /etc/udev for the script you mentioned but there's no sign of it. What I did find was a file called 'udev.rules', which contained the following:

Quote:
# /etc/udev/udev.rules: device naming rules for udev
#
# There are a number of modifiers that are allowed to be used in some of the
# fields. See the udev man page for a full description of them.

# wait for sysfs
ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus"

# all block devices
SUBSYSTEM=="block", GROUP="disk"

# permissions for IDE CD devices
BUS=="ide", KERNEL=="*[!0-9]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom*", NAME="%k", GROUP="cdrom", MODE="0660", RUN+="/lib/udev/cdrom-symlinks.sh %k"
...and a whole bunch more stuff, I just thought this bit with the reference to cdrom might be helpful to someone like yourself who knows what it's all about.
I'm not averse to having a go at hacking a script - but I've never really done much of this stuff so I'm anxious to get things absolutely clear before I dive in.
I'm guessing here - but that bit at the end about '/lib/udev/cdrom-symlinks.sh' looks like it might be involved somehow?
That script looks like this:
Quote:
#!/bin/sh
if [ -z $udev_root ]; then
. /etc/udev/udev.conf
fi

cd_num=0
dvd_num=0
optical_device=$1
if ! ls -l $udev_root | grep -q ^l.*$optical_device ; then
cd $udev_root
for i in `/bin/ls cdrom? 2>/dev/null`; do
cd_num=$(($cd_num + 1))
done
for i in `/bin/ls dvd? 2>/dev/null`; do
dvd_num=$(($dvd_num + 1))
done
if [ "$cd_num" = "0" ]; then
ln -sf $optical_device cdrom
ln -sf $optical_device cdrom0
else
ln -sf $optical_device cdrom${cd_num}
fi
if grep -iq dvd /proc/ide/$optical_device/model ; then
if [ "$dvd_num" = "0" ]; then
ln -sf $optical_device dvd
ln -sf $optical_device dvd0
else
ln -sf $optical_device dvd${dvd_num}
fi
fi
fi
Thanks for the help Piete.

Last edited by stevielawson; 03-05-2006 at 02:50 PM.
 
Old 03-05-2006, 04:27 PM   #8
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
I would've come the same conclusion. Basically that udev rule says: "if you find some optical devices, run the script". My udev-rule-knowledge is, frankly, pants, so you'd be best checking some of the awesome tutorials on that if you wanna be certain.

The script says (if I read this right), find out how many devices exist, and symlink each optical device to /dev/cdromX where X is some value that it counts up.

So, in theory, you should already have individual links in /dev/ like, /dev/cdrom, /dev/cdrom0, /dev/cdrom1, /dev/dvd, /dev/dvd0, /dev/dvd1 .. if I read the script correctly, you should have *all* of those links ... if you don't, then you need to start asking if that script is running.

It's just a bash script, so, it's easy to hack. Use # at the start of a line to comment out that line, and use things like: echo "We made it here!"

That'll print out to the terminal to show you what's running where ... so, whack some echos in the script and, as root, run: /etc/rc.d/rc.udev restart

If that doesn't work you'll have to kill udev and start it up again from /etc/rc.d/rc.udev .

Let us know how it goes and what you discover! I'm sorry I'm not running the same version of Slack as you to be able to help more!

- Piete.
 
  


Reply


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
Weird VFAT mount problem drj000 Linux - Hardware 10 10-28-2005 04:06 PM
Symlink or Mount or Another Technique? jalperin Linux - Newbie 1 08-26-2004 07:43 PM
/dev/cdrom symlink GETS DELETED on reboot eyeoft Linux - General 2 06-08-2004 12:59 PM
weird mount problem scarr3d Debian 3 11-09-2003 08:13 AM
mount not writing to /etc/mtab if is symlink? sannik Linux - General 1 07-27-2003 01:18 AM


All times are GMT -5. The time now is 02:53 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