LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Issue ejecting CD-R used to boot Linux (https://www.linuxquestions.org/questions/linux-software-2/issue-ejecting-cd-r-used-to-boot-linux-615362/)

dwhitney67 01-21-2008 10:57 PM

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.

aus9 01-22-2008 06:39 AM

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.

dwhitney67 01-23-2008 08:15 AM

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.

aus9 01-23-2008 09:04 PM

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

dwhitney67 01-23-2008 09:50 PM

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.

jailbait 01-23-2008 10:15 PM

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

aus9 01-23-2008 10:36 PM

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.

dwhitney67 01-24-2008 10:49 AM

Quote:

Originally Posted by jailbait (Post 3033311)
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!

dwhitney67 01-24-2008 12:23 PM

Quote:

Originally Posted by aus9 (Post 3033332)
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.

aus9 01-24-2008 05:10 PM

I can not help...but why not buy cdrws to save on coasters

dwhitney67 01-24-2008 05:35 PM

The CD-R disks are free... my employer buys them. As for the environment, well I'll worry about that tomorrow.

syg00 01-24-2008 06:05 PM

Have a look at the shutdown script for knoppix - you'll (probably) need to set the unlock and autoeject flags.

dwhitney67 01-24-2008 06:30 PM

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


archtoad6 03-03-2008 08:49 AM

It's been more than a few weeks, have you returned to the problem & found a more elegant solution?

dwhitney67 03-03-2008 10:43 AM

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.


All times are GMT -5. The time now is 05:55 AM.