<?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>That Chris Brown's Blog &#187; linux</title>
	<atom:link href="http://www.thatchrisbrown.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thatchrisbrown.com</link>
	<description>Another Chris Brown &#38; another blog</description>
	<lastBuildDate>Sat, 03 Apr 2010 13:05:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Making squid work under selinux with non-default settings</title>
		<link>http://www.thatchrisbrown.com/2010/making-squid-work-under-selinux-with-non-default-settings/</link>
		<comments>http://www.thatchrisbrown.com/2010/making-squid-work-under-selinux-with-non-default-settings/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 13:05:09 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=143</guid>
		<description><![CDATA[I've been wrestling with squid today, and although I have inky stains on my body and soul, I've made some headway.  I've been trying to be a good sysadmin and not just disable selinux, or set it to permissive and forget it, at the first sign of trouble.  Thing is, I wanted a non-default squid configuration, and selinux got in the way.  I had two problems that I had to solve - non standard listen ports, and non-standard cache location.  This is how I fixed those [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2010%2Fmaking-squid-work-under-selinux-with-non-default-settings%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2010%2Fmaking-squid-work-under-selinux-with-non-default-settings%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been wrestling with squid today, and although I have inky stains on my body and soul, I&#8217;ve made some headway.  I&#8217;ve been trying to be a good sysadmin and not just disable selinux, or set it to permissive and forget it, at the first sign of trouble.  Thing is, I wanted a non-default squid configuration, and selinux got in the way.  I had two problems that I had to solve &#8211; non standard listen ports, and non-standard cache location.<br />
<span id="more-143"></span></p>
<p>I installed squid with the usual <code><strong>yum install squid</strong></code> command on my CentOS 5.4 server.  I want to be able to use a single squid instance to support both configured browsers (on the basis that it&#8217;s better if browsers know they are being proxied) and transparent (sometimes called &#8220;intercept&#8221;) proxying for applications with their own http access libraries, and guest machines on my network that may not want to configure my proxy settings, or don&#8217;t respect autoconfigure via DHCP.  So, after using webmin to set up a few basics, I jumped into the <code>/etc/squid/squid.conf</code> file and set up the following:<br />
<code># Listen on internal address for VLAN 2<br />
http_port 10.254.225.65:3128<br />
http_port 10.254.225.65:3129 transparent</p>
<p># Listen on internal address for VLAN 3<br />
http_port 10.254.225.129:3128<br />
http_port 10.254.225.129:3129 transparent</code></p>
<p>I then used Webmin to create a new logical volume on my RAID array, a nice healthy 64GB.  Big for a cache, but I want to try and cache installers and downloaded updates, so I want plenty of space.  I created the logical volume, mounted it on /webcache and jumped back into squid config in Webmin and added a cache location /webcache of 5000MB, 16 1st-level folders and 256 2nd-level folders.</p>
<p>Squid failed to start.  OK, I thought, I&#8217;ll initialise the cache with squid -z.  That ran fine as root.  Squid still wouldn&#8217;t start.  A check of the log files showed that squid was complaining &#8220;<em>cache_dir /webcache: (13) Permission denied</em>&#8220;.  Of course, I hadn&#8217;t set permissions on /webcache, so a quick <code><strong>chown -R squid:squid /webcache</strong></code> and I thought I was done.  I was not &#8211; squid still wouldn&#8217;t start.</p>
<p>I realised selinux might be the culprit and checked this by running <code><strong>setenforce Permissive</strong></code> and lo and behold, squid started.  A review of <code>/var/log/audit/audit.log</code> suggested that there were two problems &#8211; the non-standard port 3129 and the non-standard cache location.</p>
<p>The port issue was relatively easy to fix.  <code><strong>semanage port -l | grep "cache"</strong></code> to list any selinux information about ports that cache processes are allowed to use suggested the following:<br />
<code>http_cache_port_t              tcp      3128, 8080, 8118, 11211, 10001-10010<br />
http_cache_port_t              udp      3130, 11211</code></p>
<p>So, I needed to add port 3129 to the list.  A quick Google found a note about adding non-standard Apache ports, and from that is was easy to work out that the magic line would be <code><strong>semanage port -a -t http_cache_port_t -p tcp 3129</strong></code> which adds port 3129 to the list of allowed ports for http caches.  I didn&#8217;t expect this to get squid running, but at least the next failure gave me a smaller set of audit log entries to work on!</p>
<p>Next, I needed to fix the file contexts for /webcache.  This was a little more complex, being a novice to selinux.  I discovered that I could view existing context with <code><strong>ls -Z</strong></code> so at least I could assess my efforts.  I also found that it&#8217;s possible to change the file context with <strong>chcon</strong>, but this may not survive reboots, a <strong>restorecon</strong> (restore contexts) command or a &#8220;relabel&#8221; of the filesystem.  I needed a way to make sure that selinux knew that /webcache was meant to be used for squid, so I disn&#8217;t have to keep telling it.</p>
<p>After some poking around, and trying a few things out to no avail, I found that I needed to use a command <code><strong>grep -hi "squid" /etc/selinux/targeted/contexts/files/file_contexts*</strong></code> which showed me where the selinux policy knew about allowable locations for squid to keep files, as follows:<br />
<code>/etc/squid(/.*)?        system_u:object_r:squid_conf_t:s0<br />
/var/log/squid(/.*)?    system_u:object_r:squid_log_t:s0<br />
/var/squidGuard(/.*)?   system_u:object_r:squid_cache_t:s0<br />
/var/spool/squid(/.*)?  system_u:object_r:squid_cache_t:s0<br />
/usr/share/squid(/.*)?  system_u:object_r:squid_conf_t:s0<br />
/var/cache/squid(/.*)?  system_u:object_r:squid_cache_t:s0<br />
/var/log/squidGuard(/.*)?       system_u:object_r:squid_log_t:s0<br />
/usr/sbin/squid --      system_u:object_r:squid_exec_t:s0<br />
/var/run/squid\.pid     --      system_u:object_r:squid_var_run_t:s0<br />
/usr/lib/squid/cachemgr\.cgi    --      system_u:object_r:httpd_squid_script_exec_t:s0<br />
/usr/lib64/squid/cachemgr\.cgi  --      system_u:object_r:httpd_squid_script_exec_t:s0</code></p>
<p>So, it seems all I needed to do was to add to that list, and all would be good.  There was a small wrinkle to this too though.  <code><strong>semanage fcontext -a -t squid_cache_t /webcache</strong></code> would seem to do the necessary magic, but in fact semanage fcontext doesn&#8217;t work like a regular filesystem tool, so there&#8217;s no recursion.  It didn&#8217;t seem &#8220;clean&#8221; to then iterate through each sub-folder (all 4096 of them!) and set the context.</p>
<p>The answer was actually simple.  Delete the cache folders with <code><strong>rm -rf /webcache/0*</strong></code> and <code><strong>rm -rf /webcache/swap*</strong></code> and then set the required context on /webcache in the policy with <code><strong>semanage fcontext -a -t squid_cache_t /webcache</strong></code> and finally make this the current context with <code><strong>restorecon -R /webcache</strong></code>.  Then, with context set in the parent folder, running <code><strong>squid -z</strong></code> meant that the 4096 cache directories were also created with the right context.</p>
<p>I re-enabled Enforcing mode, squid started and my selinux policy is aware of my non-standard configuration, so hopefully future updates won&#8217;t break it.  My small concern is that future updates to the selinux policy may overwrite my changes &#8211; I don&#8217;t know how selinux works well enough to know if my policy changes will survive or be overwritten.  At least I&#8217;ve got my own handy guide to how to make it work again if I need it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2010/making-squid-work-under-selinux-with-non-default-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kernel 2.6.18-164.11.1.el5xen on xen.gz-3.4.1 needs dom0_mem</title>
		<link>http://www.thatchrisbrown.com/2010/kernel-2-6-18-164-11-1-el5xen-on-xen-gz-3-4-1-needs-dom0_mem/</link>
		<comments>http://www.thatchrisbrown.com/2010/kernel-2-6-18-164-11-1-el5xen-on-xen-gz-3-4-1-needs-dom0_mem/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:04:55 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtualisation]]></category>
		<category><![CDATA[bond]]></category>
		<category><![CDATA[dom0]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=136</guid>
		<description><![CDATA[
			
				
			
		
<p>My server runs CentOs 5.x, and uses the Gitco repo to provide later versions of Xen.  I&#8217;ve previously sorted out the issues (at least in earlier Xen and CentOS versions) around bridging guest vifs to a bonded interface (I replaced Xen entwork scripts with stock CentOS ones, which needed patching to bring bonds up [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2010%2Fkernel-2-6-18-164-11-1-el5xen-on-xen-gz-3-4-1-needs-dom0_mem%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2010%2Fkernel-2-6-18-164-11-1-el5xen-on-xen-gz-3-4-1-needs-dom0_mem%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>My server runs CentOs 5.x, and uses the Gitco repo to provide later versions of Xen.  I&#8217;ve previously sorted out the issues (at least in earlier Xen and CentOS versions) around bridging guest vifs to a bonded interface (I replaced Xen entwork scripts with stock CentOS ones, which needed patching to bring bonds up before bridges).  Everything&#8217;s been fine with one small caveat &#8211; any time yum updates a kernel, before rebooting, I need to go check grub.conf to make sure that it&#8217;s using the xen version from gitco not the one matching the centOS kernel version.</p>
<p>So, with the Xen kernel 3.4.1 from Gitco, I did a yum update which included kernel 2.6.18-164.11.1.el5xen and somehow forgot to check grub.conf before rebooting.  I waited and waited, but got no response from my server.</p>
<p>Luckily, I have a remote console on my physical server, so I was able to investigate.  I found that the dom0 startup was hanging at &#8220;Bringing up interface bond0&#8243;.  I hit the virtual reset button and dropped into the grub menu.  I edited the kernel line to use xen.gz-3.4.1 and thought that would be it.</p>
<p>No, same problem.  Same thing booting kernel 2.6.18-164.10.1.el5xen as well, either on its matching Xen kernel version, or 3.4.1 from Gitco.  However, I could boot dom0 into 2.6.18-164.9.1.el5xen against Xen kernel 3.4.1, albeit with terribly slow network performance and &#8220;<strong>xen_net: Memory squeeze in netback driver</strong>&#8221; logged regularly in /var/log/messages, and network access to my guests was so slow that nearly everything timed out.</p>
<p>A bit of research on Google suggested that adding &#8220;<strong>dom0_mem=<em><something></em></strong>&#8221; to the kernel line in grub.conf might help.</p>
<p>Sure enough, it did &#8211; it cured the &#8220;memory squeeze&#8221; messages, and it&#8217;s let me boot dom0 into kernel 2.6.18-164.11.1.el5xen on top of Xen kernel 3.4.1 as well.</p>
<p>My guess is that kernels after 2.6.18-164.9.1.el5xen have some change that means without a restriction on dom0 memory, something somewhere breaks, and one of the side effects is terribly slow networking, possibly only when bonded?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2010/kernel-2-6-18-164-11-1-el5xen-on-xen-gz-3-4-1-needs-dom0_mem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen vs KVM &#8211; horses for courses?</title>
		<link>http://www.thatchrisbrown.com/2009/xen-vs-kvm-horses-for-courses/</link>
		<comments>http://www.thatchrisbrown.com/2009/xen-vs-kvm-horses-for-courses/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 12:04:14 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtualisation]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://m.thatchrisbrown.com/?p=133</guid>
		<description><![CDATA[
			
				
			
		
<p>As anyone who&#8217;s read any of my previous posts will know, I&#8217;ve been considering Red Hat&#8217;s adoption of KVM over Xen and wondering if a move to KVM is the right thing to do.</p>
<p>I think &#8220;The right thing&#8221; depends a fair bit on where you are, and what your requirements are.  Obvious? Perhaps, but [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fxen-vs-kvm-horses-for-courses%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fxen-vs-kvm-horses-for-courses%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>As anyone who&#8217;s read any of my previous posts will know, I&#8217;ve been considering Red Hat&#8217;s adoption of KVM over Xen and wondering if a move to KVM is the right thing to do.</p>
<p>I think &#8220;The right thing&#8221; depends a fair bit on where you are, and what your requirements are.  Obvious? Perhaps, but then sometimes it&#8217;s the obvious things we overlook.</p>
<p>I think there&#8217;s no pressing need to migrate my hosted server.  It works pretty well on Xen and now I&#8217;ve sorted out my mess of repo priorities, and I&#8217;m a bit less cavalier with updates, I don&#8217;t expect it to present me any significant problems.</p>
<p>My home server is a different thing.  It&#8217;s not currently commissioned so there&#8217;s no downtime to worry about, I&#8217;d like to be able to run PVM and HVM Windows and Linux guests, including possibly LinuxMCE one day, and carrying most weight for me at present, it&#8217;s going to also be my network gateway.</p>
<p>Now, purists might not think running VM services on my gateway is a smart idea, and I should put in a separate host for each, but it&#8217;s a model I&#8217;d like to try out as I have some work project ideas that might benefit.</p>
<p>My thinking is that if I&#8217;m doing security policy, NAT, bandwidth shaping and VPN on a machine that also runs guests, KVM might make sense &#8211; doing that work in a Xen dom0 would involve a bit more switching of network data in and out of the Hypervisor and guests. In theory, Linux being the hypervisor should mean it&#8217;s only doing that for network traffic to guests, which will only be anything I can&#8217;t sensibly run in the base Linux OS.</p>
<p>There may be some argument that my hosted server may benefit too, as in a bonded setup, the current state of Xen networking seems to suggest that the dom0 has to do all the work anyway &#8211; I have my dom0 using regular Linux networking (patched to fix an issue bridging a bonded interface) to get my guests on a bridge to a fully bonded interface.</p>
<p>KVM will be an interesting experience to compare with Xen. If the networking is faster, as long as performance of guests is good, it may make sense to choose it ultimately because Red Hat have, and out-of-the-box compatability is no bad thing.</p>
<p>For now, I&#8217;m happy to keep my hosted workhorse on Xen and try the new contender out on a home server first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2009/xen-vs-kvm-horses-for-courses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating BIOS on an Intel board without Windows</title>
		<link>http://www.thatchrisbrown.com/2009/updating-bios-on-an-intel-board-without-windows/</link>
		<comments>http://www.thatchrisbrown.com/2009/updating-bios-on-an-intel-board-without-windows/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:12:08 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=124</guid>
		<description><![CDATA[I have swapped out a Q8200 processor for a Q8400 processor in my home server, so I can play with KVM.  This means a BIOS update to give me the enable/disable option for Intel Virtualization [sic] Technology.  Now I've updated many a BIOS in my time, so it didn't even occur to me that it might be anything other than trivial.  How wrong I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fupdating-bios-on-an-intel-board-without-windows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fupdating-bios-on-an-intel-board-without-windows%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I have swapped out a Q8200 processor for a Q8400 processor in my home server, so I can play with <a href="http://www.linux-kvm.org/" target="_blank">KVM</a>.  This means a BIOS update to give me the enable/disable option for Intel Virtualization <em>[sic]</em> Technology.  Now I&#8217;ve updated many a BIOS in my time, so it didn&#8217;t even occur to me that it might be anything other than trivial.</p>
<p>I hopped on Intel&#8217;s site and went to the downloads for the board.  Windows executable, raw BIOS file for a BIOS recovery function my board doesn&#8217;t even have or &#8220;OEM kit&#8221; with the BIOS file and a DOS flash utility.  Here&#8217;s where the fun starts.  The machine doesn&#8217;t have a floppy drive and didn&#8217;t (until today) have a CD/DVD drive either.  I have previously booted this machine from a &#8216;live&#8217; CentOS 5 USB <a href="http://www.thatchrisbrown.com/2009/usb-centos-to-the-rescue/" target="_blank">stick</a>.</p>
<p>So, I installed an IDE CD/DVD writer while I was in the case swapping CPUs.  This shoudl make it really easy, right?  Wrong.</p>
<p>First, I used CD Burner XP and a downloaded FreeDOS image to make a bootable CD with an emulated 2.88MB A: floppy and the flash imaging tool on C:, which would be the CD-ROM.  This didn&#8217;t even boot FreeDOS, it just did nothing.</p>
<p>Next I tried my CentOS USB stick, and hacked the syslinux boot menu to add a new FreeDOS item, using memdisk as kernel and a 1.44MB FreeDOS image as the initrd.  This gave me a working FreeDOS environment with C: on the USB stick.  Great!  So, I added the Intel flash tools and booted it up.  The Intel flash tool loaded, let me pick the BIOS image and then promptly told me the update had failed.  Trying to run the flash utility a second time hung the box.</p>
<p>Back to CD, this time with a CD-RW so I&#8217;m not making coasters.  I used InfraRecorder to make a bootable CD with the FreeDOS image that booted fine fron syslinux.  I added the flash utility and burnt the CD.  This started to boot FreeDOS but then threw an &#8220;Invalid Opcode&#8221; error and hung.</p>
<p>I thought I&#8217;d try a &#8216;real&#8217; MS-DOS 6.22 and found one on  bootdisk.com, which turned out to be a Windows executable that requires a floppy disk.</p>
<p>I found the <a href="http://www.coreboot.org/Flashrom" target="_blank">flashrom</a> project, which looks great, but no record of my board on the site, and this is just flashing a BIOS &#8211; surely it can be done simply?</p>
<p>Well, it can, sort of.  I went back to my trusty USB CentOS and downloaded the FreeDOS diskette image that had worked previously.  I mounted it up on a loopback and removed anything not needed to boot FreeDOS to make space for the Intel utility and BIOS file, which I then copied in.  I unmounted the floppy image, used mkisofs to make a bootable .iso image and used cdrecord to blank my CD-RW and burn the image to it.</p>
<p>Success!  A bootable FreeDOS CD, and a working flash utility!  All it took was buying a CD/DVD drive, having available a USB stick, a CentOS Live CD image, the Fedora Live USB creator, a FreeDOS image, the Intel FLASH files and several hours trying various combinations until one worked.</p>
<p>Intel used to also supply .iso file downloads once upon a time, so you could just download, burn and boot.  What happened to that?</p>
<p>Intel people &#8211; if you&#8217;re going to only provide a &#8216;bare&#8217; DOS flasher and a Windows application, and make life more difficult for non-Windows or DOS users, can I ask that you please, please give a little bit of software engineering time to help the flashrom team get more Intel flash updates supported, to make your boards more attractive to Linux users.  <strong><em>Please?</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2009/updating-bios-on-an-intel-board-without-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB CentOS to the rescue!</title>
		<link>http://www.thatchrisbrown.com/2009/usb-centos-to-the-rescue/</link>
		<comments>http://www.thatchrisbrown.com/2009/usb-centos-to-the-rescue/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 22:44:07 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=115</guid>
		<description><![CDATA[I stupidly broke a host and managed to recover it with CentOS Live CD running from a USB stick, which was refreshingly easy to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fusb-centos-to-the-rescue%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fusb-centos-to-the-rescue%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>OK, OK &#8211; I was stupid.</p>
<p>As part of my ongoing move from Xen to KVM for VM hosting, I fireed up a server that had been sitting about too long switched off under the desk, thinkig that it would make an ideal machine to try KVM out on.  A <strong>yum groupremove Virtualization</strong> seemed to produce no issues, so I was looking good to go with a bit fo repo cleanup and then an update before upgrading from CentOS 5.2 to 5.3 with yum.  Then I did something stupid.</p>
<p>I renamed the logical volume that / is mounted from, becuase I thought the name wasn&#8217;t descriptive enough.  Then I rebooted the box.  Oh yes.</p>
<p>Cue a kernel panic when grub couldn&#8217;t find the root partition.  Oh Chris, how SMRT!  The physical box doesn&#8217;t have a CD/DVD drive (it&#8217;s meant to be a headless box) but luckily it does have USB ports, and I had a spare screen and keyboard about, and I happeend to have a 4GB USB thumb drive in my laptop bag.  A quick Google search turned up Pendrivelinux.com and a handy <a href="http://www.pendrivelinux.com/usb-centos-5-live-install-via-windows/" target="_blank">guide</a> to getting CentOS 5 working on USB.  I already had a CentOS 5.2 Live CD image on my hard drive, so a quick upload of the thumb drive contents, a quick download of the <a href="https://fedorahosted.org/liveusb-creator/" target="_blank">Fedora LiveUSB Creator</a> and I was in business!</p>
<p>It was a pretty simple recovery.  I had to unmount and remount the LVs becuase CentOS Live CD mounted them read-only, but that was easy enough &#8211; the device mapper nodes were all there and sensibly named too, so it was pretty intuitive.  The I just had to edit the LV names in /boot/grub/grub.conf, /etc/fstab and /etc/mtab.  For good measure I removed the duplicate entry in /etc/blkid/blkid.tab too.</p>
<p>Reboot, pull out the USB drive at the BIOS screen and a few moment later, there was my host back in the land of the serving. Phew!</p>
<p>A lucky escape this time, but it shows the risk of unintended consequences.  The sooner I get KVM sorted out, and all the real work done in VM guests in LVs, the better, because at least then I&#8217;ll be able to make a snapshot before I try anything like a sysadmin task!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2009/usb-centos-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LVM saves the day, possibly&#8230;</title>
		<link>http://www.thatchrisbrown.com/2009/lvm-saves-the-day-possibly/</link>
		<comments>http://www.thatchrisbrown.com/2009/lvm-saves-the-day-possibly/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 18:53:42 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtualisation]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=112</guid>
		<description><![CDATA[Using LVM for Xen guests virtual disks might have made KVM migration easier than I first [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Flvm-saves-the-day-possibly%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Flvm-saves-the-day-possibly%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>OK, so I&#8217;m mulling the move from <a href="http://www.thatchrisbrown.com/2009/in-theory-migrating-from-xen-to-kvm-under-centos-5-3/" target="_blank">Xen to KVM</a>.  This initially looked like I&#8217;d have to make duplicate virtual disks in KVM for my Xen guests, then shut the guests down, block copy content across and patch up MBR and boot my physical box into a stock kernel and hope KVM comes up with the goods.</p>
<p>Well, a little bit of experimentation with a rarely-used VM and I&#8217;ve found much to my joy that because I used LVM logical volumes to create my Xen guests virtual disks, I can use kpartx to add device mapping for them and (when the guest is safely shut down!) mount them up in my dom0 and read/write to them.  Thi sis good news because it means they have a full virtual disk setup, with a /boot partition, a root partition and a swap partition all living in a single logical volume.  This means KVM should pick them straight up and work with them unmodified.</p>
<p>Which hopefully means all I have to do is set a stock kernel to be the boot default in my guests, shut them down, set my dom0 to boot from a stock kernel, load up the KVM kernel module and add some guests from the logical volumes.</p>
<p>If it&#8217;s that easy, I&#8217;ll be a happy person indeed!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2009/lvm-saves-the-day-possibly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In theory &#8211; migrating from Xen to KVM under CentOS 5.3</title>
		<link>http://www.thatchrisbrown.com/2009/in-theory-migrating-from-xen-to-kvm-under-centos-5-3/</link>
		<comments>http://www.thatchrisbrown.com/2009/in-theory-migrating-from-xen-to-kvm-under-centos-5-3/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 14:56:59 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtualisation]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.thatchrisbrown.com/?p=107</guid>
		<description><![CDATA[I'm advance planning my migration of live services from Xen VMs to KVM VMs on the same physical box, with as little downtime as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fin-theory-migrating-from-xen-to-kvm-under-centos-5-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thatchrisbrown.com%2F2009%2Fin-theory-migrating-from-xen-to-kvm-under-centos-5-3%2F&amp;source=thatchrisbrown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I have a CentOS 5.3 (actually a CentOS 5.2 build upgraded in yum, but that&#8217;s not terribly important) x86_64 machine that is in fact a Xen hypervisor kernel with said CentOS 5.3 running as the dom0 (service VM), and currently four guest VMs also running CentOS 5.2 x86_64, upgraded to CentOS 5.3 with yum.  This was a kind of interesting project in itself, in that I used the Gitco repos in order to get Xen 3.3.1 on the CentOS build, and I had to do some hackery of the Xen and stock CentOS networking scripts to make things work.  The box doesn&#8217;t use Xen network scripts and xenbr0, because they broke pretty badly with bonded dual NICs.  It has a fairly standard Ethernet bond setup going, then a patched RH network script so bridges don&#8217;t init before the bond, a standard Linux bridge br0, which all my Xen vifs attach to, and a virbr0 which doesn&#8217;t have any physical NICs attached, but does have an IP address and dhcpd running against it, so I have a place to quickly fire up new VM guests without having to assign network addresses.</p>
<p>This complexity lead to a few problems, partly during installation, when I ended up temporarily having to go wiht a non-Xen kernel in order to update bits and ipeces and set up repos so I could go back to a Xen kernel, and when yum wanted to update to kernel-xen-2.6.18-128.1.10.el5 and like a trusting fool I let it, and promptly had no running VMs on the next reboot.  Hacking grub back to 2.6.18-128.1.6.el5xen seemed to sort it, and it never got changed from there.</p>
<p>Actually, to tell the trust, I also have another machine built a similar way, <em>sans</em> CentOS 5.3 upgrade.  This one was meant to potentially be a home to a windows machine, or most likely a Linux MCE installation running in  a non-PV guest.  That one didn&#8217;t get installed yet, and has been sitting under my desk for many a month, waiting for cabling.  Oops.</p>
<p>My guest DomUs are living in Xen virtual disks which are inside LVM logical volumes as far as the dom0 is concerned.  If I&#8217;d been smarter, I might have set up three LVs for each domU &#8211; one for /boot, one swap and one for /, so that I cold more easily manage them from not only the guest domU, but also the dom0 if the domU was offline for any reason.</p>
<p>The increased exposure KVM is getting in RHEL 5.4 is making me wonder if all this Xen tinkering is worth it.  My machine only runs Linux guests, and then only really for a bit of process separation security.  Given that the dom0 has to do a bit of service work for guest domUs anyway, and it seems that this involves a bit of context switching overhead, I don&#8217;t see that doing the hypervisor function in the kernel is going to be a problem for me, especially on that currently unused box, which is going to be a home all-in-one media, file/print, NATting, caching and bandwidth arbitrating machine.  As I was going to just accept doing all the networking for that (including the firewall/NAT/bandwidth and some VPN stuff) in the dom0 instead of making the Xen networking even more complicated with dual virtual NICs and a virtual firewall box, I guess just making all that work in plain old Linux and then loading up a kernel module when I want a media centre guest VM (yes, I know I could just be less lazy and make all the bits of Linux MCE work under CentOS natively, but starting a VM and installing an OS-up image for LMCE seems like a good thing) installing makes a bit of sense.</p>
<p>The currently unused machine isn&#8217;t so bad &#8211; as it currently has no VMs and didn&#8217;t get the 5.2/5.3/Gitco hybrid horror treatment, I could just strip Gitco repo, group uninstall Virtualisation (sorry Virtuali<strong>z</strong>ation), and boot it as a regular Linux kernel, do the networkingy bits (and make better use of my rather rubbish 1.5Mb/s of patchy ADSL) and then worry about that media server when the time is right.  The dual-NIC networkign will be far easier &#8211; one outside one inside, attach a separate bridge to each and I could then attach VMs to the &#8220;public&#8221; or &#8220;private&#8221; bridges and the host OS will iptables them like any other hosts.  Great!</p>
<p>It&#8217;s that first server that is going to be &#8216;interesting&#8217;.  Fedora&#8217;s virt-v2v is a ways off yet, so I&#8217;ve got to think of smart ways of moving painlessly from Xen to KVM without losing services for long.  The current outline plan goes something like:</p>
<ol>
<li>Install a plain old Linux kernel into each VM guest</li>
<li>Install a plain old Linux kernel into the current dom0</li>
<li>Make new LVM logical volumes for guest VMs &#8211; <em>possibly three each for /boot, swap and /</em></li>
<li>Modify guest VM grub config to default the plain old Linux kernel</li>
<li>Shutdown guest VMs</li>
<li>Reboot dom0 as a plain old Linux kernel, albeit with KVM support loaded</li>
<li>Make any networking changes required</li>
<li>Create new KVM virtual machine images in the logival volumes</li>
<li>Stop the new KVM guests</li>
<li>Mount guests Xen virtual &#8216;disks&#8217; (actually just some partitions I think, not full bootable disk images) on loopback in the dom0</li>
<li>dd the contents of the Xen partitions into the new LVM logical volumes, overwriting the guest images created at step 7</li>
<li>Start the KVM guests</li>
<li>Panic when it goes wrong (had to be step 13, didn&#8217;t it?)</li>
</ol>
<p>I&#8217;m hoping that the fact I already do the networking outside of Xen, and just use standard Linux bridging on and the libvirt virbr0, will mean a slightly easier migration &#8211; all I have to do is get my instances booting off a standard kernel instead of a Xenified one, and inside a different virtual disk format.</p>
<p>I&#8217;ll still need my standard-breaking networking patch to enable bonds before bridges though.  Hopefully RH fix that one in RHEL 5.4 so CentOS picks it up in the next release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thatchrisbrown.com/2009/in-theory-migrating-from-xen-to-kvm-under-centos-5-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
