LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2008, 10:57 PM   #1
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Issue ejecting CD-R used to boot Linux


I have a customized Linux distro that I am able to boot from CD-R, where using start-up scripts I am able to run udev to discover and setup my device nodes, and then install a CLFS distro onto the HDD. Everything goes well except when I am "done".

I am unable to successfully eject the CD-R. When I attempt to do so (using the 'eject' command), the CD-ROM tray opens up and then immediately shuts close again, never giving me a chance to physically remove the CD-R.

The interesting part is that once this happens, I still have a command prompt and a shell running, however I cannot run any system commands. It is as if the CD-R is no longer mounted, which probably is the case.

Anyhow, what can I do to get the CD-ROM tray to remain open so that I can have an opportunity to remove the media?

Btw, my CD-ROM device is /dev/hdb and /dev/cdrom has been setup properly using udev and related rules. So everything is good with respect to that.

Last edited by dwhitney67; 01-21-2008 at 11:31 PM.
 
Old 01-22-2008, 06:39 AM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
eject is supposed to unmount but run..... man eject....... you may notice -v switch

[gordy@gs ~]$ eject -v cdrom
eject: device name is `cdrom'
eject: expanded name is `/dev/cdrom'
eject: `/dev/cdrom' is a link to `/dev/hda'
eject: `/dev/hda' is mounted at `/media/cdrom'
eject: unmounting device `/dev/hda' from `/media/cdrom'
eject: `/dev/hda' is a multipartition device
eject: trying to eject `/dev/hda' using CD-ROM eject command
eject: CD-ROM eject command succeeded


2) in fstab....change to users,blah blah 0 0 in lieu of user (root) using root powers and see if that makes a difference.
 
Old 01-23-2008, 08:15 AM   #3
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
aus9 -

I found an error in one of my scripts, corrected it, and now I cannot get the CD-tray to open at all.

Using your advice, I ran the eject command with the "-v" option. Here is the output I received:

Code:
/usr/bin/eject: device name is '/dev/cdrom'
/usr/bin/eject: expanded name is '/dev/cdrom'
/usr/bin/eject: '/dev/cdrom' is a link to '/dev/hdb'
/usr/bin/eject: '/dev/hdb' is not mounted
/usr/bin/eject: '/dev/hdb' is not a mount point
/usr/bin/eject: '/dev/hdb' is a multipartition device
/usr/bin/eject: trying to eject '/dev/hdb' using CD-ROM eject command
/usr/bin/eject: CD-ROM eject command failed
/usr/bin/eject: trying to eject '/dev/hdb' using SCSI commands
/usr/bin/eject: SCSI eject succeeded
Don't let that last line fool you. As I stated earlier, the CD-tray did not eject!

Any ideas as to where else I can focus on to resolve this issue?

P.S. The CD-ROM drive is a Plextor PX-230A IDE/ATAPI unit.

Last edited by dwhitney67; 01-23-2008 at 08:29 AM.
 
Old 01-23-2008, 09:04 PM   #4
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
do you mind posting the script that you fixed please, in case others can suggest an alternative in your intentions...

2) post all lines of cd/dvd removeable media in your /etc/fstab

and are you using HAL daemon to automount or udev or manual commands.

3) leaping ahead...its messy but without fixing your script...delete your fsab lines...change hal rules not automount and use manual commands then a manual umount should work.

I use users...not user in fstab to allow normal user to mount/umount cds
 
Old 01-23-2008, 09:50 PM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
To fulfill your request, I've provided the information below. Please remember that I am booting from a CD, and then attempting to eject such CD when I am done.

For /boot/grub/menu.lst:
Code:
...
title install
root (cd)
kernel /boot/vmlinuz-2.6.17.13 quiet root=/dev/hdb init=/to_install/do_install_wrapper.sh
...
For /etc/fstab:
Code:
# Used only when booting from CD-ROM
#
# file system   mount-point     type            options         dump    fsck
#                                                                       order
proc            /proc           proc            defaults        0       0
sysfs           /sys            sysfs           defaults        0       0

/dev/hdb        /cdrom          iso9660         ro,noauto       0       0
/dev/hdb        /mnt/cdrom      iso9660         ro,noauto       0       0
For /to_install/do_install_wrapper.sh:
Code:
#!/bin/sh

#
# File:  do_install_wrapper.sh
#

# Import common functions
. /to_install/do_common.sh

