<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Tom Moertel's Weblog: Tag shutdown</title>
    <link>http://blog.moertel.com/articles/tag/shutdown?tag=shutdown</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Quality rants on programming theory and stuff geeks like</description>
    <item>
      <title>How to make sure your servers come back up after an extended power outage</title>
      <description>&lt;p&gt;If an extended power outage drains your &lt;span class="caps"&gt;UPS&lt;/span&gt;, and your servers are
forced to shut down, will they automatically start up again when the
power is eventually restored?  It&amp;#8217;s a good question, especially
if your servers are in some distant, unattended server room.
Unless you&amp;#8217;ve tested your servers, don&amp;#8217;t assume that the answer
is Yes.&lt;/p&gt;


	&lt;p&gt;Many servers offer a &lt;span class="caps"&gt;BIOS&lt;/span&gt; configuration option that forces them to
automatically power on when they receive line voltage.  If your
servers have this option, just set it and you&amp;#8217;re done.&lt;/p&gt;


	&lt;p&gt;Unfortunately, some servers, including a Dell PowerEdge 1600SC
that I&amp;#8217;m using, lack this configuration option.  When these servers
turn themselves off as the final step of a &lt;span class="caps"&gt;UPS&lt;/span&gt;-controlled
shutdown, they don&amp;#8217;t start up again when the power is restored.
Because they were shut down &lt;em&gt;before&lt;/em&gt; the power was cut off, they think
they are supposed to remain off when the power is restored.  That is,
they remember their on/off status across power outages.&lt;/p&gt;


	&lt;p&gt;Fortunately, there is a way to make sure these servers automatically
power on: shut them  down without powering them off; halt them
instead.  That way, when the &lt;span class="caps"&gt;UPS&lt;/span&gt; finally cuts off the supply voltage,
the servers will still be in their &amp;#8220;on&amp;#8221; state, and they will remember
this state across the outage. Later, when the power is restored, the servers
will automatically restore their pre-outage state and power up.&lt;/p&gt;


	&lt;p&gt;With Fedora Core Linux and &lt;a href="http://www.networkupstools.org/"&gt;Network &lt;span class="caps"&gt;UPS&lt;/span&gt;
Tools&lt;/a&gt;, it&amp;#8217;s not difficult to make
sure the servers are halted instead of powered off, but the implementation
isn&amp;#8217;t obvious.  To spare you the digging, here are the
important bits.&lt;/p&gt;


&lt;ol&gt;

&lt;li&gt;When the power fails and the &lt;span class="caps"&gt;UPS&lt;/span&gt;-monitoring software decides that
the batteries are almost depleted, it will initiate a server shutdown
using the command defined in the &lt;code&gt;/etc/ups/upsmon.conf&lt;/code&gt;
file.  The default command is this:

&lt;pre&gt;&lt;code&gt;SHUTDOWNCMD "/sbin/shutdown -h +0" 
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;The shutdown command will tell the &lt;code&gt;init&lt;/code&gt; process
to enter runlevel 0, which is the prepare-to-halt-the-system runlevel.&lt;/li&gt;

&lt;li&gt;The &lt;code&gt;init&lt;/code&gt; process will stop all of the running
services in an orderly fashion, and then, as the last step, invoke the
final script in the shutdown process:
&lt;code&gt;/etc/rc.d/rc0.d/S01halt&lt;/code&gt;.&lt;/li&gt;

&lt;li&gt;The final lines of the &lt;code&gt;S01halt&lt;/code&gt; script will
power off the server.  Unless, that is, the file &lt;code&gt;/halt&lt;/code&gt; is
present, in which case the script will halt the server instead.&lt;/li&gt;

&lt;/ol&gt;

	&lt;p&gt;Thus the trick is to make sure that the &lt;code&gt;/halt&lt;/code&gt;
file &lt;em&gt;does&lt;/em&gt; exist.  The trick turns out to be easy to pull off;
just redefine the shutdown command in &lt;code&gt;/etc/ups/upsmon.conf&lt;/code&gt;:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;SHUTDOWNCMD "/bin/touch /halt; /sbin/shutdown -h +0" 
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;And that&amp;#8217;s all there is to it!&lt;/p&gt;</description>
      <pubDate>Wed, 09 Aug 2006 00:35:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:488c24a8-dcb3-4015-8d8e-09f6267e6051</guid>
      <author>Tom Moertel</author>
      <link>http://blog.moertel.com/articles/2006/08/09/how-to-make-sure-your-servers-come-back-up-after-an-extended-power-outage</link>
      <category>linux</category>
      <category>hardware</category>
      <category>sysadmin</category>
      <category>hardware</category>
      <category>ups</category>
      <category>linux</category>
      <category>fedora</category>
      <category>nut</category>
      <category>power</category>
      <category>shutdown</category>
      <category>halt</category>
      <trackback:ping>http://blog.moertel.com/articles/trackback/151</trackback:ping>
    </item>
  </channel>
</rss>
