<?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>olivetalks &#187; CentOS</title>
	<atom:link href="http://www.olivetalks.com/tag/centos/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.olivetalks.com</link>
	<description>The Olive has arrived and it has things to say…</description>
	<lastBuildDate>Tue, 16 Nov 2010 19:25:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up UPS on CentOS 5.2 with SELinux, part 2</title>
		<link>http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/</link>
		<comments>http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 06:00:10 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[UPS]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/</guid>
		<description><![CDATA[After setting up UPS monitoring software on a computer it would be good to allow access to this information via a web browser.]]></description>
			<content:encoded><![CDATA[<p>In the <a href="/2009/02/19/ups-on-centos-with-selinux-part-1/" title="Setting up UPS on CentOS 5.2 with SELinux, part 1">previous post</a> I have described how to setup monitoring of UPS battery status with <a href="http://www.networkupstools.org/" title="Network UPS Tools">Network UPS Tools</a> so your computer can shut down gracefully in case of power loss. At the end we configured a CGI script to allow checking the UPS status via a web browser. Unfortunately this didn&#8217;t work very well because of a missing SELinux policy. This post will explain how to install the required policy module.</p>
<p><strong>Step one: Define the policy module</strong></p>
<p>To define the policy module for nut CGI create a text file nutcgi.te with the following content:</p>
<p><code>module nutcgi 1.0.8;</code></p>
<p><code>require {</code><br />
<code>type unlabeled_t;</code><br />
<code>type xend_var_log_t;</code><br />
<code>type httpd_sys_script_exec_t;</code><br />
<code>type default_t;</code><br />
<code>type procmail_t;</code><br />
<code>type ping_t;</code><br />
<code>type httpd_t;</code><br />
<code>type httpd_sys_script_t;</code><br />
<code>type port_t;</code><br />
<code>class tcp_socket { write name_connect connect shutdown read create };</code><br />
<code>class lnk_file { read getattr };</code><br />
<code>class file append;</code><br />
<code>class dir search;</code><br />
<code>class packet { recv send };</code><br />
<code>}</code></p>
<p><code>#============= httpd_sys_script_t ==============</code><br />
<code># src="httpd_sys_script_t" tgt="port_t" class="tcp_socket", perms="name_connect"</code><br />
<code># comm="upsstats.cgi" exe="" path=""</code><br />
<code>allow httpd_sys_script_t port_t:tcp_socket name_connect;</code><br />
<code># src="httpd_sys_script_t" tgt="httpd_sys_script_t" class="tcp_socket", perms="{ write read create connect shutdown }"</code><br />
<code># comm="upsstats.cgi" exe="" path=""</code><br />
<code>allow httpd_sys_script_t self:tcp_socket { write read create connect shutdown };</code><br />
<code># src="httpd_sys_script_t" tgt="unlabeled_t" class="packet", perms="{ recv send }"</code><br />
<code># comm="upsstats.cgi" exe="" path=""</code><br />
<code>allow httpd_sys_script_t unlabeled_t:packet { recv send };</code></p>
<p><code>#============= httpd_t ==============</code><br />
<code># src="httpd_t" tgt="httpd_sys_script_exec_t" class="lnk_file", perms="{ read getattr }"</code><br />
<code># comm="httpd" exe="" path=""</code><br />
<code>allow httpd_t httpd_sys_script_exec_t:lnk_file { read getattr };</code></p>
<p>Save the file somewhere.</p>
<p><strong>Step two :  Compile the policy module</strong></p>
<p>Execute the command:</p>
<p><code>checkmodule -M -m nutcgi.te -o nutcgi.mod</code></p>
<p>This will generate a binary file representing the policy module.</p>
<p><strong>Step three: Create a SELinux policy module package</strong></p>
<p>Execute the command:</p>
<p><code>semodule_package -o nutcgi.pp -m nutcgi.mod</code></p>
<p>This will create a SELinux policy module package which can then be installed.</p>
<p><strong>Step four: Install the SELinux policy module package</strong></p>
<p>Execute the command:</p>
<p><code>semodule -i nutcgi.pp</code></p>
<p>Now the policy module is installed. You can refresh the web page with UPS status in your web browser <font color="#000080">http://localhost/cgi-bin/upsstats.cgi</font></p>
<p><a href="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-configured.jpg" title="UPS status in web browser after installing SELinux policy module"></a></p>
<p style="text-align: center"><a href="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-configured.jpg" title="UPS status in web browser after installing SELinux policy module"><img src="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-configured-small.jpg" alt="UPS status in web browser after installing SELinux policy module" /></a></p>
<p>You can also verify that access to this web page from other machines works as intended. SELinux policy module installation is persistent &#8211; you don&#8217;t have to do it again if the system reboots.</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/" title="Setting up UPS on CentOS 5.2 with SELinux, part 1">Setting up UPS on CentOS 5.2 with SELinux, part 1 (0)</a></li><li><a href="http://www.olivetalks.com/2009/06/24/skype-40-for-windows-is-out-pros-and-cons-compared-with-linux-skype-20/" title="Skype 4.0 for Windows is out: Pros and cons (compared with Linux Skype 2.0) ">Skype 4.0 for Windows is out: Pros and cons (compared with Linux Skype 2.0)  (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/17/big-eee/" title="Eee PC 901 &#8211; aka Big Eee">Eee PC 901 &#8211; aka Big Eee (0)</a></li><li><a href="http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/" title="What files did I change?">What files did I change? (2)</a></li><li><a href="http://www.olivetalks.com/2008/06/17/too-much-success-and-popularity/" title="Too much success and popularity?">Too much success and popularity? (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up UPS on CentOS 5.2 with SELinux, part 1</title>
		<link>http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/</link>
		<comments>http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 07:00:57 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[UPS]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/</guid>
		<description><![CDATA[Power failure for a computer can cause data loss and require many hours to undo the damage. That can be especially bad if the computer acts as a server. At the minimum, servers must have a chance to perform an proper shut down to avoid damage to data or hardware.]]></description>
			<content:encoded><![CDATA[<p>My home fileserver is connected to a UPS in order to be able to shut down properly when there&#8217;s a problem with the electricity supply. Of course, just connecting a computer to a UPS won&#8217;t help if the power is cut off for more than a few minutes since the machine won&#8217;t turn itself off before the battery runs out of juice. To guarantee that the OS is aware of the current state of the battery some software needs to be installed and configured. I use for that purpose <a href="http://www.networkupstools.org/" title="Network UPS Tools">Network UPS Tools</a>. If your system is running with SELinux enabled and you want to enable checking of the UPS via a web browser then you also need to install an appropriate SELinux policy module.</p>
<p><strong>Let&#8217;s start with the installation.</strong></p>
<p>First things first &#8211; make sure the UPS is running and connected to the computer. Both power and a serial cable of some kind should be connected. The serial connection can be either via RS-232 or USB.</p>
<p>To install the software execute the following command:</p>
<p><code># yum install nut nut-client nut-cgi</code></p>
<p>or if you&#8217;re running a 64 bit OS and don&#8217;t want 32-bit packages to be installed:</p>
<p><code># yum install nut nut-client.x86_64 nut-cgi</code></p>
<p><strong>Next step: Basic configuration</strong></p>
<p>After the software is installed we need to configure it. Fire up your favourite text editor and open these files:</p>
<ul>
<li>/etc/ups/ups.conf</li>
<li>/etc/ups/upsd.users</li>
<li>/etc/ups/upsmon.conf</li>
<li>/etc/ups/hosts.conf (only if you have installed nut-cgi)</li>
</ul>
<p>In <em>/etc/ups/ups.conf</em> add at the end the following section:</p>
<p><code>user = nut                       # execute the UPS driver as user nut - otherwise the upsd program won't be able to connect to the device </code></p>
<p><code>[pw3105]                                                   # name of the UPS device</code><br />
<code>driver = bcmxcp_usb                  # driver used to access the UPS device</code><br />
<code>port = auto                                          # serial port where the UPS is connected, bcmxcp_usb driver allows to enter 'auto' here</code><br />
<code>shutdown_delay = 0                     # additional parameter supported by bcmxcp_usb driver, see 'man bcmxcp_usb'</code></p>
<p>The comments explain what is the purpose of each line. More details can be found in man page for <a href="http://linux.die.net/man/5/ups.conf" title="ups.conf(5) - Linux man page">ups.conf</a>. The actual name of the UPS device and parameters for it depend on the UPS model you&#8217;re using. I have Powerware 3105 UPS which uses the <a href="http://linux.die.net/man/8/bcmxcp_usb" title="bcmxcp_usb(8) - Linux man page">bcmxcp_usb driver</a>.</p>
<p>Second file to edit is <em>/etc/ups/upsd.users</em> where you should append these lines:</p>
<p><code>[server]                                                    # create a user 'server'</code><br />
<code>password = ups                                  # with password 'ups'</code><br />
<code>allowfrom = localhost             # allowing access only from this machine</code><br />
<code>instcmds = ALL                                  # user can execute all instant commands</code><br />
<code>upsmon master                                    # add actions necessary for a 'upsmon' process to work</code></p>
<p>Again the purpose of each line is explained in the comments. More information as usual in man page for <a href="http://linux.die.net/man/5/upsd.users" title="upsd.users(5) - Linux man page">upsd.users</a>.</p>
<p>If you use different values in <em>/etc/ups/upsd.users</em> you have to make sure that you&#8217;ll use the same values also in the next file we&#8217;re going to edit, which is <em>/etc/ups/upsmon.conf</em>. Here add these lines at the end:</p>
<p><code>FINALDELAY 0                                                                                                          # don't wait before shutting down, allowed values depend on the UPS model</code><br />
<code>RUN_AS_USER nut                                                                                                 # don't run as root to avoid security issues</code><br />
<code>MONITOR pw3105@localhost 1 server ups master          # which UPS to monitor</code></p>
<p>The last line requires a bit of explanation:</p>
<ul>
<li> <em>pw3105@localhost</em> is the identifier of the UPS we want to monitor. <em>pw3105</em> is the same name we have used before in <em>/etc/ups/ups.conf</em> so make sure it matches. <em>@localhost</em> indicates that we&#8217;re monitoring a UPS connected directly to the machine on which <em>upsmon</em> program is running. <em>upsmon</em> can also monitor UPSes connected to other machines on the network.</li>
<li><em>1</em> indicates that this particular UPS feeds 1 power supply on this system. That&#8217;s the usual value for this parameter.</li>
<li><em>server</em> and <em>ups</em> are the user name and password we have defined previously in <em>/etc/ups/upsd.users</em></li>
<li><em>master</em><em> </em>indicates relationship with <em>upsd</em> daemon and again must match what is defined in <em>/etc/ups/upsd.users</em></li>
</ul>
<p>More explanations can be found in man page for <a href="http://linux.die.net/man/5/upsmon.conf" title="upsmon.conf(5) - Linux man page">upsmon.conf</a>.</p>
<p>After these modifications verify the permissions and ownership of the configuration files matches this:</p>
<p><code># ll /etc/ups/ups.conf /etc/ups/upsd.users /etc/ups/upsmon.conf</code><br />
<code>-rw-r----- 1 root nut  3735 Jan 22 00:33 /etc/ups/ups.conf</code><br />
<code>-rw-r----- 1 root nut  2307 Jan 22 00:08 /etc/ups/upsd.users</code><br />
<code>-rw-r----- 1 root nut 11194 Jan 22 00:09 /etc/ups/upsmon.conf</code></p>
<p>and then you can start the software:</p>
<p><code># service ups start</code></p>
<p>You should see this output:</p>
<p><code><font color="#000000">Starting UPS driver controller:             [  </font>OK<font color="#000000">  ]</font></code><br />
<code><font color="#000000">Starting upsd:                              [  </font>OK<font color="#000000">  ]</font></code><br />
<code><font color="#000000">Starting UPS monitor (master):              [  </font>OK<font color="#000000">  ]</font></code></p>
<p>And make sure that UPS software will start automatically after system reboots:</p>
<p><code># chkconfig nut on</code></p>
<p>Verify that the UPS is accessible by executing:</p>
<p><code># upsc pw3105@localhost</code></p>
<p>which should print something like this:</p>
<p><code>driver.name: bcmxcp_usb</code><br />
<code>driver.parameter.pollinterval: 2</code><br />
<code>driver.parameter.port: auto</code><br />
<code>driver.parameter.shutdown_delay: 0</code><br />
<code>driver.version: 2.2.0-</code><br />
<code>driver.version.internal: 0.11</code><br />
<code>output.phases: 1</code><br />
<code>ups.alarm:</code><br />
<code>ups.firmware: Cont:00.80 Inve:00.60</code><br />
<code>ups.model: POWERWARE UPS    500VA</code><br />
<code>ups.power.nominal: 500</code><br />
<code>ups.serial:</code><br />
<code>ups.status: OL</code><br />
<code>ups.voltage.nominal: 230</code></p>
<p>The actual values depend on the UPS model.</p>
<p>At this point the system is configured to automatically shut down when the UPS will indicate that the battery is low on power. You should test this scenario on your system to make sure that it will work when you really need it.</p>
<p><strong>Last step:  Configure web access to upsmon</strong></p>
<p>The last step is to configure monitoring of UPS status via a web browser. We have already installed <em>nut-cgi</em> package which contains the necessary CGI scripts. This package includes a file <em>/var/www/nut-cgi-bin/upsstats.cgi</em> which you should copy to <em>/var/www/cgi-bin/</em> directory:</p>
<p><code># cp /var/www/nut-cgi-bin/upsstats.cgi /var/www/cgi-bin/</code></p>
<p>After that modify file /etc/ups/hosts.conf by appending this line:</p>
<p><code>MONITOR pw3105@localhost "Local UPS"</code></p>
<p>As before <em>pw3105@localhost</em> is the name of UPS to monitor. &#8220;Local UPS&#8221; defines the name which will appear in the web page.</p>
<p>Now start your web server if it&#8217;s not running yet and (optionally) configure the firewall to allow access to port 80 from other machines.</p>
<p>You can now check status of the UPS via a web browser by typing the following in the address bar <font color="#000080">http://localhost/cgi-bin/upsstats.cgi</font></p>
<p>Unfortunately if you&#8217;re running with SELinux enabled then you won&#8217;t see much:</p>
<p><a href="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-not-configured.png"></a></p>
<p style="text-align: center"><a href="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-not-configured.png"><img src="http://www.olivetalks.com/wp-content/uploads/2009/02/ups-status-selinux-not-configured-small.jpg" title="UPS status in web browser before installing SELinux policy module" alt="UPS status in web browser before installing SELinux policy module" /></a></p>
<p>The reason for this is a missing SELinux policy module. Because of that you&#8217;ll see errors in <em>/var/log/audit/audit.log</em> and the web page won&#8217;t provide any useful information. How to install the missing SELinux policy module? This will be described in the <a href="/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">follow up post</a> coming soon.</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li><li><a href="http://www.olivetalks.com/2009/06/24/skype-40-for-windows-is-out-pros-and-cons-compared-with-linux-skype-20/" title="Skype 4.0 for Windows is out: Pros and cons (compared with Linux Skype 2.0) ">Skype 4.0 for Windows is out: Pros and cons (compared with Linux Skype 2.0)  (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/17/big-eee/" title="Eee PC 901 &#8211; aka Big Eee">Eee PC 901 &#8211; aka Big Eee (0)</a></li><li><a href="http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/" title="What files did I change?">What files did I change? (2)</a></li><li><a href="http://www.olivetalks.com/2008/06/17/too-much-success-and-popularity/" title="Too much success and popularity?">Too much success and popularity? (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What files did I change?</title>
		<link>http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/</link>
		<comments>http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 16:45:14 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[RPM]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/</guid>
		<description><![CDATA[Sometimes I need to check what files have been modified on my Linux computers. Recently I discovered a new way to do that.]]></description>
			<content:encoded><![CDATA[<p>I run a few Linux PCs at home and at work. Most of them use packages in RPM format (Fedora, RHEL and CentOS). Sometimes I want to know which configuration files have I modified. That is really important when you&#8217;re upgrading to a new OS version and want to keep your custom settings.</p>
<p>What I used to do was to keep a copy of all the relevant files as they were in the previous version and then modify the new installation accordingly. This solution was working for me but I was never sure whether the new configuration was exactly the same and if I hadn&#8217;t missed any settings in one of the configuration files.</p>
<p>A few days ago I found a better way to monitor the configuration files for changes. As long as you install all the software as RPMs (which makes sense anyway since it&#8217;s easier to deploy the same package on multiple machines or deal with reinstallation) you can use the rpm verification capability which is built into the <em>rpm</em> command.</p>
<p>The way this works is quite simple. For example, I want to know if I changed my firewall settings. Since the firewall I&#8217;m using is installed as part of the <em>iptables</em> RPM I need to execute (as root):</p>
<p><code># rpm -V iptables</code></p>
<p>which produces the following output:</p>
<p><code>SM5....T c /etc/sysconfig/iptables-config</code></p>
<p>This means that since the RPM was installed the file <code>/etc/sysconfig/iptables-config</code> has changed. Specifically the output indicates that the following has changed:</p>
<ul>
<li> size of the file (S),</li>
<li>permissions (M),</li>
<li>MD5 checksum (5),</li>
<li>modification time (T).</li>
</ul>
<p>The properties which did not change are:</p>
<ul>
<li>device major/minor numbers (1st dot), if it did change we would see D</li>
<li>path to which a symbolic link points to (2nd dot), if it did change we would see L</li>
<li>user ownership (3rd dot), if it did change we would see U</li>
<li>group ownership (4th dot), if it did change we would see G</li>
</ul>
<p>Now I know that only this file from <em>iptables RPM</em> was modified.</p>
<p>If I want to look for all the changes in <em>/etc</em> folder I would execute:</p>
<p><code># rpm -Va | grep "\/etc\/"</code></p>
<p>which produces quite a long output so I won&#8217;t list it here. Instead of writing<em> </em>&#8220;rpm -V&#8221; one can also use &#8220;rpmverify&#8221;.</p>
<p>RPM verification has a few more uses than just checking for changes you did to your own system. It can also be used to monitor your system for unauthorized changes.</p>
<p><em>This post was written based on information I have found on <a href="http://www.novell.com/coolsolutions/feature/16238.html" title="Cool Solutions: Using RPM Verify to Monitor Changes to System Files">Novell website</a>, <a href="http://rpm.org/max-rpm/s1-rpm-verify-what-to-verify.html" title="Selecting What to Verify, and How">rpm.org</a> and man page for <a href="http://linux.die.net/man/8/rpm" title="rpm(8): RPM Package Manager - Linux man page">rpm</a> command.</em></p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/" title="Xen p2v conversion in seven simple steps">Xen p2v conversion in seven simple steps (1)</a></li><li><a href="http://www.olivetalks.com/2009/06/06/protect-your-laptop-from-overheating/" title="Stop your laptop from succumbing to thermal death">Stop your laptop from succumbing to thermal death (2)</a></li><li><a href="http://www.olivetalks.com/2009/06/05/native-resolution-l22w-7sd/" title="Native resolution with Fujitsu Siemens Scaleoview L22W-7SD">Native resolution with Fujitsu Siemens Scaleoview L22W-7SD (0)</a></li><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/" title="Setting up UPS on CentOS 5.2 with SELinux, part 1">Setting up UPS on CentOS 5.2 with SELinux, part 1 (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xen and CentOS 5.1 on PowerEdge 2950</title>
		<link>http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/</link>
		<comments>http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 06:41:06 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[cruisecontrol]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/</guid>
		<description><![CDATA[I've installed CentOS 5.1 on PowerEdge 2950. The installation includes Xen 3.0.3. The new server is running multiple Xen guests.]]></description>
			<content:encoded><![CDATA[<p>A few months ago I got my hands on a new server at work. It&#8217;s a Dell PowerEdge 2950. I was going to post a link but it seems Dell is having some problems with their website and half of the links I find in Google do not work.</p>
<p>The server has a Quad Core Xeon CPU E5440 and 4 GB of RAM. The storage needs are covered by a MD1000 disk array connected to a Perc5/E controller. The controller supports different RAID configurations: 0, 1, 10 and 50. I&#8217;ve tried most of them plus different combinations of software raid and hardware plus software raid. In the end I&#8217;ve settled on RAID-5 on 3 disks.</p>
<p>As the operating system I&#8217;ve installed <a href="http://www.centos.org/">CentOS 5.1</a> which is basically a free copy of RHEL 5.1. It comes with Xen 3.0.3 and of course I&#8217;ve installed that too. I want to convert the existing servers we have at work to Xen guests and have them running on this new machine. This will let me update OS on all the servers to the same version without bringing the whole office to halt. And once the servers are virtualized it will be much easier to deal with maintenance of the physical servers. Maybe I will even set up some cluster to host all these Xen guests. I didn&#8217;t have time to fully explore this idea but it sounds like it could offer further advantages.</p>
<p>So far I was able to convert one physical server to a virtual one with rather short downtime. I followed the instructions described in my <a href="/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/" title="Xen p2v conversion">Xen p2v</a> post. The virtual server has been running fine for several months already. In terms of performance there are no problems &#8211; it helps that the Xen host has more powerful hardware and this server doesn&#8217;t need much I/O.</p>
<p>Besides this P2V conversion I&#8217;ve also created a Xen guest with Fedora Core 8 to run our CruiseControl server. The previous installation was running on a Fedora Core 5 host. I&#8217;ve used the occasion and upgraded CruiseControl to the latest version. Installing CruiseControl took me a long time. Mostly because I couldn&#8217;t find proper instructions. I&#8217;ve tried few different ones from the <a href="http://cruisecontrol.sourceforge.net/gettingstartedsourcedist.html">CruiseControl</a> website, from <a href="http://www.ibm.com/developerworks/java/library/j-cc/">IBM</a> and some others. Unfortunately I just couldn&#8217;t get it to work. So in the end I&#8217;ve just duplicated the setup we had before. It&#8217;s not perfect but it works and I don&#8217;t want to spend a week on that.</p>
<p>Third Xen guest I&#8217;ve created is a very small installation of CentOS 5.1 running with only 64 MB of RAM. It serves as a license server for some applications we use. I&#8217;ve minimized the amount of the services running to reduce the memory footprint and the virtual machine uses only 41 MB of RAM.</p>
<p>So far all three guests are running nicely together. I&#8217;ll be adding more of them in the future.</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/" title="Xen p2v conversion in seven simple steps">Xen p2v conversion in seven simple steps (1)</a></li><li><a href="http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/" title="USB forwarding on Xen">USB forwarding on Xen (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/19/ups-on-centos-with-selinux-part-1/" title="Setting up UPS on CentOS 5.2 with SELinux, part 1">Setting up UPS on CentOS 5.2 with SELinux, part 1 (0)</a></li><li><a href="http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/" title="What files did I change?">What files did I change? (2)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xen p2v conversion in seven simple steps</title>
		<link>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/</link>
		<comments>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 11:18:20 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[fully virtualized]]></category>
		<category><![CDATA[HVM]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[SCSI]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[Xen guest]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/</guid>
		<description><![CDATA[Easily convert a physical Linux machine to a HVM guest running under Xen. Follow seven simple steps.]]></description>
			<content:encoded><![CDATA[<p>Xen is one of the currently available virtualization technologies. The commercially supported version is now owned by Cytrix while the Open Source community edition is available at<a href="http://xen.org/"> xen.org</a>. In this article I&#8217;ll be referring to the Open Source edition of Xen, version 3.0.3 which is available by default on CentOS 5.1.</p>
<p>I&#8217;ve recently performed two conversions of physical hosts to Xen guests running on CentOS 5.1 host. The physical hosts were running RHEL 3.7 and CentOS 4.6. It is important to know that after the conversion you end up with a fully virtualized guest &#8211; HVM. This has its effect on the performance, especially when it comes to I/O. It is a general limitation of fully virtualized Xen guests and not of this particular P2V method. I don&#8217;t recommend using it for virtualizing for example a file server. In such a case your only real choice is to create a new paravirtualized guest and migrate the services. This article won&#8217;t be describing that approach.</p>
<p>These instructions are based on the <a href="http://www.linuxjournal.com/article/9942">article</a> by Kyle Rankin. I&#8217;ve adapted it for Xen and added comments on those things which did cause me trouble. The instructions have been used to virtualize RHEL and CentOS servers to run as Xen guests on CentOS 5.1 but you should be able to use most of them for other distributions.</p>
<p><strong>First step</strong> in the conversion is to create LVM volume(s) in the Xen host to be used by the guest. To figure out how much space you need,   have a look at the physical server you want to virtualize. Each LVM volume will be visible in the guest as a separate hard disk. Note that HVM guests support only up to four disks. You will partition the disks from inside the guest in step two.</p>
<p><strong>Second step</strong> is to create a new HVM guest and boot it from a bootable rescue CD/DVD. You should use a rescue CD which matches the architecture of the physical host being virtualized. In step four you need to run <code>chroot</code> command on the guest and it won&#8217;t work if you try for example a 32 bit rescue CD on a 64 bit system. After you have already booted the guest from a rescue CD you need to create partitions to match the physical host. The easiest thing is to match exactly the number and sizes of partitions on the physical system. You can also put several file systems which were on separate partitions on the physical server on a single partition on the guest as long as you prepare enough space.</p>
<p><strong>Third step</strong> is to copy files from the physical server to the guest. This can take some time, so depending on whether you want to minimize the downtime you can do it either in one step or in two. Both methods use <code>rsync</code> command.  The second method is described by Kyle in his <a href="http://www.linuxjournal.com/article/9942">article</a>. The first method is basically the same but you only do the final synchronization. If you use a single transfer method you don&#8217;t need to use the <code>--delete</code> parameter for the final (and in this case the only) synchronization. The single transfer method is faster but it might not be available for you if you need to minimize the downtime.</p>
<p><strong>Fourth step</strong> is to adjust the boot settings in the guest. Without that the guest won&#8217;t boot. To do that make sure all the guest file systems are mounted and <code>chroot</code> into the guest root file system. From there you need to adjust the boot loader configuration. I use GRUB on my systems. For instructions on adjusting LILO you&#8217;ll have to look elsewhere.</p>
<p>First you need to change the file <code>/boot/grub/device.map</code>. If you see <code>/dev/sda</code> there you need to replace it with <code>/dev/hda</code>. This should represent your boot drive. Also verify that the guest boot partition is in <code>/etc/mtab</code>. After that you execute <code>grub-install /dev/hda</code>.</p>
<p>Another file which needs modifications is <code>/etc/grub.conf</code>. Pay attention to the lines starting with <code>boot=</code> and <code>splashimage=</code> as they probably need adjusting. The boot parameters need to be updated as appropriate. The important entries are <code>root (hd0,0)</code> and <code>root=</code> kernel parameter. Note that the first one selects the boot partition while the second selects the partition for the root file system. So for example if the boot partition is in <code>/dev/hda3</code> and root partition is <code>/dev/hda1</code> these entries should look <code>root (hd0,2)</code> (here the partitions are counted starting from zero) and <code>root=/dev/hda1</code> (here they are counted from one).</p>
<p><strong>Fifth step</strong> is to generate a new initrd file for the guest. First copy the existing initrd file somewhere in case you need it later. Then adjust the <code>/etc/modules.conf</code> or <code>/etc/modprobe.conf file</code> (only one will be present depending on the distribution and OS version). Remove all entries starting with <code>alias scsi_hostadapter</code>. After that you can run <code>mkinitrd</code> command. I recommend you use <code>-v</code> parameter for <code>mkinitrd</code>. This will list all the modules which will be included in the initrd. You will probably need at least libata and ata_piix &#8211; even if the physical server uses SCSI disks the HVM guest will use IDE. This depends on the OS of the physical machine you&#8217;re virtualizing because it was only important when I was converting the RHEL 3.7 server but not with CentOS 4.6. If they&#8217;re missing you can add them using <code>--with=</code> parameter. Another advice in case you need to verify the content of initrd file (probably because the guest doesn&#8217;t boot): take into account that older versions of <code>mkinitrd</code> produce just a gzipped ext2 filesystem while the newer ones create a gzipped cpio archive.</p>
<p><strong>Sixth step</strong> is to adjust the network settings and mount points for the guest. The configuration files you need to edit to change network settings are in <code>/etc/sysconfig/network-scripts</code>. Most likely you will have at least <code>ifcfg-eth0</code>. RHEL and CentOS usually specify the MAC address of the network adapter there so you need to change it to match with the MAC address of your guest. Otherwise when the guest boots the interface might not get activated. If you want to change the IP address of the guest you can also do it although I&#8217;d recommend to leave it for later when you already know the guest works. For the initial boot it should be easier if the guest runs with the same IP address as was used before by the physical server.</p>
<p>You also need to edit file <code>/etc/fstab</code> to match with the partition scheme defined for the guest.</p>
<p><strong>Seventh step</strong> is to boot the HVM guest which will be now able to replace the physical server. In order to avoid conflicts you should either power down the physical server, disconnect it from the network or change its IP address(es). After that you can reboot the Xen guest. If you followed the instructions and if the initrd file contains all required modules the system should boot and start all the configured services. If you&#8217;re using <code>kudzu</code> it will ask you a few questions about removed/added hardware. Kyle suggests to select &#8220;Keep Configuration&#8221; for any removed SCSI or network hardware, and select &#8220;Ignore&#8221; for any added SCSI or network hardware. If you are prompted about any removed video, sound, USB and similar hardware you can safely select &#8220;Remove Configuration&#8221;. When booting finishes verify that all required service are running and that you have network connectivity from within the guest.</p>
<p>That&#8217;s it. You should have now a fully virtualized guest running on the Xen host which has the same configuration as the physical server it replaces. It would be a good idea to perform this process first on a test physical server so you have more time to figure out solutions to any problems you may encounter.</p>
<hr align="left" width="20%" /> <a href="/category/computers/feed" title="rss feed to post"><img src="/wp-content/uploads/2008/01/feed-icon-14x14.png" alt="rss feed to post" /></a> Subscribe to the Computers posts of olivetalks, if you found this article interesting, thank you!</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/" title="Xen and CentOS 5.1 on PowerEdge 2950">Xen and CentOS 5.1 on PowerEdge 2950 (2)</a></li><li><a href="http://www.olivetalks.com/2008/02/03/usb-forwarding-on-xen-it-just-does-not-work/" title="USB forwarding on Xen &#8211; it just does not work">USB forwarding on Xen &#8211; it just does not work (6)</a></li><li><a href="http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/" title="USB forwarding on Xen">USB forwarding on Xen (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/" title="What files did I change?">What files did I change? (2)</a></li><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>USB forwarding on Xen</title>
		<link>http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/</link>
		<comments>http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 22:00:11 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[pci passthrough]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[USB export]]></category>
		<category><![CDATA[usb passthrough]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[Xen guest]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/</guid>
		<description><![CDATA[Xen can forward USB ports to guest by PCI forwarding the whole controller. Learn how to do it.]]></description>
			<content:encoded><![CDATA[<p>Recently I was setting up a Xen guest which needed access to a USB port on a CentOS 5.1 host. I searched the Internet for instructions on how to use <strong>USB forwarding</strong> or <strong>USB pass-through</strong>  but I was not able to find anything which would work on the Xen 3.0.3 I&#8217;m using. I decided to set up <strong>PCI pass-through</strong> instead.</p>
<p>To set it up, I followed instructions written by Jón Fairbairn at <a href="http://wiki.xensource.com/xenwiki/Assign_hardware_to_DomU_with_PCIBack_as_module">xensource.com</a>. The <em>pciback</em> module in the CentOS 5.1 kernel doesn&#8217;t support the <em>hide</em> parameter so I left that out from my setup. It doesn&#8217;t seem to be necessary, anyway, for the driver for the USB controller in the host can be unbound from the PCI slot used by the controller.</p>
<p>To make sure the PCI slot is exported to Xen guests when the host system boots I created a <em>xenpciexport</em> script and placed it in the <em>/etc/init.d/</em> directory. You can download the code from here <a href="http://www.olivetalks.com/wp-content/uploads/2008/01/xenpciexport.txt" title="xenpciexport.txt">xenpciexport.txt</a></p>
<p>The script <em>xenpciexport</em> is set up to start before <em>xend</em> and <em>xendomains</em> to make sure the PCI forwarding is working before any guest is running. It stops after <em>xend</em> and <em>xendomains</em>. That&#8217;s controlled by the line:</p>
<p><code># chkconfig: 2345 97 02</code></p>
<p>you can see in the script header.</p>
<p>After copying the file to <em>/etc/init.d</em> you need to run</p>
<p><code>chkconfig --add xenpciexport</code></p>
<p>to create the appropriate links in the <em>/etc/rc*.d/</em> directories.</p>
<p>To find out the slot number for the USB controller use <em>lspci</em> and <em>lsusb</em> commands. If the script is set up correctly you can plug in the USB device and run</p>
<p><code>service xenpciexport stop</code></p>
<p>After that the results of <em>lsusb</em> should include the USB device you want to export. Then run</p>
<p><code>service xenpciexport start</code></p>
<p>and now <em>lsusb</em> won&#8217;t show this device anymore &#8211; it&#8217;s hidden from the host and visible to Xen guests.</p>
<p>Before you start the Xen guest which is supposed to have access to the exported device add this line to its configuration file:</p>
<p><code>pci = [ '0000:00:1d.1' ]</code></p>
<p>The number in quotes must be the same as the <em>SLOT</em> variable in the <em>xenpciexport</em> script.</p>
<p>After that you need to patch your Xen installation. The version installed in CentOS 5.1 contains a bug which makes it impossible to use PCI pass-through. The fix can be found at <a href="http://bugs.centos.org/view.php?id=2485">CentOS Bug Tracker</a>. Make sure you also fix the file <em>pciif.py</em> as specified in the note. In total there are three files which need to be edited: <em>iopif.py</em>, <em>irqif.py</em> and <em>pciif.py</em>.</p>
<p>Now you can finally start the Xen guest. When it finishes booting log into it and run <em>lsusb</em> there to confirm that the device is visible to the guest. <em>lspci</em> in the guest should also show you the USB controller. It is important to run the <em>xenpciexport</em> script before you start your guest, otherwise the USB device will not be visible to the guest OS.</p>
<p>The Xen guest has now full access to the USB device.</p>
<p>Here you can read more about <a href="http://www.wlug.org.nz/XenPciPassthrough" title="XenPciPassthrough">PCI passthrough on Xen</a>.</p>
<p><em><strong>Update:</strong></em><br />
It turns out that this setup was causing the Xen guest to crash. You can read more in a <a href="/2008/02/03/usb-forwarding-on-xen-it-just-does-not-work/">new post</a>.</p>
<hr align="left" width="20%" /> <a href="/category/computers/feed" title="rss feed to post"><img src="/wp-content/uploads/2008/01/feed-icon-14x14.png" alt="rss feed to post" /></a> Subscribe to the Computers posts of olivetalks, if you found this article interesting, thank you!</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2008/02/03/usb-forwarding-on-xen-it-just-does-not-work/" title="USB forwarding on Xen &#8211; it just does not work">USB forwarding on Xen &#8211; it just does not work (6)</a></li><li><a href="http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/" title="Xen p2v conversion in seven simple steps">Xen p2v conversion in seven simple steps (1)</a></li><li><a href="http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/" title="Xen and CentOS 5.1 on PowerEdge 2950">Xen and CentOS 5.1 on PowerEdge 2950 (2)</a></li><li><a href="http://www.olivetalks.com/2008/03/22/usb-in-xen-how-to-make-it-work/" title="USB in Xen &#8211; how to make it work">USB in Xen &#8211; how to make it work (0)</a></li><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