# enable udev (device discoverer)
KickoffUdev

# run the script that will launch the setup user-interface
/to_install/do_install_or_update.sh

# allow writes to the HDD to be flushed
sync
sync
sync

# sleep for an arbitrary amount of time
sleep 3

echo "************************************************************************"
echo "************************************************************************"
echo "****"
echo "****  Please reboot the system after you have removed the CDROM."
echo "****"
echo "************************************************************************"
echo "************************************************************************"

# eject the CD-R from the drive
eject /dev/cdrom

# don't let the script exit; this will mask the "kernel panic" that would
# otherwise ensue.
while true
do
        sleep 60;
done
For /to_install/do_install_or_update.sh (with non-relevant stuff snipped out):
Code:
#!/bin/sh

#
# File:  do_install_or_update.sh
#

# Import common functions
. /to_install/do_common.sh

# setup /tmp and /var/log as ramdisks
mke2fs /dev/ram0 >/dev/null 2>/dev/null
mke2fs /dev/ram1 >/dev/null 2>/dev/null

mount /dev/ram0 /tmp     >/dev/null 2>/dev/null
mount /dev/ram1 /var/log >/dev/null 2>/dev/null
...
export LD_LIBRARY_PATH=/usr/X11R6/lib:/usr/lib:/usr/local/qt/lib
export PATH=/usr/X11R6/bin:$PATH

# Determine the video chip-set used on the system.  VIDEO is returned.
DetermineVideoType

/usr/X11R6/bin/xinit /bin/UpdateUI $CDVERSION $PARAM -- /usr/X11R6/bin/X -config /etc/X11/$VIDEO/xorg.conf 2>/dev/null
For /to_install/do_common.sh:
Code:
#!/bin/sh

# File:  do_common.sh
#
# Purpose:  Defines common function(s) uses by the "do" scripts
#


PATH=$PATH:/usr/X11R6/bin


