<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>seigafuse.com &#187; Systems Administration</title>
	<atom:link href="http://seigafuse.com/category/technology/systems-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://seigafuse.com</link>
	<description>Mike Seigafuse&#039;s Technology and IT Security Blog</description>
	<lastBuildDate>Fri, 20 Aug 2010 16:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>OCS Diff script</title>
		<link>http://seigafuse.com/2008/12/19/ocs-diff-script/</link>
		<comments>http://seigafuse.com/2008/12/19/ocs-diff-script/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 16:10:52 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Systems Administration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[OCS-NG]]></category>

		<guid isPermaLink="false">http://seigafuse.com/?p=108</guid>
		<description><![CDATA[Here is the script I used to generate hardware change reports from the OCS NG database.  This script is implemented much like the daily disk reports from OCS (see this).  Sorry there is no better documentation for this, I just have not had the time and soon will no longer have access to test or [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the script I used to generate hardware change reports from the OCS NG database.  This script is implemented much like the daily disk reports from OCS (see <a href="http://seigafuse.com/2007/07/26/daily-diskspace-alerts-using-ocs-inventory-ng/">this</a>).  Sorry there is no better documentation for this, I just have not had the time and soon will no longer have access to test or refine this.  If you post a comment here I will try to help as best I can and as time allows.</p>
<p><a class="downloadlink dlimg" href="http://seigafuse.com/wp-content/plugins/download-monitor/download.php?id=6" title="Version 1.0 downloaded 821 times" ><img src="http://seigafuse.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download OCS Diff Version 1.0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://seigafuse.com/2008/12/19/ocs-diff-script/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Daily diskspace alerts using OCS Inventory NG</title>
		<link>http://seigafuse.com/2007/07/26/daily-diskspace-alerts-using-ocs-inventory-ng/</link>
		<comments>http://seigafuse.com/2007/07/26/daily-diskspace-alerts-using-ocs-inventory-ng/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 01:51:25 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://seigafuse.com/?p=36</guid>
		<description><![CDATA[Being proactive about managing system capacity is always a good idea. If you happen to use the OCS Inventory NG tool then here is a way for you to automatically have reports emailed to you (or various people) regarding systems with disk capacity below a threshold you set in a configuration file. This solution is [...]]]></description>
			<content:encoded><![CDATA[<p>Being proactive about managing system capacity is always a good idea.  If you happen to use the OCS Inventory NG tool then here is a way for you to automatically have reports emailed to you (or various people) regarding systems with disk capacity below a threshold you set in a configuration file.  This solution is geared towards Windows Servers, but you can easily change the select statement and use a different criteria (change where osname like &#8216;%server%&#8217; to suit yourself).  The results are sent as an attached CSV file, so you can easily view it in Excel or Open Office or even using vi if that is suits your fancy.</p>
<p>The percentage free space threshold, along with email addresses and domain names (aka workgroup names) are configured in a file named ocsdiff_conf.php.  I run this (and other reports which I may post later) from a new subdirectory named reports that I created under /var/www/html/ocsreports.  Be sure to set the same ownership and permissions on files in this directory as the other files under ocsreports.  Here is what the file looks like:</p>
<p><a href="javascript:showme('4596_1');"> <b>> ocsdiff_conf.php</b></a>
<div style="display: none; background:white;" id=4596_1>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #808080; font-style: italic;"># ocsdiff configuration file</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Database host</span>
<span style="color: #0000ff;">$dbhost</span> = <span style="color: #ff0000;">"localhost"</span>;
<span style="color: #0000ff;">$dbname</span> = <span style="color: #ff0000;">"ocsweb"</span>;
<span style="color: #0000ff;">$dbuser</span> = <span style="color: #ff0000;">"ocs"</span>;
<span style="color: #0000ff;">$dbpass</span> = <span style="color: #ff0000;">"XXX"</span>;
<span style="color: #0000ff;">$adminemail</span> = <span style="color: #ff0000;">"admin@yourdomain.tld"</span>;
<span style="color: #0000ff;">$diskthreshold</span> = <span style="color: #cc66cc;">5</span>; <span style="color: #808080; font-style: italic;"># percentage free space threshold</span>
<span style="color: #0000ff;">$domains</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
		<span style="color: #cc66cc;">0</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'XXXXX'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"fred@yourdomain.tld,barney@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span>,
		<span style="color: #cc66cc;">1</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'YYYYY'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"wilma@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span>,
		<span style="color: #cc66cc;">2</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'ZZZZZ'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"betty@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$diskdomains</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
		<span style="color: #cc66cc;">0</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'XXXXX'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"fred@yourdomain.tld,barney@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span>,
		<span style="color: #cc66cc;">1</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'YYYYY'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"wilma@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span>,
		<span style="color: #cc66cc;">2</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
			<span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'ZZZZZ'</span>,
			<span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">"betty@yourdomain.tld"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</div>
<p>The file is named like this because the first report I wrote was to generate reports on hardware changes (RAM and disk in particular).  I know reports like this can be implemented using GLPI integration &#8211; but we already have a helpdesk/ticketing system and I just can&#8217;t justify the effort to setup GLPI when writing one&#8217;s own reports is just not that hard.</p>
<p>The report itself is contained in the code below, I named the file diskreport.php and I scheduled it to run everyday using cron.  I run my cron jobs for OCS-NG reports under the apache account.</p>
<p><a href="javascript:showme('4596_2');"> <b>> diskreport.php</b></a>
<div style="display: none; background:white;" id=4596_2>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #808080; font-style: italic;"># This program will generate a daily report of disks with free space</span>
<span style="color: #808080; font-style: italic;"># below a threshold set in the configuration file </span>
<span style="color: #808080; font-style: italic;"># Written by Mike Seigafuse July 2007</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Get the configuration file</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"ocsdiff_conf.php"</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Initialize headers so that email will be readable as Excel attachment</span>
<span style="color: #0000ff;">$today</span> = <a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Y-m-d G:i:s"</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$headers</span> = <span style="color: #ff0000;">"From: ITInventory@yourdomain.tld<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">"Reply-To: ITInventory@yourdomain.tld<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">"MIME-Version: 1.0<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">"Content-type: text/html; charset=iso-8859-1<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">"Content-type: application/vnd.ms-excel<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #0000ff;">$headers</span> .= <span style="color: #ff0000;">"Content-disposition: attachment; filename=$today.csv<span style="color: #000099; font-weight: bold;">\\r</span><span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
<span style="color: #808080; font-style: italic;"># Connect to database</span>
<span style="color: #0000ff;">$link</span> = <a href="http://www.php.net/mysql_connect"><span style="color: #000066;">mysql_connect</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"$dbhost"</span>, <span style="color: #ff0000;">"$dbuser"</span>, <span style="color: #ff0000;">"$dbpass"</span><span style="color: #66cc66;">&#41;</span>
    or <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Could not connect : "</span> . <a href="http://www.php.net/mysql_error"><span style="color: #000066;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/mysql_select_db"><span style="color: #000066;">mysql_select_db</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"$dbname"</span><span style="color: #66cc66;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Could not select database"</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Now loop through the defined disk domains and prepare report </span>
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$i</span> &lt; <a href="http://www.php.net/sizeof"><span style="color: #000066;">sizeof</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$diskdomains</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0000ff;">$entry</span> = <span style="color: #0000ff;">$diskdomains</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$name</span> = <span style="color: #0000ff;">$entry</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'name'</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$email</span> = <span style="color: #0000ff;">$entry</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'email'</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$subject</span> = <span style="color: #ff0000;">"Daily Disk Utilization Report for domain $name"</span>;
	<span style="color: #0000ff;">$msg</span> = <span style="color: #ff0000;">"Computer Name,Drive Letter,Type,Filesystem,Total,Free,Free %<span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
	<span style="color: #808080; font-style: italic;"># Now we have the domain name and contact, next get a current list of</span>
	<span style="color: #808080; font-style: italic;"># deviceIDs from this domain</span>
	<span style="color: #0000ff;">$query</span> = <span style="color: #ff0000;">"select id, name, userid from hardware where workgroup='$name' and osname like '%server%'"</span>;
	<span style="color: #0000ff;">$deviceresults</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">&#41;</span>  or <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Query failed : "</span> . <a href="http://www.php.net/mysql_error"><span style="color: #000066;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color: #000066;">mysql_fetch_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$deviceresults</span>, MYSQL_ASSOC<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$deviceid</span> = <span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#93;</span>;
		<span style="color: #0000ff;">$computername</span> = <a href="http://www.php.net/rtrim"><span style="color: #000066;">rtrim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'name'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #808080; font-style: italic;"># Disk checking section</span>
		<span style="color: #0000ff;">$query</span> = <span style="color: #ff0000;">"select letter, type, filesystem, total, free
			from drives
			where hardware_id='$deviceid' and
			type = 'Hard Drive'"</span>;
		<span style="color: #0000ff;">$diskresults</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">&#41;</span>  or <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Query failed : "</span> . <a href="http://www.php.net/mysql_error"><span style="color: #000066;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #808080; font-style: italic;"># All information is now collected, now generate output </span>
		<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$diskline</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color: #000066;">mysql_fetch_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$diskresults</span>, MYSQL_ASSOC<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0000ff;">$driveletter</span> = <span style="color: #0000ff;">$diskline</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'letter'</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0000ff;">$drivetype</span> = <span style="color: #0000ff;">$diskline</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0000ff;">$drivefs</span> = <span style="color: #0000ff;">$diskline</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'filesystem'</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0000ff;">$drivetotal</span> = <span style="color: #0000ff;">$diskline</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'total'</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0000ff;">$drivefree</span> = <span style="color: #0000ff;">$diskline</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'free'</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0000ff;">$freeperc</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$drivefree</span>/<span style="color: #0000ff;">$drivetotal</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$freeperc</span> &lt; <span style="color: #0000ff;">$diskthreshold</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #0000ff;">$msg</span> .= <span style="color: #ff0000;">"$computername,$driveletter,$drivetype,$drivefs,$drivetotal,$drivefree,$freeperc<span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;"># end of disk loop</span>
		<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;"># end of devices in a domain loop</span>
	<span style="color: #808080; font-style: italic;"># send out the email for this domain</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$msg</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$msg</span> = <span style="color: #ff0000;">"No disk space issues found<span style="color: #000099; font-weight: bold;">\\n</span>"</span>;
	<a href="http://www.php.net/mail"><span style="color: #000066;">mail</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"$email"</span>, <span style="color: #0000ff;">$subject</span>, <span style="color: #0000ff;">$msg</span>, <span style="color: #0000ff;">$headers</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;"># end of domain loop</span>
<span style="color: #808080; font-style: italic;"># Almost done, just need to free up result memory</span>
<a href="http://www.php.net/mysql_free_result"><span style="color: #000066;">mysql_free_result</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$deviceresults</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/mysql_free_result"><span style="color: #000066;">mysql_free_result</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$diskresults</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># The End :)</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</div>
<p>Be sure to change the From and Reply To addresses in at the top of the file to suit yourself.  If I have time I will move this to the configuration file.</p>
<p>My version of OCS-NG displays 4020 on the screen, I believe this equates to V1.0 (I know 1.01 is released, but just haven&#8217;t had the time to upgrade yet).  I am running on RHEL 4.</p>
<p>Use the link below to download a zip file of both of these files.  If you have any comments or questions post a comment on this post and I will reply.</p>
<p><a class="downloadlink dlimg" href="http://seigafuse.com/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 982 times" ><img src="http://seigafuse.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download OCS-NG Diskspace Report Version 1.0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://seigafuse.com/2007/07/26/daily-diskspace-alerts-using-ocs-inventory-ng/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Recovering a Linux server on different disk partitions</title>
		<link>http://seigafuse.com/2007/02/06/recovering-a-linux-server-on-different-disk-partitions/</link>
		<comments>http://seigafuse.com/2007/02/06/recovering-a-linux-server-on-different-disk-partitions/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 03:54:50 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://seigafuse.com/?p=27</guid>
		<description><![CDATA[We lost a disk in the RAID 5 array on one our Dell 2550 Linux servers today. Usually this is no big deal, just replace the disk and the array rebuilds right? Not quite &#8211; for some unexplained reason the array was &#8220;inconsistent&#8221; and we had to destroy and rebuild the container. No big deal, [...]]]></description>
			<content:encoded><![CDATA[<p>We lost a disk in the RAID 5 array on one our Dell 2550 Linux servers today.  Usually this is no big deal, just replace the disk and the array rebuilds right?  Not quite &#8211; for some unexplained reason the array was &#8220;inconsistent&#8221; and we had to destroy and rebuild the container.  No big deal, we have backups so it should just be a matter of reinstalling the OS, installing our backup client software (NetWorker) and doing a restore allowing the restore to overwrite files.  This should be a no-brainer.  But, what if the disk was not partitioned on the new install the same as the original system?  Once the restore completed we have now overwritten /boot/grub/grub.conf with the file that matches the original install &#8211; what if the boot partition is no longer at the same location?</p>
<p>After the restore the system administrator attempted to reboot, and was informed that the system could not find the boot file.  Now what?  No worries, simply do the following:</p>
<ul>
<li>Insert the install CD and boot from it</li>
<li>Hit F5, and then enter Linux rescue</li>
<li>Select OK to search for Linux installs</li>
<li>Select continue to mount the install disk found</li>
</ul>
<p>Once you get to the command prompt do the following:</p>
<ul>
<li>cd /mnt/sysimage/boot/grub</li>
<li>TERM=VT100;export TERM</li>
<li>vi grub.conf</li>
</ul>
<p>You should see a file that looks like this:</p>
<blockquote><p># grub.conf generated by anaconda<br />
#<br />
# Note that you do not have to rerun grub after making changes to this file<br />
# NOTICE:  You do not have a /boot partition.  This means that<br />
#          all kernel and initrd paths are relative to /, eg.<br />
#          root (hd0,1)<br />
#          kernel /boot/vmlinuz-version ro root=/dev/sda2<br />
#          initrd /boot/initrd-version.img<br />
#boot=/dev/sda<br />
default=0<br />
timeout=10<br />
splashimage=(hd0,0)/boot/grub/splash.xpm.gz<br />
title Red Hat Enterprise Linux ES (2.4.21-40.EL)<br />
root <strong>(hd0,0)<br />
</strong> kernel /boot/vmlinuz-2.4.21-40.EL ro root=LABEL=/<br />
initrd /boot/initrd-2.4.21-40.EL.img<br />
title Red Hat Enterprise Linux ES (2.4.21-20.EL)<br />
root <strong>(hd0,0)<br />
</strong> kernel /boot/vmlinuz-2.4.21-20.EL ro root=LABEL=/<br />
initrd /boot/initrd-2.4.21-20.EL.img</p></blockquote>
<p>The bolded entries above are the ones of interest.  hd0 is obviously the first hard drive, and the 0 after the comma is the partition on that disk.  In our case the original system had the boot partition located on partition 1 but after the rebuild I changed it as indicated here to what you see 0.  If you aren&#8217;t sure which partition is which you should be able to enter command line mode in grub after your boot fails by entering &#8220;c&#8221;.  Then by entering &#8220;geometry (hd0)&#8221; which should display something like this:</p>
<blockquote><p>grub> geometry (hd0)<br />
drive 0&#215;80: C/H/S = 6637/255/63, The number of sectors = 106633728, /dev/sda<br />
Partition num: 0,  Filesystem type is ext2fs, partition type 0&#215;83<br />
Partition num: 1,  Filesystem type is ext2fs, partition type 0&#215;83<br />
Partition num: 2,  Filesystem type is ext2fs, partition type 0&#215;83<br />
Partition num: 4,  Filesystem type is ext2fs, partition type 0&#215;83<br />
Partition num: 5,  Filesystem type is ext2fs, partition type 0&#215;83<br />
Partition num: 6,  Filesystem type unknown, partition type 0&#215;82<br />
Partition num: 7,  Filesystem type is ext2fs, partition type 0&#215;83  grub></p></blockquote>
<p>Good information, but which one is /boot?  Try entering the below and you will get your answer:</p>
<blockquote><p>grub> find /boot/grub/grub.conf<br />
(hd0,0)</p></blockquote>
<p>Partition 0 is /boot on this system &#8211; your mileage may vary <img src='http://seigafuse.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://seigafuse.com/2007/02/06/recovering-a-linux-server-on-different-disk-partitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

