old-www/LDP/LG/issue86/tag/3.html

325 lines
13 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<META NAME="generator" CONTENT="lgazmail v1.4G.a">
<TITLE>The Answer Gang 86: alternatives for the Big Red Switch</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!-- begin 3 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>alternatives for the Big Red Switch</H3>
<H4 ALIGN="center">consider journaling...</H4>
<p><strong>From Mark Morshedi
</strong></p>
<p></strong></p>
<!-- sig -->
<!-- sig -->
<!-- ::
alternatives for the Big Red Switch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
consider journaling...
:: -->
<p align="right"><strong>Answered By Thomas Adams, David Mandala, John Karns, Rick Moen, Mike "Iron" Orr, Didier Heyden, Heather Stern
</strong></p>
<P><STRONG>
What if the only option is to use the power switch to turn off the system.
there are times that mouse doesn't work and keyboard is dead. how does one
manages that without destorying the file system.
</STRONG></P>
<P><STRONG>
thanks
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Thomas]
My first indication is that this is VERY much hardware
specific. You should check that your motherboard can
handle processes like the one that you wish to
implement under linux.
</blockQuote>
<blockQuote>
Typically the programs that you would want to use are:
"apm" which is most likely, the program that will
control the "power-down" feature via the power button
anyway, and also "lm_sensors" so that you can get the
current state of your system.
</blockQuote>
<blockQuote>
As far as not allowing the filesystem to get mangled,
you can set the maximum mount check point to an
arbitrary value (I have it set at 100), using the
"tune2fs" program. Thus you can specify:
</blockQuote>
<blockQuote><CODE>
tune2fs -c 100
</CODE></blockQuote>
<blockQuote>
means that your filesystem WONT be checked until it
has been mounted 100 times. You can extend this
further to say that:
</blockQuote>
<blockQuote><CODE>
tune2fs -i [d/m] whereby you can set the next check to
<BR>be in either days or months. Have a look at "man
<BR>tune2fs" for more details.
</CODE></blockQuote>
<blockquote><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Heather] Note that lm_sensors is specifically <EM>not</EM> recommended for some
hardware; some thinkpad models crash hard and in fact the hardware
suffers wickedly (see <A HREF="http://www.linux-thinkpad.org"
>http://www.linux-thinkpad.org</A> for details).
Do check the internet for comments about lm_sensors and your motherboard
before just brazenly invoking it.
</blockquote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [David]
One can try the three finger salute Control Alt Delete which sometimes
will cause a orderly shutdown and restart. Or one can use the ext3
filesystem option on newer versions of Linux which are safer to data
loss.
</blockQuote>
<blockQuote>
If the machine is networked you could try sshing or telnetting into the
locked machine, sometimes the console is locked but the machine is still
active on the network and you can gain control that way.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [John]
Re: journaling filesystems (ext3 mentioned below) I've been very happy
with reiserfs over the past 18 months. Then there is the SGI (?)
contributed XFS. See the LG issue 68
<a href="http://www.linuxgazette.com/issue68/dellomodarme.html">article about journaling filesystems</a>
for more info about them.
</blockQuote>
<blockQuote>
The magic SysRQ can also help, unless the kernel is locked up hard. It's
worked for me on a number of occasions. For a system lock-up, the key
sequence that I most often use is Alt-SysRq-S, Alt-SysRq-U, and
Alt-SysRq-B which syncs buffers, unmounts fs's, and reboots, respectively.
You may need to recompile your kernel to enable the feature though. For
moe info, see <TT>/usr/src/linux/Documentation/sysrq.txt</TT>
</blockQuote>
<P><STRONG>
<IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [David]
I remember reading somewhere how to hook up the power switch on an ATX
power supply to do an orderly shutdown but I don't remember where.
Anybody else remember?
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Rick]
You might be thinking of Joris van Rantwijk's Linux PowerSwitch Driver.
Description: "The powerswitch driver makes it possible to use the ATX
power button on your computer to shutdown Linux. You simply press the
power button, and the driver shuts down Linux and powers off the
machine, just like the shutdown command does."
</blockQuote>
<blockQuote>
<A HREF="http://deadlock.et.tudelft.nl/~joris/powerswitch"
>http://deadlock.et.tudelft.nl/~joris/powerswitch</A>
</blockQuote>
<blockQuote><DL><DT>
A different approach:
<DD><A HREF="http://www.geocrawler.com/archives/3/38/1999/9/50/2611153"
>http://www.geocrawler.com/archives/3/38/1999/9/50/2611153</A>
</DL></blockQuote>
<blockQuote><DL><DT>
Or a kernel patch for the ACPI code:
<DD><A HREF="http://www.cs.helsinki.fi/linux/linux-kernel/2001-31/0968.html"
>http://www.cs.helsinki.fi/linux/linux-kernel/2001-31/0968.html</A>
</DL></blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Iron]
Since this is a different driver than the keyboard driver, it may work
even when the keyboard doesn't respond. However, if not losing data is
your primary concern, the first step to do is to switch to a journalled
filesystem. It's easy to switch from ext2 to ext3.
</blockQuote>
<blockQuote><ol>
<LI>Make sure your kernel has ext3 support compiled in. (Not a module,
because you don't want it to fail if something happens to the module
files.)
<LI>Boot to single-user mode (or use "telinit s").
<LI>For each filesystem:
<OL>
<LI> Verify it's unmounted or mounted read-only.
<LI> Run "tune2fs -j /dev/THE_PARTITION".
</OL>
<LI>Change "ext2" to "ext3" in /etc/fstab for the affected filesystems.
<LI>Switch back to multi-user mode.
</ol></blockQuote>
<blockQuote>
You can also place <TT>/usr</TT> on a separate partition and mount it read-only
except when installing software, to prevent those files from being
corrupted in an unclean shutdown.
</blockQuote>
<blockQuote>
Make sure your rescue floppy (from your distribution, www.toms.net/rb/,
etc) has support for the journalled filesystem you're using, or you won't be
able to repair it from the floppy. Last I saw, Tom's supported ext3 out of
the box, but for ReiserFS you had to put a custom kernel on the floppy.
You may also want to leave <TT>/boot</TT> as ext2 (mounted read-only of course) to
ensure it's repairable from the widest variety of rescue floppies, should
the need ever arise.
</blockQuote>
<blockQuote>
Of course, you'll also want to determine why the keyboard is not responding
and how to fix it. However, if you're stuck with unreliable hardware,
immature drivers for your gee-whiz must-have peripherals, or you occasionally run
out of both memory and swap, there's not much you can do except press the reset
button or the power switch.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Didier]
I'm being rather off-topic here, but this summarizes perfectly the
problem I had with my old graphics board -- a hardware issue ...
seemingly solved by replacing the defective (or MVP3-incompatible) thing
with another video card.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Iron]
But your first line of defense when the console hangs is to try to ssh or telnet
in from another computer, because usually those services are unaffected. It may
take a long time if the system is "thrashing" (meaning free memory is so low it's
constantly swapping to disk), but you may be able to do a clean "halt" or "reboot"
command that way.
</blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Didier]
Regarding 'ext3' however, it may be worth mentioning the following
discussion about a data corruption bug recently found in the 2.4.20
kernel:
</blockQuote>
<blockQuote><BLOCKQuote>
<A HREF="http://kerneltrap.org/node.php?id=515"
>http://kerneltrap.org/node.php?id=515</A>
</BLOCKQuote></blockQuote>
<blockQuote>
The funny thing is, ever since I started using 2.4.x kernels, and
regardless of the actual 'ext' filesystem subtype, I've had to 'sync'
<em>multiple times</em> and introduce artificial delays right before powering
off the beast, otherwise the filesystems are almost invariably found
to "have not been unmounted cleanly" on the next boot.
</blockQuote>
<blockquote><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Heather] The nature of the problem, and a workaround, is summarized nicely on this kernel-traffic entry:
<A HREF="http://kt.zork.net/kernel-traffic/kt20021209_195.html#16"
>http://kt.zork.net/kernel-traffic/kt20021209_195.html#16</A>
</blockquote>
<blockquote>This bug has been caught and the patch is now available; to be safe
you need to be either using an early enough kernel (the nasty bug
was introduced in 2.4.20-pre5, but I think I saw discussion about
interaction with a more subtle bug that lurked in the 2.4.19 series)
or a late enough one (this one was nailed in 2.4.20-pre1, and two more
notable ext3 bugs were nailed in -pre2).
</blockquote>
<blockquote>When I realized that some of my dev work was going to heavily crash my
development workstation, I decided I needed journals; saving
<EM>everything</EM> aside for a thorough reiserfs makeover looked like no fun,
so ext3 was my first try. That was when 2.4.19-pre10 was current and
I've not encountered any sync problems; I'd certainly know, because
a lot of my testing involves swapping drives around, so I'm up and
down all the time deliberately as well. Also, It's not at all clear
whether this ever affected the backported-to-2.2.x ext3 support, since
the main flaw was in an optimization trick.
</blockquote>
<blockquote>There was apparently some benchmark comparing reiserfs and ext3
mid-year 2002; it generated an awful lot of mailing list traffic at the
time, easy to find in Google/linux when looking for both keywords together.
</blockquote>
<!-- end 3 -->
<!-- *** 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 86 of <i>Linux Gazette</i>, January 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>
</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 ========================================================= -->