# Function: KickoffUdev()
#
# Runs the udev daemon to setup the device nodes appropriate for the
# hardware in the system.
#
KickoffUdev()
{
  echo "Mounting kernel-based file systems..."
  mount -n /proc
  mount -n /sys

  echo "Starting udevd..."
  mount -n -t tmpfs -o mode=0755 udev /dev
  cp -a /lib/udev/devices/* /dev
  chmod 1777 /dev/shm
  echo "" > /sys/kernel/uevent_helper
  udevd --daemon

  echo "Performing Coldplugging..."
  mkdir -p /dev/.udev/queue
  udevtrigger
  udevsettle
}


# Function:  DetermineVideoType()
#
# Determines the video chip-set used on the running system, and
# returns the type in a variable called VIDEO.  Possible return
# values for VIDEO are: ati, chips, intel, or vesa.
#
DetermineVideoType()
{
  VIDEO=vesa

  if [ `scanpci | grep "ATI" -c` -eq 1 ]
  then
        VIDEO=ati

  elif [ `scanpci | grep "Chips and Technologies" -c` -eq 1 ]
  then
        VIDEO=chips

  elif [ `scanpci | grep "82852/855GM" -c` -eq 3 ]
  then
        VIDEO=intel
  fi
}
The final part of the do_install_or_update.sh script launches X11 and a Qt GUI that prompts the operator whether to install the OS and proprietary applications to the HDD, or to update, etc. The final option available is to "Cancel".

When I select "Cancel", the GUI app terminates, followed by X11, and then control is returned to do_install_wrapper.sh. I see the "Please reboot the system..." banner but the CD-R is never ejected.

My system does not use HAL, thus there is no automounter.
 
Old 01-23-2008, 10:15 PM   #6
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,336

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
I think that your problem may be that you have /dev/hdb listed twice in /etc/fstab. Try removing the first of the two lines (/cdrom), reboot, and see what happens.

--------------------------
Steve Stites
 
Old 01-23-2008, 10:36 PM   #7
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
I agree but is this script on a re-mastered cdr or on the hard drive...your first post, I thought the cdr was used to install an os onto the hd....now I am not so sure.

btw, that looks like an oldish kernel...I assume http://trac.cross-lfs.org/ allows you to update to a new kernel if you wanted to?

you are more advanced than me...I have never used LFS.
 
Old 01-24-2008, 10:49 AM   #8
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by jailbait View Post
I think that your problem may be that you have /dev/hdb listed twice in /etc/fstab. Try removing the first of the two lines (/cdrom), reboot, and see what happens.

--------------------------
Steve Stites
I did this, and then repeated again with by removing the second entry as well, and still no joy.

Two more CD-R disks, err coasters, created! Yay!
 
Old 01-24-2008, 12:23 PM   #9
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by aus9 View Post
I agree but is this script on a re-mastered cdr or on the hard drive...your first post, I thought the cdr was used to install an os onto the hd....now I am not so sure.

btw, that looks like an oldish kernel...I assume http://trac.cross-lfs.org/ allows you to update to a new kernel if you wanted to?

you are more advanced than me...I have never used LFS.
The issues I am having pertain to the OS that is running on the CD-R, not the HDD. With operator input, the scripts running on the CD-R will install a CLFS (Cross-Compile LFS) OS onto the HDD. When the process is done, and the system is rebooted without the CD-R, the distro on the HDD boots fine and from there, the CD-ROM drive works like a charm.

The OS running on the CD-R is a morph of the CLFS. In lieu of using a huge suite of packages, I rely on BusyBox for my shell and various system utilities. The 'eject' command is not part of BusyBox; it is provided by the eject-2.1.5 source package.

News update... I have found that I can eject the CD-R if I place two 'eject' statements back-to-back in my script. When the second 'eject' is called, the "CDROM eject" command works, as opposed to the first time where it fails and 'eject' issues a "SCSI eject" command.

Now for another problem, if I install the CLFS distro onto the HDD, and following this the two eject commands are issued, then half of my screen is filled with error messages similar to the following:
Code:
[  340.092309] Buffer I/O error on device hdb, logical block 199157
[  340.093225] Buffer I/O error on device hdb, logical block 199158
...
[  340.100475] Buffer I/O error on device hdb, logical block 199174
These error messages are not from 'eject', but from the kernel.
 
Old 01-24-2008, 05:10 PM   #10
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
I can not help...but why not buy cdrws to save on coasters
 
Old 01-24-2008, 05:35 PM   #11
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
The CD-R disks are free... my employer buys them. As for the environment, well I'll worry about that tomorrow.
 
Old 01-24-2008, 06:05 PM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Have a look at the shutdown script for knoppix - you'll (probably) need to set the unlock and autoeject flags.
 
Old 01-24-2008, 06:30 PM   #13
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I'm leaving to go on holiday tomorrow, and I won't be able to return to this problem for a few weeks. For now, I've decided to use the kludge I discovered earlier.

For my do_install_wrapper.sh script, I have modified it to use two 'eject' commands. This forces the CD-ROM tray to eject the disk. Here's the modified portion of the script:
Code:
...
echo "************************************************************************"
echo "************************************************************************"
echo "****"
echo "****  Please reboot the system after you have removed the CDROM."
echo "****"
echo "************************************************************************"
echo "************************************************************************"

# eject the CD-R from the drive
# The rationale for having 2 eject calls is to convince the system that we want
# our CD-R to be ejected.  With only one eject call, such will not happen.  For
# some reason, the first attempt clears settings within the drive which then
# allow for the second call to succeed.
eject -s /dev/cdrom >/dev/null 2>/dev/null
eject -r /dev/cdrom >/dev/null 2>/dev/null

# don't let the script exit; this will mask the "kernel panic" that would
# otherwise ensue.
runForever=true
while [ $runForever = true ]
do
        runForever=true         # a statement is needed; this is as good as any.
done
 
Old 03-03-2008, 08:49 AM   #14
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
It's been more than a few weeks, have you returned to the problem & found a more elegant solution?
 
Old 03-03-2008, 10:43 AM   #15
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
No I was not able to return to this issue. It would be nice to resolve, however I just learned to accept it. The issue will only be seen at the factory (or by service personnel) and never by the client. Nevertheless, it would be nice to clean it up.
 
  


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
Linux ejecting my DVDRW stefaandk Linux - Newbie 5 01-16-2007 04:41 PM
problem, dual boot, xp/redhat, cdtray kept ejecting, del redhat part. wont boot a OS mraym84 Linux - General 2 08-22-2004 01:46 PM
Mandrake Linux 10, Ejecting the CD-ROM while running WineX bloodredbath Linux - Hardware 3 04-09-2004 02:49 PM
Redhat Linux 7.3 Boot up issue jdelalx Linux - General 1 11-26-2003 06:19 PM

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

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