old-www/LDP/LG/issue95/tag/2.html

324 lines
12 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<META NAME="generator" CONTENT="lgazmail v1.4G.k">
<TITLE>The Answer Gang 95: force unmounting of CDROM</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!--endcut ==============================================-->
<!-- begin 2 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>force unmounting of CDROM</H3>
<p><strong>From Chady Kassouf
</strong></p>
<p></strong></p>
<p align="right"><strong>Answered By: Thomas Adam, Mike Martin, Karl-Heinz Herrmann
</strong></p>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Hello Answer Gang,
</STRONG></P>
<P><STRONG>
I backed up most of my files on CD-Rs that later on appeared to be of very
low quality, now none of my CD-ROM of CD-Writer drives manage to read from
them, but that's not where the problem is.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
As long as you have (hopefully) learnt from the exercise, that's all the
matters
<IMG SRC="../../gx/dennis/smily.gif" ALT=":)"
height="24" width="20" align="middle">
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
The fact that mounting a CDROM in linux locks the drive is making a problem
with these CDs.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
How so? The whole idea of locking the drive is to do with the way the
mount command works.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
OK, the CDs are bad, there's no way to read them, but there's the problem of
not being able to unmount them, linux will just keep on trying to chew on
the bad CD, and killing `cp' will not make it give up. `umount' will either
hang forever waiting for system to finish reading from the drive, or it will
return but the drive will not be released. same thing will happen with
`eject'
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
If you're trying to umount a <TT>/cdrom</TT> that is currently being read/write to,
then what you should do is:
</blockQuote>
<blockquote><pre>ps waxf
</pre></blockquote>
<blockQuote>
to see the upper program that is being called below "mount <TT>/cdrom</TT>", and
do:
</blockQuote>
<blockquote><pre>kill -9 $(pidof &lt;program_name&gt;)
</pre></blockquote>
<blockQuote>
(rude, I know). Then you'll be able to do:
</blockQuote>
<blockquote><pre>umount /cdrom
</pre></blockquote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I'm using RedHat 7.3, and the guilty drives are a TEAC 40X CDROM and an HP
8200Plus CD-Writer.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
What you're describing here is not really a problem with the hardware per
se but merely a gripe with the way the kernel and mount mounts a cdrom
drive. Locking the drive is there to prevent the FS from screwing up, and
allowing a clean change of disks via umount.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
It's good to note that while rebooting the machine, init will try to unmount
the filesystems but will fail on the drive that's stuck trying to read,
`umount2' will kick in and retry for three times before finally giving up
and letting the reboot continue.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
Umounting drives is done for a reason. I suspect the reason why you cannot
unmount <TT>/cdrom</TT> is due to Zombie processes clogging up your kernel buffer,
and the kernel doesn't realised that these have effectively stopped.
Usually, I have found in situations like this that a lengthy wait of 30
mins or so, does allow the kernel time to flush itself, and the locked
drive is then accessible via an 'eject'.
</blockQuote>
<blockquote><pre>fuser mount /cdrom
</pre></blockquote>
<blockQuote>
will also help you ascertain this information, as well as the classic:
</blockQuote>
<blockquote><pre>ps wax
</pre></blockquote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
My question is twofold; first, is there a way to tell linux to give up
reading and force unmounting a CDROM drive without having to use the safety
pin and, hence, lose access to the drive, OR reboot he machine?
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
Yes, there is. I have done this on some severe occassions. The first thing
I would try is to:
</blockQuote>
<blockquote><pre>umount -f /cdrom
</pre></blockquote>
<blockQuote>
The "-f" flag says to mount to force umounting of it. If that does not
work, then edit "<TT>/etc/mtab</TT>" and remove the entry pertaining to your cdrom
drive. In case you are wondering, "<TT>/etc/fstab</TT>" holds information about
drives that <EM>can</EM> and <EM>might be</EM> mounted, and "<TT>/etc/mtab</TT>" is there as a
state file for those drives that <EM>are</EM> currently mounted. Editing the file
in this instance is perhaps a good idea.
</blockQuote>
<blockQuote>
If you find that this is happening to you on each and <EM>every</EM> mount, try
doing something like:
</blockQuote>
<blockquote><pre>mount -n /cdrom
</pre></blockquote>
<blockQuote>
which will tell mount NOT to write to <TT>/etc/mtab.</TT> Typically I have used
this on drives whereby "<TT>/</TT>" has been mounted ro, but I cannot see why it
wont work here.
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
Second, anyone happened to have a similar situation? or might that be a
hardware problem?
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
Reading my answer here will not doubt confirm that I have had experience
in this sort of thing. I doubt this is hardware related, but it could be.
I would need to know more information about which aspects of your cdrw
work/don't work in order to help you further.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [K.-H.]
Better use some of the suggestions by Thomas but it seems cdrecord
does not care for the "lock" state of a CD. If you issue:
</blockQuote>
<blockquote><pre>cdrecord -eject
</pre></blockquote>
<blockQuote>
it will simply eject the CD -- regardless if it's locked or mounted. In the
best case the kernel recognises the media is gone and the errors given back
to "cp" causes all concerned processes to stop. Then a umount should also be
possible. Worst case you get a kernel panic for a "damaged" filesystem on the
now nonexistant CD (didn't happen here, mostly it's recovering gracefully).
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [MikeM]
final issue could be a process called fam locking the drive -
sometimes if you kill fam, you can then umount the drive.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
Indeed, Mike. I had considered this, but then I realised that FAM isn't
always loaded on some machines.
</blockQuote>
<blockQuote>
FAM (File Alteration Monitor), is also debian package and an absolute cow
to compile. It is not distro specific, no. It is used to monitor
directory/file changes, so I can see how it <EM>might</EM> be used in this
instance but it is unlikely.
</blockQuote>
<font color="red"><blockquote><em>The querent reported back....
-- Thomas Adam</em></blockquote></font>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I tried all the options presented by the kind people in this list, the only
one that worked though was the cdrecord -eject although it took
about 3 minutes to succeed.
Thanx for K.H for the solution.
</STRONG></P>
<P><STRONG>
I was able to capture the error that was printed out after a file copy in
<A HREF="http://www.kde.org/">KDE</A> started to choke:
</STRONG></P>
<pre><strong>scsi0: ERROR on channel 0, id 0, lun 0, CDB: Request Sense 00 00 00 40 00
Info fld=0x1a4f7, Current sd0b:00: sense key Medium Error
Additional sense indicates No seek complete
I/O error: dev 0b:00, sector 431068
</strong></pre>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [K.-H.]
read error from the CD, "Medium error" as you already assumed in your
original mail. Probably nothing to save anymore. I too had some CD's which
came through the file comparison right after burning. Some time later they
gave me plenty of read errors. In my case the read attempts at some point
broke off but as I tried to get as much data back as possible I made
the reading process to try harder.
</blockQuote>
<!-- end 2 -->
<!-- *** BEGIN copyright *** -->
<hr>
<CENTER><SMALL><STRONG>
<h5>
<br>Copyright &copy; 2003
<br>Copying license <A HREF="">http://www.linuxgazette.com/copying.html</A>
<BR>Published in Issue 95 of <i>Linux Gazette</i>, October 2003</H5>
</STRONG></SMALL></CENTER>
<!-- *** END copyright *** -->
<SMALL><CENTER><H6 ALIGN="center">HTML script maintained by
<A HREF="mailto:star@starshine.org">Heather Stern</a> of
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6></SMALL></CENTER>
<HR>
<!--startcut ======================================================= -->
<P> <hr>
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="../index.html"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="../../tag/bios.html">Meet&nbsp;the&nbsp;Gang</A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!--endcut ========================================================= -->
<P> <hr>
<!--startcut ======================================================= -->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!--endcut ========================================================= -->
<!--startcut ======================================================= -->
</BODY></HTML>
<!--endcut ========================================================= -->