<?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>KernelCrash &#187; linux</title>
	<atom:link href="http://www.kernelcrash.com/blog/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kernelcrash.com/blog</link>
	<description>the difference that is no difference makes no difference</description>
	<lastBuildDate>Mon, 03 May 2010 04:59:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>kvm</title>
		<link>http://www.kernelcrash.com/blog/kvm/2009/05/16/</link>
		<comments>http://www.kernelcrash.com/blog/kvm/2009/05/16/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:08:08 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=246</guid>
		<description><![CDATA[KVM in this case is the linux  &#8216;Kernel-based Virtual Machine&#8217;, not Keyboard/Video/Mouse. I&#8217;ve always been puzzled why you would name the new whiz bang virtualization technology for linux the same as a rather mundane piece of equipment found in most data centres.
So I&#8217;ve been a big virtual machine user for many years. Mainly using the [...]]]></description>
			<content:encoded><![CDATA[<p>KVM in this case is the linux  &#8216;Kernel-based Virtual Machine&#8217;, not Keyboard/Video/Mouse. I&#8217;ve always been puzzled why you would name the new whiz bang virtualization technology for linux the same as a rather mundane piece of equipment found in most data centres.</p>
<p>So I&#8217;ve been a big virtual machine user for many years. Mainly using the desktop products like Vmware Workstation (and Fusion on the Mac) and I&#8217;ve tried Virtualbox a few times. I tried VMware Server a few times but was never happy with its performance on linux. But, Vmware ESX is always quite impressive. Being so low level it obviously has quite a few extra &#8217;smarts&#8217; over the desktop and &#8216;on top of a regular OS&#8217; type VM products. It is incredibly popular in data centers, and has the key benefit of &#8216;being around for years&#8217;, and has consequently been refined and refined.</p>
<p>So that brings me to KVM. In theory it should be the linux world alternative to ESX. Sure Xen kind of does the same thing, but KVM is very integrated into the kernel supposedly, whereas Xen has its own microkernel or somesuch. Of course, when KVM first came out, I tried it and it didn&#8217;t seem to work very well, so I forgot about it until now. Lately, I&#8217;ve been looking at other distros and have been playing quite a bit with Ubuntu 9.04. Usually I would hate something like Ubuntu due to the volume of updates you typically get, but I was interested in ext4 performance and I had also read that KVM was reasonably integrated into it, so it seemed like an easier way to try those things out.</p>
<p>So I installed Ubuntu 9.04 (the 32 bit version initially) on my 2Gb ram core2duo on top of ext4 and read this <a href="http://www.adoleo.com/blog/2009/apr/27/lvm-based-virtualization-kvm-and-jaunty/">KVM post at Adoleo</a> to get some hints on setting it up. I must admit there is a lot of &#8216;not quite&#8217; consistent information on the net about setting up KVM &#8230; and I can understand people who have tried setting it up, got stuck, googled for answer &#8230; and then given up. The Adoleo post is quite good as it&#8217;s quite recent. There were a couple of extra apt-get&#8217;s I needed to do to get everything going (you need the qemu package for example).</p>
<p>Now, with all the bits installed, I of course wanted to install a guest. This is where I think a lot of info on the net becomes confusing. It&#8217;s very much a case of heaps and heaps of &#8216;abstractions&#8217;. Here&#8217;s how I think everything fits together;</p>
<blockquote>
<ul>
<li>kvm itself is a low level kernel module that does the virtualization stuff using the Intel VT extension or the AMD SVM extension</li>
<li>qemu is a software  i386 (and others) CPU emulation system that has been around for years and has a lot of tools necessary for doing virtualisation stuff. In the past qemu has been slow.</li>
<li>qemu now can leverage itself against kvm to do &#8216;in hardware&#8217; virtualisation. So I think if you run the kvm command (which seems ot take all the same args as the qemu command) on a VT or SVM capable CPU and you just happen to be emulating a intel type PC architecture system then it&#8217;ll go and use the dandy fast hardware virtualization stuff.</li>
<li>Launching these virtual machines using the kvm command at the command line means you end up with a long list of args. Someone must have thought &#8216;Lets come up with some clever XML abstracted network thingee instead&#8217; and hence you have this libvirt API which seems to be an API for managing virtual machines both locally and across a network. All the args to the kvm command are now in the form of some XML file.</li>
<li>Someone thought we need some GUI management tool just like vmware etc have and you end up with virt-manager which seems to be used in the majority of examples on the net. virt-manager uses the libvirt API.</li>
</ul>
</blockquote>
<p>Well, all the above is how I think it works &#8230; today <img src='http://www.kernelcrash.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So based on that Adoleo info for the basic low level setup, I think I started up virt-manager (you might have to apt-get it too) and you get a window that says;</p>
<blockquote><p>localhost (System)</p>
<p>localhost (User)</p></blockquote>
<p>Of course I could not find a howto anywhere that mentioned why there are two entries and what each one is for. What I think they mean is that localhost (System) is for all the virtual machines running as root level , and the localhost (User) is for all the machines running as your username (???). Anyway I clicked the User one and &#8216;connected&#8217; to it OK, then right clicked to create a new VM. I think I tried a ubuntu 9.04 VM first. That sort of worked OK. You get a dandy graphical console view and even though the mouse was sometimes erratic (there is a hint somewhere to configure the virtual mouse as a usb tablet to get around this) I got the VM installed OK.</p>
<p>Then of course I could not get networking to go. I&#8217;ve set up bridging using brctl before so I had an idea in my head how I wanted things to work. I changed my /etc/network/interfaces to bridge my eth0 into a br0 bridge (as per that Adoleo page), and my host side networking worked fine. Guest networking was a no go. it eventually clicked that even though my user had write permission to /dev/net/tun that it probably was not creating the tap devices in the first place etc. I googled for a while, gave up, then thought &#8220;I&#8217;ll just make the VM&#8217;s part of that localhost (system) thing which should run as root and get rid of my network probs.</p>
<p>This meant working out where the libvirt XML config files live for the VMs. They live in ~/.libvirt/qemu. Just mv them from there into /etc/libvirt/qemu, and restart the libvirt daemon (I seem to have to do this restart a lot);</p>
<blockquote><p>/etc/init.d/libvirt-bin stop</p>
<p>/etc/init.d/libvirt-bin start</p></blockquote>
<p>Probably shutdown all your VMs too and stop virt-manager and start it again and you should now see all your VMs under &#8216;localhost (System)&#8217;.</p>
<p>Now my networking worked. I had something like this in my XML file for the ubuntu VM;</p>
<blockquote><p>&lt;interface type=&#8217;bridge&#8217;&gt;<br />
&lt;mac address=&#8217;54:52:00:12:34:56&#8242;/&gt;<br />
&lt;source bridge=&#8217;br0&#8242;/&gt;<br />
&lt;model type=&#8217;virtio&#8217;/&gt;<br />
&lt;/interface&gt;</p></blockquote>
<p>and also I had the following somewhere for the mouse;</p>
<blockquote><p>&lt;input type=&#8217;tablet&#8217; bus=&#8217;usb&#8217;/&gt;</p></blockquote>
<p>So now I tried a Windows XP VM. It also worked. I had some fun with the networking. Initially I used a line like the ones above, which specify that virtio thing. Virtio is some special driver interface that KVM virtual machines can use to get much faster disk and network performance. It requires a special driver in the guest OS. I think in the case of ubuntu 9.04 this is already integrated. With my XP VM I would just get a &#8216;Ethernet Controller&#8217; device detected &#8230; and for the life of me I could not track down where the Windows XP virtio drivers now live on the net. All the links to them on the net seem either broken or really old. So I kind of gave up, and my XP VM now just has a network section like so (without the virtio ref);</p>
<blockquote><p>&lt;interface type=&#8217;bridge&#8217;&gt;<br />
&lt;mac address=&#8217;54:52:00:65:43:21&#8242;/&gt;<br />
&lt;source bridge=&#8217;br0&#8242;/&gt;<br />
&lt;/interface&gt;</p></blockquote>
<p>In the XP device manager I now just see a Realtek 8139C network device. It is autodetected and configured and networking just works.</p>
<p>So then I tried a Windows 7 RC VM. The only ISO I have is for the 64 bit version. Of course, one of the limitations of KVM is that you cannot run a 64 bit guest on top of a 32 bit OS (I think some of the vmware products can do this). Anyway, my host OS install was relatively new (and destroyable) so I downloaded the 64 bit iso of Ubuntu 9.04 desktop and got that up and running. And set everything up AGAIN.  Now I tried the Windows 7 install and suffice to say it does not work. It starts, it goes a bit of the way through the install and then dies. So far I&#8217;ve googled but haven&#8217;t found a solution.</p>
<p><strong>Summary</strong></p>
<p>One very noticeable thing is that the VMs seem quite snappy and responsive. A lot more so than any of the other virtualization products I&#8217;ve tried on this server. And I get the impression that people are starting to use KVM for production workloads.  Sure I was disappointed that I couldn&#8217;t get Windows 7 to run, but thats not a big deal for me. I found the virt-manager was good at the basic &#8216;wizard to create a simple VM&#8217;, but some of the finer points about how it works have a way to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/kvm/2009/05/16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick VM testing with OpenVZ</title>
		<link>http://www.kernelcrash.com/blog/quick-vm-testing-with-openvz/2009/03/19/</link>
		<comments>http://www.kernelcrash.com/blog/quick-vm-testing-with-openvz/2009/03/19/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 04:41:00 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=209</guid>
		<description><![CDATA[I&#8217;ve been running OpenVZ now on my T42 for a few weeks now, and its all going well. Certainly no complaints.  Basically the host is Debian Lenny and the two guests are also Debian Lenny; one as my asterisk server and the other is a small subversion server.
Recently I had a problem with a Debian [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running OpenVZ now on my T42 for a few weeks now, and its all going well. Certainly no complaints.  Basically the host is Debian Lenny and the two guests are also Debian Lenny; one as my asterisk server and the other is a small subversion server.</p>
<p>Recently I had a problem with a Debian Etch server I maintain for a client. The possible solution to my problem involved downloading and installing a new program. Of course, this new program seemed to want a lot of dependencies met. I started to apt-get these and when apt-get told me it might need to install 100MB+ of related packages, the alarm bells went off and I hit ctrl-c. A better solution would be to try this on a test Etch server &#8230; but I didn&#8217;t have one.</p>
<p>OpenVZ to the rescue. Basically I downloaded a Debian Etch template for OpenVZ, installed the program and its dependencies and basically worked out the solution to my problem.Sure you can do the same thing with other virtualisation technologies but the key advantages to me were just how quick it was to do everything;</p>
<p>Firstly the setup/install process is quick;</p>
<ul>
<li><a href="http://wiki.openvz.org/Download/template/precreated">The example templates on the OpenVZ site</a> are all relatively small (the Etch one is 112MB). A lot smaller than a CD or DVD install image.</li>
<li>To install the image takes a few seconds</li>
<li>I already had my notes for the handful of commands to create a VM, so I had the VM running and on an IP address on my LAN in a few minutes</li>
<li>Since the debian build is minimal, an apt-get update/upgrade is also very quick.</li>
</ul>
<p>Another key factor that is not obvious is just how fast you can start and stop and restart a VM. There&#8217;s no hardware probing as the kernel boots since each VM has no kernel. The overhead is the startup time of the relevant startup scripts. In my test VMs it&#8217;s in the order of a few seconds to startup or shutdown. This is obviously handy when you&#8217;re testing something and you need to reboot several times.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/quick-vm-testing-with-openvz/2009/03/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMware ESXi on a Thinkpad T42</title>
		<link>http://www.kernelcrash.com/blog/vmware-esxi-on-a-thinkpad-t42/2009/02/09/</link>
		<comments>http://www.kernelcrash.com/blog/vmware-esxi-on-a-thinkpad-t42/2009/02/09/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:24:00 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=140</guid>
		<description><![CDATA[As per my previous post, I&#8217;ve put OpenVZ on my old Thinkpad T42. However, prior to trying OpenVZ, I installed Vmware ESXi on the T42. Amazingly it does install and it does run, but I gave up on it due to poor performance. The T42 has a gig of RAM and a 5400RPM drive, and [...]]]></description>
			<content:encoded><![CDATA[<p>As per my previous post, I&#8217;ve put OpenVZ on my old Thinkpad T42. However, prior to trying OpenVZ, I installed <a href="http://www.vmware.com/products/esxi/">Vmware ESXi </a>on the T42. Amazingly it does install and it does run, but I gave up on it due to poor performance. The T42 has a gig of RAM and a 5400RPM drive, and it did require some hacking to get ESXi installed, but my thoughts were that either DMA wasn&#8217;t working to the drive or ESXi really really wants you to install Vmware Tools to make a VM work passably OK. It seemed OK with one VM running, but two seemed to kill performance.</p>
<p>For some background, the big problem with ESXi is that I didn&#8217;t think I had anything that was compatible. It has a very limited range of hardware it works with. I did try it on my Core2Duo desktop server when it first came out, but it couldn&#8217;t find a disk to install on, and I had low hopes of a Marvell gigabit card ever working anyway. There is the highly useful <a href="http://www.vm-help.com/esx/esx3.5/Whiteboxes_SATA_Controllers_for_ESX_3.5_3i.htm">VMware ESX Whitebox HCL.</a> That pretty much confirmed that my ASUS motherboard was never going to work and I needed an Intel Pro 100 or 1000 network card (and intel Pro 1000 cards seem to be particularly expensive in my part of the world).</p>
<p>So I tried installing it on my T42. Of course the installer failed, saying it cannot find a disk it can write to. It seems that ESXi is aimed at people with SCSI and SATA  or iSCSI drives and the lowly T42 can only do IDE. However, there is <a href="http://communities.vmware.com/message/1046750;jsessionid=228C4C8490B6633E3BB496D16325BE23">a way to set it up on the internal IDE disk</a> (NB: As per this <a href="http://blog.outie.net/?p=38">outie.net howto on the IDE ESXi trick</a> , you need to press Alt-F1 to flip back to the first console screen after you type &#8216;install&#8217;. I thought this was rather confusing). Using this technique, ESXi installs just fine. You  reboot and the network interface works and you have a very compact ESXi server</p>
<p>OK, so ESXi installs. Now what?</p>
<p>This next bit turned out to be rather painful. The main way of administering your shiny new ESXi server is to use Vmware Infrastructure Client which only works on Windows! Doh! So I thought I&#8217;ll run up Vmware Fusion on my Mac, install Vmware Infrastructure into my XP VM and do it all from there. This sounded like a great idea, but I came across an annoying problem related to running a VMware product within a VMware product.</p>
<p>VMware Fusion gets you to press Ctrl-Alt to release the mouse and keyboard back to the host machine. Guess what Vmware infrastructure gets you to press to release its mouse/keyboard back to the host machine? Yes, ctrl-alt as well. So, in Vmware Infrastructure I create a test virtual machine to boot off, but I had trouble getting it to pick up a virtual CDROM, so I would press ctrl-alt to release the mouse/keyboard, but sadly Fusion picked this up and I found my mouse/keyboard were back at the &#8216;Mac&#8217; level. It seemed rather difficult to get back to the Windows desktop (ie. I could not do things like press the &#8216;Stop&#8217; or &#8216;Restart&#8217; buttons in Vmware infrastructure).</p>
<p>One workaround I did find was to go to the ESXi server and restart the Management Agents &#8230; which then made Vmware Infrastructure pop up a message saying it&#8217;d lost contact with the server.</p>
<p>Eventually I found a setting in the settings for my virtual machine to set a boot delay. I set this to 7000ms and that gave me time to click the connect CD/DVD button and find the Fedora iso I was testing this with &#8230;. and eventually it booted.</p>
<p>Fedora must use a vmware X driver in its installed as I no longer had my ctrl-alt problem once it installed</p>
<p>Another problem I had was when I tried to create a second VM and got a message in Vmware Infrastructure like &#8216;Admission Check failed for Memory Resource&#8217;. I eventually found this post about <a href="http://communities.vmware.com/thread/140488?tstart=0&amp;start=15">reducing the VIM memory</a> . There&#8217;s a post part way down that page about changing the VIM object reservation from 512MB to 192MB. That did the trick for me.</p>
<p>Installing a Windows XP Pro VM requires getting a SCSI driver floppy image (I couldn&#8217;t see how you could use an IDE disk in a VM). I ended up downloading the floppy image from <a href="http://download3.vmware.com/software/vmscsi-1.2.0.4.flp">http://download3.vmware.com/software/vmscsi-1.2.0.4.flp</a> . For the Windows install, first I had to click the connect CD/DVD and then after you see the CD booting, click the &#8216;connect floppy&#8217; and select the image. Then when the installer prompts you to press F6 for any additional drivers, it should find the driver floppy image.</p>
<p>So it generally  worked. But performance was pretty crap. It&#8217;s probably an OK test set up to get to know ESXi and the Infrastructure client &#8230; but I probably wouldn&#8217;t use it to run actual useful servers on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/vmware-esxi-on-a-thinkpad-t42/2009/02/09/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenVZ and Asterisk and PAE</title>
		<link>http://www.kernelcrash.com/blog/openvz-and-asterisk-and-pae/2009/02/03/</link>
		<comments>http://www.kernelcrash.com/blog/openvz-and-asterisk-and-pae/2009/02/03/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 01:29:19 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[asterisk]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=150</guid>
		<description><![CDATA[This post started out as a simple howto for installing Asterisk in an OpenVZ container on Debian Lenny. It all started out well, as a test box I used my core2duo server running Debian Lenny, did an apt-get of the openvz kernel image that is already in the Lenny standard repository, downloaded an OpenVZ template [...]]]></description>
			<content:encoded><![CDATA[<p>This post started out as a simple howto for installing <a href="http://www.asterisk.org">Asterisk</a> in an <a href="http://wiki.openvz.org/Main_Page">OpenVZ</a> container on <a href="http://www.debian.org/releases/testing/">Debian Lenny</a>. It all started out well, as a test box I used my core2duo server running Debian Lenny, did an apt-get of the openvz kernel image that is already in the Lenny standard repository, downloaded an OpenVZ template for  a minimal Lenny virtual machine (VM), got a VM running, installed asterisk using apt-get inside the VM, got it configured, then worked out how to install the zaptel modules (usiing the debian repository&#8217;s zaptel-source) in the host machine using module-assistant, and then getting the zaptel stuff recognised within the VM. And it all worked.</p>
<p>However, setting it up on the core2duo box was just a test. I really wanted to set it up on my old Thinkpad T42. It&#8217;s been gathering dust since I bought the Macbook, and it seemed such a shame to have it doing nothing. I&#8217;ve had an old Thinkpad 600X running Asterisk for a while now. It runs natively (ie. not in a VM) and does the job, but it has a hand compiled kernel and Asterisk &#8230; and that kind of set up tends to put me off doing proper updates on it. Hence why I was liking Debian Lenny; modern kernel and Asterisk 1.4.x in the standard repository. And the T42 had a bit of horsepower with a 1GB of RAM and a 100GB drive, so I thought something like Asterisk could be virtualised on it.</p>
<p>So step 1, install Lenny from CD on the T42 and &#8216;apt-get update&#8217; , &#8216;apt-get upgrade&#8217;, then step 2 ; install the openvz kernel image;</p>
<blockquote><p>apt-get install linux-image-2.6.26-1-openvz-686</p></blockquote>
<p>And reboot &#8230; and nothing. It would not boot. Obviously my Thinkpad did not like this kernel. It turns out that the Debian Lenny OpenVZ kernel is compiled with <a href="http://en.wikipedia.org/wiki/Physical_Address_Extension">PAE</a> support compiled in. A core2duo has PAE support. The Pentium M in the Thinkpad does not support PAE.</p>
<p>So what to do? I could go on about the other virtualisation techniques I tried here &#8230; but ultimately I liked the idea of OpenVZ; Simple kernel mod, light overhead, don&#8217;t need dedicated raw files on disk for VMs. I also liked that Lenny had a standard OpenVZ kernel in it&#8217;s repository, which ultimately meant &#8216;easy kernel updates&#8217;.</p>
<p>So I thought I&#8217;d have  a go at trying to recompile the Debian OpenVZ kernel with PAE turned off &#8230; in a supportable way. To me the easy way is to get a vanilla kernel from kernel.org, and add the patches from openvz.org. But I wanted to have a kernel closely approximating the latest apt-get&#8217;able Debian OpenVZ kernel.</p>
<p>I&#8217;ve used make-kpkg to make my own debian kernels before, but that didn&#8217;t really work in this case.</p>
<p>So here&#8217;s what I did (I got a lot of ideas from <a href="http://it.toolbox.com/blogs/locutus/easily-build-a-debian-xen-kernel-package-without-pae-22254">this post about Xen without PAE</a>);</p>
<blockquote><p># get the source<br />
cd /usr/src<br />
apt-get source linux-image-2.6.26-1-openvz-686</p></blockquote>
<p>Now you should end up with a /usr/src/linux-2.6-2.6.26 directory. It looks like a normal kernel extraction directory, but with a debian directory.</p>
<blockquote><p>cd /usr/src/linux-2.6-2.6.26/debian/config/i386<br />
vi config.686-bigmem</p></blockquote>
<p>Now I just searched for PAE in the partial config file and turned it off, as well as disabled the 64GB setting and enabled the 4GB one. Mine looks like this:</p>
<blockquote><p>CONFIG_HIGHMEM4G=y<br />
CONFIG_HIGHMEM64G=n<br />
## end choice<br />
CONFIG_X86_PAE=n</p></blockquote>
<p>Save that. Now do all the steps to apply patches, build the config, and compile to generate the kernel image and headers deb</p>
<blockquote><p>cd /usr/src/linux-2.6-2.6.26<br />
fakeroot debian/rules debian/build debian/stamps</p>
<p># Removing these ABI files below is a cheap hack workaround to errors that are normally produced at the end of the compile</p>
<p>rm debian/abi/2.6.26-1/*<br />
fakeroot make -f debian/rules.gen binary-arch_i386_openvz_686</p></blockquote>
<p>That last fakeroot command will take ten bazillion years to complete. Once complete you should end up with two deb files in /usr/src;</p>
<blockquote><p>linux-headers-2.6.26-1-openvz-686_2.6.26-13_i386.deb<br />
linux-image-2.6.26-1-openvz-686_2.6.26-13_i386.deb</p></blockquote>
<p>Now install both of these;</p>
<blockquote><p>cd /usr/src<br />
dpkg -i linux-headers-2.6.26-1-openvz-686_2.6.26-13_i386.deb<br />
dpkg -i linux-image-2.6.26-1-openvz-686_2.6.26-13_i386.deb</p></blockquote>
<p>And make sure you have the OpenVZ tools installed;</p>
<blockquote><p>apt-get install vzctl</p></blockquote>
<p>And try rebooting</p>
<p>This time it worked for me.</p>
<p>And now (finally) we set up a virtual machine and install Asterisk in it.</p>
<p>Download an OpenVZ template for Lenny from <a href="http://openvz.org/download/template/cache">http://openvz.org/download/template/cache</a>;</p>
<blockquote><p>debian-5.0-i386-minimal.tar.gz</p></blockquote>
<p>You just put the tar.gz file in /var/lib/vz/template/cache (ie. don&#8217;t extract it).</p>
<p>Then its a case of picking a unique id for your VM (eg. 101) and doing  something like;</p>
<blockquote><p>vzctl create 101 &#8211;ostemplate debian-5.0-i386-minimal &#8211;config vps.basic<br />
vzctl set 101 &#8211;onboot yes &#8211;save<br />
vzctl set 101 &#8211;hostname testmachine &#8211;save<br />
vzctl set 101 &#8211;ipadd 10.1.2.3 &#8211;save<br />
vzctl set 101 &#8211;nameserver 1.2.3.4 &#8211;save<br />
vzctl start 101</p></blockquote>
<p>The VM should start quickly and to get a sort of console you enter;</p>
<blockquote><p>vzctl enter 101</p></blockquote>
<p>One thing that confused me initially is how networking works. The basic example above uses venet networking. I wasnt sure whether the IP address I specified should be on a seperate subnet or on the same subnet as my host machine. In the end, I used an IP address that was on the same subnet as my host machine. It doesn&#8217;t use brctl style bridging, but it effectively bridges the interface onto your network. I must admit I couldn&#8217;t find a decent explanation/diagram of how OpenVZ networking works.</p>
<p>Install asterisk in the VM;</p>
<blockquote><p>apt-get install asterisk</p></blockquote>
<p>The install worked fine, but because of problems with Music On Hold in the past I wanted to set up ztdummy properly. This can be done.</p>
<p>In the host machine I <a href="https://www.saruman.biz/wiki/index.php/Installing_and_configuring_Zaptel">installed the zaptel modules per this debian howto</a></p>
<blockquote><p>apt-get install zaptel-source<br />
module-assistant prepare<br />
module-assistant auto-install zaptel</p></blockquote>
<p>Afer you do that, do a &#8216;modprobe ztdummy&#8217;. The first time I tried this it didn&#8217;t work, because Lenny had downloaded the &#8216;official&#8217; package for the OpenVZ kernel headers rather than the one that I generated. If that happens to you, dpkg -r the old package, and then install the headers deb that you created earlier. Then run the auto-install above again and double check that the ztdummy modules inserts cleanly. If you do a dmesg now, you should see something like;</p>
<blockquote><p>ztdummy: High resolution Timer started, good to go</p></blockquote>
<p>So that gets ztdummy working from the host machine. We need to make it accessible from within the virtual machine. I looked at the following two howtos;</p>
<p><a href="http://wiki.openvz.org/Asterisk_in_VE_with_debian_stable">http://wiki.openvz.org/Asterisk_in_VE_with_debian_stable</a><br />
<a href="http://wiki.openvz.org/Asterisk_from_source">http://wiki.openvz.org/Asterisk_from_source</a> (I just used the vzctl example commands they have)</p>
<p>The big test of whether the ztdummy stuff is working from inside the virtual machine is to run zttest and hit ctrl-c after a few lines of output. Here&#8217;s how mine runs;</p>
<p>root@lenny:/# zttest<br />
Opened pseudo zap interface, measuring accuracy&#8230;<br />
99.996582% 99.975983% 99.984177% 99.983887% 99.984070% 99.984467% 99.984375%<br />
99.984177% 99.979492% 99.984467% 99.981735% 99.983208% 99.984581% 99.982819% 99.983978%<br />
99.982811% 99.977448% 99.983971% 99.983971% ^C<br />
&#8212; Results after 19 passes &#8212;<br />
Best: 99.997 &#8212; Worst: 99.976 &#8212; Average: 99.983484, Difference: 99.983484</p>
<p>So the only bit remaining for me was to configure asterisk. I just copied files over from my old Asterisk server and got it going. The only issues I had;</p>
<ul>
<li>I needed to use the <a href="http://asterisk.hosting.lv/">g729 codec from http://asterisk.hosting.lv/</a>. That just requires dropping the library file in the right directory and restarting asterisk.</li>
</ul>
<ul>
<li> I found I had to change the asterisk.conf file so that it had the following change;astdatadir =&gt; /usr/share/asterisk<br />
Debian seems to put all the sounds and music on hold data under /usr/share/asterisk (instead of /var/lib/asterisk). I had some ulaw and g729 sounds on the old server, so I copied those into /usr/share/asterisk/sounds</li>
</ul>
<p>And that is pretty much it. What an endeavour. In hindsight, if I had counted the cost of all the effort put in to get this working on a non-PAE CPU, it would have been easier to just buy a newer system with a PAE CPU.</p>
<p>UPDATE: I used the simple venet networking when I initially set up the Asterisk virtual machine. Unfortunately, the VM would work for a few hours and then either lose its default route or be unable to get responses to DNS requests &#8230; so I ended up converting the VM to veth networking using the notes <a href="http://wiki.openvz.org/Using_veth_and_brctl_for_protecting_HN_and_saving_IP-adresses">here</a> and <a href="http://wiki.openvz.org/Virtual_Ethernet_device">here</a>. It now works much better.</p>
<p>UPDATE: I noticed after doing this, that an apt-get update/upgrade may end up trying to download a kernel with the same name as the one I compiled. There should be a way around this, but for now I&#8217;m doing the following to prevent my kernel and headers being overwritten (NB: You may have to undo the change below in order to install a new self-compiled kernel. You probably just need to change &#8216;hold&#8217; to &#8216;install&#8217; to undo the change below);</p>
<blockquote><p># echo &#8220;linux-headers-2.6.26-1-openvz-686 hold&#8221; | dpkg &#8211;set-selections<br />
# echo &#8220;linux-image-2.6.26-1-openvz-686 hold&#8221; |dpkg &#8211;set-selections</p></blockquote>
<p>UPDATE: I had problems with DNS lookups occasionally hanging from within the OpenVZ virtual machine. If I did a &#8216;cat /proc/user_beancounters&#8217; from inside the virtual machine, the failcnt column would have a non-zero number against the dgramrcvbuf.  Apparently this has something to do with udp buffers. As a quick workaround I did this to double the barrier limit for that parameter;</p>
<blockquote>
<pre>sudo vzctl set 102 --dgramrcvbuf $((262144*2)) --save</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/openvz-and-asterisk-and-pae/2009/02/03/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>linux sound</title>
		<link>http://www.kernelcrash.com/blog/linux-sound/2009/01/07/</link>
		<comments>http://www.kernelcrash.com/blog/linux-sound/2009/01/07/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 06:26:44 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=102</guid>
		<description><![CDATA[In my previous post I mentioned that I&#8217;d had some issues with sound in Debian Lenny. The problem was intermittent, but had something to do with the order of sound devices being recognised at boot (remember the PC speaker is a seperate sound device). For what it&#8217;s worth, I found a post somewhere that suggested [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post I mentioned that I&#8217;d had some issues with sound in Debian Lenny. The problem was intermittent, but had something to do with the order of sound devices being recognised at boot (remember the PC speaker is a seperate sound device). For what it&#8217;s worth, I found a post somewhere that suggested having this in /etc/modprobe.d/sound (I had to actually create that file):</p>
<blockquote><p>alias snd-card-0 snd-hda-intel<br />
options snd-hda-intel index=0<br />
alias snd-card-1 snd_pcsp<br />
options snd_pcsp index=1</p></blockquote>
<p>It seemed to fix it.  Then earlier today I was trying to play a youtube video and could barely hear it. I&#8217;d been playing a video in mplayer earlier and the volume level seemed to be fine. So I checked the Gnome Volume control in the top right corner and it was at 100%, then I ran alsamixer and the main volume and the PCM one were almost at 100 as well. Then I checked the volume control in the flash window for the youtube video. It was full. Then I double checked the actual volume of the speakers on my monitor. They were pretty high too.</p>
<p>This got me thinking about linux sound in general; Sound on linux has been a pain in the ass for quite a while now. I know it works &#8216;most of the time&#8217; &#8230; but it&#8217;s one of those things that you&#8217;d kind of like to work &#8216;all the time&#8217;. Why on earth should anyone even have to consider about 4 volume controls? That is obviously silly.</p>
<p>So per usual I started doing some research, and came across <a href="http://insanecoding.blogspot.com/2007/05/sorry-state-of-sound-in-linux.html">&#8216;The Sorry State of Sound in Linux&#8217;</a> . It&#8217;s over a year old, but I think it&#8217;s probably still quite relevant. It is sort of a mini history of how linux sound ended up in the mess that it has. An interesting read. I must admit I have never really played with  <span id="SPELLING_ERROR_9" class="blsp-spelling-error">aRts</span> and <span id="SPELLING_ERROR_10" class="blsp-spelling-error">ESD</span> or pulseaudio or any of those software mixing things as I generally run things using ALSA directly.</p>
<p>There is a subtle hint in that blog post to try out what was the closed source OSS (by 4Front technologies). Its now open source as far as I can tell &#8230; and you can just <a href="http://www.4front-tech.com/download.cgi">download</a> it and install it for free. So I did. I just grabbed the linux 2.6 x86 deb and installed it (which was very very easy). Rebooted. It detected my Intel HDA onboard sound and then I ran osstest (which makes nice-ish test noises rather than highly annoying ones). In Gnome, the volume control applet in the top right corner no longer works (not entirely sure why), but I just run ossxmix to change the volume. It seems to work fine. And like a few of people noted on that blog post &#8230; the sound output seems to sound better than anything ALSA produced.</p>
<p>So, so far so good. I can even play that youtube video now and hear it.</p>
<p>There&#8217;s some interesting comments in that blogpost. This one sounds a chord with me;</p>
<blockquote><p>&#8220;This type of BS is exactly why many of us long time linux users have given up and bought macs, or &#8230; windows.&#8221;</p></blockquote>
<p>I&#8217;m not suggesting you buy a Mac or Windows PC. However, if like me you&#8217;ve used Linux since the 90&#8217;s you may be starting to tire of some of these issues that seem to sound more like politics rather than real technical issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/linux-sound/2009/01/07/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lenny upgrade &#8230; continued</title>
		<link>http://www.kernelcrash.com/blog/lenny-upgrade-continued/2008/12/19/</link>
		<comments>http://www.kernelcrash.com/blog/lenny-upgrade-continued/2008/12/19/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 22:19:38 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=92</guid>
		<description><![CDATA[Well it&#8217;s been about a week running Lenny and its mostly all good. But I found one program had a problem with it. Interestingly it was a program I wrote myself. It&#8217;s this C based program that opens multiple download threads &#8230; etc. My most recent version seemed to run fine on Etch &#8230; but [...]]]></description>
			<content:encoded><![CDATA[<p>Well it&#8217;s been about a week running Lenny and its mostly all good. But I found one program had a problem with it. Interestingly it was a program I wrote myself. It&#8217;s this C based program that opens multiple download threads &#8230; etc. My most recent version seemed to run fine on Etch &#8230; but in Lenny it had some weird bugs.</p>
<p>Problem one was that on maybe 80% of occasions (ie. not all the time), just after startup my program would crash with a &#8216;glibc double free&#8217; error. It spat out a stack trace that wasn&#8217;t much use to me. I&#8217;d never seen these double free errors before so I assumed they are something to do with the new glibc used .. OR could be some debug stuff that is in Lenny (since technically it hasn&#8217;t gone stable yet &#8230; its just a release candidate).</p>
<p>So I google for &#8216;glibc double free&#8217; &#8230; and well you can try yourself &#8230; but google returns a zillion results all of people having these errors&#8230;. with not a lot of solutions offered. I did work out that it means that a program tried to do a free() on a block of memory twice. I summarily checked all my free() calls and didn&#8217;t see anything bad. I then played with gdb a bit &#8230; which did&#8217;t really help. My program is multi-threaded and I&#8217;ve never really worked out how to use gdb to effectively debug such a program (I should probably learn). So then I added lots of printfs to try to narrow down where the crash occurs (and keep in mind the crash doesn&#8217;t happen all the time).</p>
<p>So it seemed to start one or two threads and then die shortly after the 3rd thread started. All these download threads run identical code. The bug (I think) related to some openSSL initialisation code early in the thread. My download threads can make either clear text socket connections to a server &#8230; or SSL based ones. I had some lines similar to:</p>
<blockquote><p>connection.method=SSLv23_client_method();<br />
connection.context = SSL_CTX_new(connection.method);</p></blockquote>
<p>But these were being run regardless of whether an SSL connection was going to be established. I added an if statement around these to only run them for SSL connections and voila &#8230; no more glibc errors &#8230;. well none that I&#8217;ve seen.</p>
<p>Weird eh? I did find there is an env variable you can set to turn off all this double free checking;</p>
<blockquote><p>export MALLOC_CHECK=0</p></blockquote>
<p>Problem two was that the unrar program provided with Lenny is a fair bit newer than the one in Etch. My program behaves like &#8216;expect&#8217; forking unrar and watching its output and prompts and responding appropriately. Of course, the text output of the newer unrar (3.80 beta I think) is slightly different to the one in Etch. Suffice to say I had to rewrite some of my &#8216;expect&#8217; code and finally it works again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/lenny-upgrade-continued/2008/12/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading from Etch to Lenny</title>
		<link>http://www.kernelcrash.com/blog/upgrading-from-etch-to-lenny/2008/12/14/</link>
		<comments>http://www.kernelcrash.com/blog/upgrading-from-etch-to-lenny/2008/12/14/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 21:50:13 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=82</guid>
		<description><![CDATA[So my Debian Etch based server has been ticking along for a while now. I chose Etch over lots of other distros as I don&#8217;t like loads and loads of updates.  I just want something reasonably stable and reasonably up to date.
However, recently I tried to upgrade the non-free adobe flashplayer plugin to 10.something &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>So my Debian Etch based server has been ticking along for a while now. I chose Etch over lots of other distros as I don&#8217;t like loads and loads of updates.  I just want something reasonably stable and reasonably up to date.</p>
<p>However, recently I tried to upgrade the non-free adobe flashplayer plugin to 10.something &#8230; and hey it doesn&#8217;t work on Etch. Basically the flashplayer needs a more modern glibc (as to why glibc keeps having so many major version changes is beyond me). Anyway, I started reading about the next version of Debian ; Lenny. They currently have it as an RC1 so I thought that must be reasonably stable. So I downloaded the netinst ISO for the 64 bit version. My current Etch is 32bit, and I&#8217;ve never seen much necessity to upgrade to 64 bit, as I don&#8217;t have lots of memory and I&#8217;ve never seen a review that says &#8216;the 64 bit version goes much better than the 32 bit one&#8217;.</p>
<p>So I installed the 64bit lenny on a separate disk to play with for a while. It all seemed good. Didn&#8217;t seen any faster really &#8230; but I did notice (at least for the 64 bit Lenny) that the flash player is the free one (can&#8217;t remember its name). I remember reading that adobe had recently released a <a href="http://labs.adobe.com/technologies/flashplayer10/">64 bit alpha version of the flashplayer for linux</a> &#8230; but the fact that it was alpha was a worry.</p>
<p>I then remembered that debian lets you do a whole distribution upgrade and I had never tried it. So I made a dd backup of my root partition and gave it a shot. It&#8217;s relatively simple to do (google for &#8216;debian etch lenny dist&#8211;upgrade&#8217;):</p>
<ul>
<li>edit /etc/apt/sources.list and change all the references to &#8216;etch&#8217; to &#8216;lenny&#8217;.</li>
<li>Do a &#8216;apt-get update&#8217;</li>
<li>Do a &#8216;apt-get dist-upgrade&#8217;</li>
</ul>
<p>And then wait a long time. It does download a lot &#8230; and then you&#8217;ll get asked some questions about various packages and also some questions about some files that have changed. The latter generally related to some printer drivers I had manually installed. I made a note of these files but told the installer to use the new versions (After the install was finished I manually loopback mounted my dd of the old root partition and compared by hand)</p>
<p>The main prob after the install was getting X windows to start. I have an nvidia video card and I had installed a linux driver using a driver direct from nvidia. I see now (maybe they&#8217;ve always been there) that you can install these nvidia drivers using apt-get. I can&#8217;t remember the exact steps, but it went something like;</p>
<ul>
<li>apt-get install nvidia-glx</li>
<li>apt-get install nvidia-xconfig</li>
<li>dpkg-reconfigure xserver -xorg</li>
</ul>
<p>I suggest googling for more help. The nvidia-xconfig thing seems to be definately required. And when you do the reconfigure I told it not to use the framebuffer for mode switching &#8230; but I&#8217;m not sure if thats required or not</p>
<p>I also had problems printing afterwards. But that turned out to be a major &#8216;Doh!&#8217; moment as my printer had no paper in it &#8230; and the LED indicators aren&#8217;t exactly very descriptive.</p>
<p>Speedwise, Lenny doesn&#8217;t seem much different. My gdm login possibly takes longer now &#8230; which I&#8217;m thinking may be more to do with data fragmentation due to the major upgrade. Not sure. I&#8217;ll see how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/upgrading-from-etch-to-lenny/2008/12/14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Porting to Mac OS X</title>
		<link>http://www.kernelcrash.com/blog/porting-to-mac-os-x/2008/09/18/</link>
		<comments>http://www.kernelcrash.com/blog/porting-to-mac-os-x/2008/09/18/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 02:43:37 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/porting-to-mac-os-x/2008/09/18/</guid>
		<description><![CDATA[In my spare time I like to program. Usually in C &#8230; which a lot of people find bemusing.  My rationale is I spent my teenage years hacking assembly code on systems like the Amiga, so moving to C is like moving to a &#8216;high level language&#8217;. I never quite hopped on the Object Oriented [...]]]></description>
			<content:encoded><![CDATA[<p>In my spare time I like to program. Usually in C &#8230; which a lot of people find bemusing.  My rationale is I spent my teenage years hacking assembly code on systems like the Amiga, so moving to C is like moving to a &#8216;high level language&#8217;. I never quite hopped on the Object Oriented bandwagon &#8230; so I&#8217;m kind of stuck in my old procedural ways.</p>
<p>I have one program I&#8217;ve been working on lately that is getting more complicated. For most of it&#8217;s life it&#8217;s been &#8216;command line only&#8217;. It creates multiple threads , opens lots of socket connections, spawn&#8217;s external subprocesses too. It&#8217;s been quite a learning curve to get it to work. Lately, I&#8217;ve started adding features to it to open a GUI window to provide status info. My first attempt was to simply add in some Xlib calls (yes Xlib <img src='http://www.kernelcrash.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) to basically do the bare minimum to get a window up. That worked OK on linux, but I&#8217;d already ported the command line version to run on OSX &#8230; and the Xlib version did not really work on OSX.</p>
<p>So I thought &#8216;How hard would it be to turn my program into a Cocoa program?&#8217;. Cocoa is of course the main GUI enviornment on the Mac. In my earlier porting experience, I aas simply treating OSX as &#8216;another unix&#8217; to do the bare minimum to port my program at a command line level. Using Cocoa was a whole different ball game.</p>
<p>So I thought I&#8217;d have a go. It&#8217;s quite a steep learning curve going from &#8216;procedural C programmer using vi as a development environment&#8217; to &#8216;Using Objective C with Cocoa on the XCode development environment&#8217;.</p>
<p>I of course tried to make a very simple first app using an XCode tutorial. That proved a problem as a lot of the tutorials on the net are for XCode 2.x (rather than 3.x that is out now), and Apple have changed the Interface Builder enough to make all the old tutorials very difficult to follow.</p>
<p>But I persevered. I ended up getting the book &#8216;Cocoa Programming for Mac OS X&#8217; which is actually a very well written book.  That kind of gave me enough info to get some of the basics of Objective C (I still have a lot to learn).</p>
<p>After 2 days hacking at my code, I now have a working program. I thought it would take quite a bit longer. I still don&#8217;t have a clue when it comes to some of the philosophical arguments about object oriented programming &#8230; but ultimately I just want a &#8216;first pass&#8217; that sort of works.  Memory management is probably rubbish, and I don&#8217;t fully understand how the event loop is meant to work .. and I know I have a delegate set up &#8230; but I don&#8217;t really understand what a delegate is.</p>
<p>I guess working in XCode was actually moderately fun. It at least told me about the 170 warnings in my program (I really do leave a lot of unused variables all over the place).  Debugging info was OK &#8230; but ultimately debugging multithreaded stuff is very difficult at the best of times.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/porting-to-mac-os-x/2008/09/18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Media Centres and failing disk drives</title>
		<link>http://www.kernelcrash.com/blog/media-centres-and-failing-disk-drives/2008/09/07/</link>
		<comments>http://www.kernelcrash.com/blog/media-centres-and-failing-disk-drives/2008/09/07/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 22:39:59 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/media-centres-and-failing-disk-drives/2008/09/07/</guid>
		<description><![CDATA[For a long time now, I&#8217;ve used an old (black) xbox running XBMC as a media centre in my lounge room plugged into the TV. I just stream content to it, so it only has a little hard drive in it. Cost-wise its hard to beat, and XBMC has been updated enough over the years [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time now, I&#8217;ve used an old (black) xbox running XBMC as a media centre in my lounge room plugged into the TV. I just stream content to it, so it only has a little hard drive in it. Cost-wise its hard to beat, and XBMC has been updated enough over the years to keep up with the myriad of funny codecs out there. I also find the component output of the xbox is quite nice compared to all the other options I&#8217;ve tried.</p>
<p>But the xbox is getting old, and the main thing it can&#8217;t do is very high resolution stuff, especially high resolution H264 content.</p>
<p>I did look at using the bottom half of a Thinkpad T40 as a media centre, but that never worked out very well. So I thought I&#8217;d try the mac mini. I&#8217;ve had the mac mini about a year now using it in my office, but since I bought the macbook the mini gets less and less use. So, even though it seems a waste to sit the mini under the TV, I thought I&#8217;d try it for a while.</p>
<p>I also thought I&#8217;d upgrade the mini from Tiger to Leopard first. I thought I&#8217;d do a clean reformat install, so found a 200GB drive I had, put it in a USB enclosure, told the mac mini to do a Carbon Copy of its internal 80GB drive, and then went and installed Leopard.</p>
<p>My goal was to use the Migration Assistant to migrate data back &#8230;. but I put that on hold, and just set the thing up to run FrontRow. One thing that works much nicer in Leopard is NFS mounts, specifically automounts. I used to manually run a script in Tiger to mount NFS mounts as it never seemed to work the way i wanted. So in Leopard I just put some symlinks under ~/Movies to /net/&lt;fileserver&gt;/movies and it all just worked fine.</p>
<p>I discovered a program called the <a href="http://appletv.nanopi.net/">&#8216;Sapphire Browser&#8217;</a>. It&#8217;s a plugin for FrontRow that I think was originally developed for the Apple TV but also works on Leopard FrontRow. Anyway, it sort of indexes your media collection and adds in coverart and movie/tv descriptions. It mostly works for me. I think it really doesn&#8217;t like my NFS mounts, as I find it very difficult to update the information. The whole concept is similar to the &#8216;Library&#8217; functions in XBMC. It all looks pretty &#8230; but I always wonder whether it&#8217;s that useful from a useability perspecpective.</p>
<p>I&#8217;m connecting the mac mini to the TV with a DVI to HDMI cable, and audio is just out the headphones socket of the mini to the TV (which has left and right audio next to the HDMI input as an option). It works well enough. On my TV, the HDMI is forced to 1280&#215;720, even though the native resolution of the TV panel is 1368&#215;768, so when looking at text its not as crisp as perhaps the VGA input (I should try VGA for comparison). Quality wise I still think the component output of the xbox is slightly better. I can now play 720p stuff OK, though I do see the occasional glitch in playback of these. I need to investigate further whether this is because the data is via NFS or just an issue with FrontRow.</p>
<p>I&#8217;ve also added the Mini in to my Harmony remote. That took a while to get sorted. It works OK, but I haven&#8217;t worked out a way to simulate pressing the play/pause button for 5 seconds in order to make the mini go to sleep.</p>
<p>Anyway, I eventually got round to grabbing my Carbon Copy of the mac mini&#8217;s disk to take a look at (It&#8217;s a seagate 200GB IDE drive). I first tried connecting it to my macbook via the USB enclosure. It would not mount at all. I eventually plugged it into my linux server directly and it found lots of bad sectors on it. I tried Seagate&#8217;s seatools and it too found lots of bad sectors. Not good. How on earth could I lose two disk drives so close together? This one was in constant daily use until I bought that 750GB drive. Then it sat in one of those shipping case things on the floor for the last couple of weeks.</p>
<p>I ran some dodgy sector recovery type programs (I never know what these things are really doing) and they seemed to recover some sectors. And now I&#8217;ve just been running some deep surface scan type recovery thingee program (which seems to take a good 12hrs to run). It actually looks a lot better than it was. With my 300GB drive that died, it got progressively worse over a few days. This one seems to be getting better. Given that my USB enclosure cost $20, I really wonder if its a case of a very dodgy power supply.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/media-centres-and-failing-disk-drives/2008/09/07/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bad blocks</title>
		<link>http://www.kernelcrash.com/blog/bad-blocks/2008/08/09/</link>
		<comments>http://www.kernelcrash.com/blog/bad-blocks/2008/08/09/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 21:50:44 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/bad-blocks/2008/08/09/</guid>
		<description><![CDATA[A few days ago, for whatever reason I found myself repeatedly compiling linux kernels in order to solve some ext3 performance problem (my theory was that kernels after 2.6.18 have very high wait io for ext3 filesystems). This was on my linux server with lots of disk drives. Three of the drives are 300GB ones [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago, for whatever reason I found myself repeatedly compiling linux kernels in order to solve some ext3 performance problem (my theory was that kernels after 2.6.18 have very high wait io for ext3 filesystems). This was on my linux server with lots of disk drives. Three of the drives are 300GB ones in a software RAID5 with LVM2 on top. The root filesystem is obviously not part of this. I have a small (non-mirrored) /boot and root is an LVM2 volume on top of a raw un-mirrored disk partition.</p>
<p>Unmirrored root? Yeah, what was I thinking.</p>
<p>Of course in the midst of all my reboots, the box decided not to come up. I&#8217;d had a few kernel builds that failed to boot so I assumed it was my fault, but I started to see funny DMA errors on the drive that has the root fs on it. Oh no.</p>
<p>And the drive was making strange noises too. This is never a good sign.</p>
<p>So then I set about to save the root fs. The drive was not completely dead, so  I  plugged it into a USB enclosure and had my T42 running dd_rescue against it. This eventually got all of my root partiton (minus 120Kbtyes). I fsck&#8217;d it and it seems reasonable. I really need to copy it file by file somewhere as there are bound to be files with holes in them.</p>
<p>Next problem. So I go and buy a new drive (a 750GB Samsung SATA), but in the course of my troubleshooting and multiple boots off CD (debian etch disk 1), my RAID5 arrays get into a bit of a weird state. Now, I had partitioned these disks into 50GB chunks and then RAIDed each of those (there is a method to this madness which I won&#8217;t go into here). So I have md5 which gives 100GB useable (50 + 50 + another 50 for parity), md6 is set up in a similar way, then md7 through to md10.</p>
<p>The weird state is that with the two working drives left, md9 and md10 say they are inactive when I do a &#8216;cat /proc/mdstat&#8217;. If I do a &#8216;mdadm &#8211;detail /dev/md9&#8242; I get a state of &#8216;Active, Degraded, Not started&#8217;. Trying a &#8216;mdadm &#8211;run /dev/md9&#8242; gives me an IO error. I also tried a &#8216;mdadm &#8211;assemble &#8211;force /dev/md9 /dev/sda9 /dev/sdb9 missing&#8217; , but that just tells me the array is already active.</p>
<p>I check the Event id on the two partitions left in md9 (mdadm -E /dev/sda9 &#8230; mdadm -E /dev/sdb9) and they give me the same number, so in the theory the array should come up with the two drives.</p>
<p>So I trawl the net, and end up partitioning up my replacement drive and trying to add it in. So I tried a &#8216;mdadm /dev/md9 -a /dev/sdc9&#8242;. That added the drive in, but no resyncing started, and md9 stayed in its useless state.</p>
<p>More trawling the net, and I tried:</p>
<p>echo clean &gt; /sys/block/md9/md/array_state</p>
<p>Finally, the array started syncing.  So now I&#8217;ve gone through and added in the all the extra partitions I&#8217;ve set up on the new drive (eg.&#8217;mdadm /dev/md5 -a /dev/sdc5&#8242;, &#8216;mdadm /dev/md6 -a /dev/sdc6&#8242; &#8230; and so on).</p>
<p>Did a vgscan to make sure I could see my volume group. Then a &#8216;modprobe dm-mod&#8217; as I was still booted off the Debian Etch install CD here (I just booted it as though I was doing an install, then went to manual partitioning, and chose the Software RAID option. Then don&#8217;t do anything further in the debian installer, hit alt-f2 and get another shell running. Now I can do cat /proc/mdstat and other stuff from this other terminal).</p>
<p>I had to do a vgchange <em>volgroupname</em> -a y</p>
<p>vgdisplay -v should now show lots of logical volumes. Now I go through and e2fsck -f /dev/volgroup/logicalvol for each of the logical vols. This takes quite some time, but its a safety check for me to make sure it all appears to be OK (I realise e2fsck is not going to do a complete check). It all checks out OK.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/bad-blocks/2008/08/09/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
