<?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</title>
	<atom:link href="http://www.kernelcrash.com/blog/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>Tue, 03 Apr 2012 05:12:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Updating NetworkManager via the command line</title>
		<link>http://www.kernelcrash.com/blog/updating-networkmanager-via-the-command-line/2012/04/01/</link>
		<comments>http://www.kernelcrash.com/blog/updating-networkmanager-via-the-command-line/2012/04/01/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 12:02:02 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=605</guid>
		<description><![CDATA[NetworkManager is one of those things in the linux world that many SysAdmins hate. It&#8217;s a bit like your mother-in-law; it means well but is really really irritating. On any new system I set up, the first thing I do is get rid of it, and just use the old-school config files way of setting [...]]]></description>
			<content:encoded><![CDATA[<p>NetworkManager is one of those things in the linux world that many SysAdmins hate. It&#8217;s a bit like your mother-in-law; it means well but is really really irritating. On any new system I set up, the first thing I do is get rid of it, and just use the old-school config files way of setting up your networking. As an experienced sysadmin, my mind is always trying to think ahead to &#8216;how is someone going to troubleshoot this some time in the future&#8217;. Config files and ifconfig and route commands are pretty easy and well understood. NetworkManager is something that appears to make things easier but if it doesn&#8217;t quite work the way you want it can be a bucket of pain.</p>
<p>Which leads me to this post. I was helping to set up a Fedora 16 system recently that had already been installed &#8230; and given that NetworkManager is the default, the sysadmin who set it up left it using NetworkManager. The thing is they had left out the DNS nameserver settings and I needed some name resolution. Of course the easy solution is edit /etc/resolv.conf and add in a nameserver line and in less than 30 seconds (assuming you have the network connectivity in place) you have name resolution. This is what I did and of course it worked and I was happy.</p>
<p>But then there was a power failure at the site and the server rebooted. It came up OK and the first thing I noticed was that /etc/resolv.conf did not have a nameserver entry in it. I knew straight away &#8220;Oh, that&#8217;s NetworkManager overwriting /etc/resolv.conf on boot&#8221;. So what to do to fix it? The normal answer is &#8220;Hop on the console, go to whatever Network preferences is called this week and add in the DNS IP to the Wired Connection in NetworkManager&#8221;. Unfortunately I did not have console access to this server. I did have a remote ssh connection so I tried logging in with x forwarding on, checked that I could launch an xterm, and tried running nm-applet .. which just hung and did not launch the GUI. I also sudo&#8217;d to root, made sure all my xauth and DISPLAY was right, checked that I could launch an xterm, then tried nm-applet &#8230; and again &#8216;nothing&#8217;. The thing is I had kind of seem this behaviour before on redhat-ish systems &#8230; and come to the conclusion that &#8220;PolicyKit is evil&#8221;.</p>
<p>So what next? Surely there must be a command line interface to NetworkManager? Nope. The closest thing is nmcli, but it has the great non-feature of not letting you change much. Sure it can give you some great status info, let you enable and disable some stuff, but no-can-do if you want to just update the DNS server.</p>
<p>Some googling later, and I&#8217;m finding some info about using dbus-send to query and control NetworkManager. In the examples below each dbus-send command gives you a little bit more info for typing in the next command (eg. the first one returns /org/freedesktop/NetworkManager/ActiveConnection/0 on my system for the list of active connections)</p>
<blockquote>
<pre>#work out the active connections
 dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.NetworkManager string:ActiveConnections</pre>
</blockquote>
<blockquote>
<pre>#get the list of devices
 dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
 /org/freedesktop/NetworkManager/ActiveConnection/0 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.NetworkManager.Connection.Active string:Devices</pre>
</blockquote>
<blockquote>
<pre>#get the list of IP4Config stuff
 dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Devices/1 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.NetworkManager.Device string:Ip4Config</pre>
</blockquote>
<blockquote>
<pre># print the nameservers. I knew this was the right command as I
#tried it on a test system that already had a DNS server assigned
 dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/IP4Config/0 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.NetworkManager.IP4Config string:Nameservers</pre>
</blockquote>
<p>OK now, so I could drill down to get the nameserver detail. Great. Surely there is some easy way to then set it? After more googling it eventually transpired that the IP4Config stuff I was getting was a read-only dbussy thing. And that there must be some other way to actually &#8216;write&#8217; to the settings. After more sleuthing (and using the GUI tool d-feet), I worked out this command;</p>
<blockquote>
<pre>dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Settings/0 \
org.freedesktop.NetworkManager.Settings.Connection.GetSettings</pre>
</blockquote>
<p>That prints out a heap of stuff including my IP address and DNS info, but its all in UINT32 type format, so an IP address like 192.168.0.100 is shown as;</p>
<blockquote>
<pre>uint32 1677764800</pre>
</blockquote>
<p>So how did I figure out that &#8216;Settings/0&#8242; bit? You can get a list of the settings available with;</p>
<blockquote>
<pre>dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Settings \
 org.freedesktop.NetworkManager.Settings.ListConnections</pre>
</blockquote>
<p>OK, now I thought there must be a way of using dbus-send to update the DNS address. I tried a few different ideas that all failed, and then found some stackoverflow comment indicating in the dbus-send man page how &#8216;D-Bus supports more types than these, but dbus-send currently does not&#8217;. Great.</p>
<p>So then I looked at the <a href="http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python">python examples that come with NetworkManager.</a> I&#8217;m not that great at python, but I fudged my way through them. Many of the examples did not run, and  I suspected that the version of NetworkManager I had was different to the one the examples were aimed at. Anyway, the biggest set of hints was in the update-secrets.py example, and eventually I hacked it and came up with the following python script (change-dns.py &#8230; Note that you might need to tailor this script if your settings is not Settings/0)</p>
<blockquote>
<pre>#!/usr/bin/env python
import dbus
import sys
import socket,struct</pre>
<pre>def dottedQuadToNum(ip):
   "convert decimal dotted quad string to long integer"
   return struct.unpack('&lt;L',socket.inet_aton(ip))[0]

if len(sys.argv) != 2:
   sys.exit("Must supply ip address for dns; eg. 192.168.0.1")

x = dottedQuadToNum(sys.argv[1])
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings/0")

settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings.Connection")

config = settings.GetSettings()
s_ipv4 = config['ipv4']
s_ipv4['dns'] = dbus.Array([dbus.UInt32(x)], signature=dbus.Signature('u'), variant_level=1)

settings.Update(config)</pre>
</blockquote>
<p>So now I could run my script (called change-dns.py) with</p>
<blockquote>
<pre>./change-dns.py 192.168.0.123</pre>
</blockquote>
<p>And then run that GetSettings dbus-send again to check that it changed.</p>
<blockquote>
<pre>dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager/Settings/0 \
org.freedesktop.NetworkManager.Settings.Connection.GetSettings</pre>
</blockquote>
<p>So yes it did work, but it does not immediately update /etc/resolv.conf, so I still manually updated /etc/resolv.conf. Checking on a test system, NetworkManager does overwrite /etc/resolv.conf with the correct value after you reboot.</p>
<p>What about if you want to set two nameservers and perhaps a default search (eg. &#8216;search local&#8217;). Try changing the end of the script to accept two IP addresses;</p>
<blockquote>
<pre>if len(sys.argv) != 3:
   sys.exit("Must supply two ip addresses for dns; eg. 192.168.0.1 192.168.0.2")

x = dottedQuadToNum(sys.argv[1])
y = dottedQuadToNum(sys.argv[2])</pre>
<pre>bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings/0")

settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings.Connection")

config = settings.GetSettings()
s_ipv4 = config['ipv4']</pre>
<pre>s_ipv4['dns'] = dbus.Array([dbus.UInt32(x), dbus.UInt32(y)], signature=dbus.Signature('u'), variant_level=1)
s_ipv4['dns-search'] = dbus.Array([dbus.String(u'local')], signature=dbus.Signature('s'), variant_level=1)</pre>
<pre>settings.Update(config)</pre>
<pre></pre>
</blockquote>
<p>Just a side note in case you are trawling the net trying to figure out how you can change an IP address on the command line using dbus, basically the change-dns.py script just needs the &#8216;s_ipv4['dns'] = dbus.Array&#8230;.&#8217; lines changed to something like;</p>
<p style="text-align: left;">s_ipv4['addresses'] = dbus.Array([dbus.Array([dbus.UInt32(1962977472L), dbus.UInt32(24L), dbus.UInt32(16820416L)], signature=dbus.Signature(&#8216;u&#8217;))], signature=dbus.Signature(&#8216;au&#8217;), variant_level=1)</p>
<p>The tricky part is figuring out the numbers. There are three numbers (all ending in a capital &#8216;L&#8217;). The first is the IP, the 2nd the netmask, the 3rd the default route. In the example above the IP address is 192.168.0.117. I usually use a programmers calculator, convert that to hex; C0A80075, then reverse all the octets; 7500A8C0 and then convert that to decimal; 1962977472 (of course, its much easier if you use the dottedQuadToNum function in the python script)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/updating-networkmanager-via-the-command-line/2012/04/01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading and Downgrading</title>
		<link>http://www.kernelcrash.com/blog/upgrading-and-downgrading/2012/02/20/</link>
		<comments>http://www.kernelcrash.com/blog/upgrading-and-downgrading/2012/02/20/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 01:33:25 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=580</guid>
		<description><![CDATA[I haven&#8217;t posted for a while about my Scientific Linux 6.0 setup on my Thinkpad R60. It all kind of goes well. However SL 6.0 is kind of old, 6.1 has been out for a while and 6.2 is on the horizon (UPDATE: Ooops, I see its now out!). So I thought I&#8217;d upgrade to [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t posted for a while about my Scientific Linux 6.0 setup on my Thinkpad R60. It all kind of goes well. However SL 6.0 is kind of old, 6.1 has been out for a while and 6.2 is on the horizon (UPDATE: Ooops, I see its now out!). So I thought I&#8217;d upgrade to 6.1. But before jumping into the <a href="www.scientificlinux.org/documentation/howto/upgrade.6x">simple update process</a> I thought I&#8217;d split my root mirror as a precaution. In recent years I just keep having problems with Linux Distro updates. Its not that the update process fails, it&#8217;s usually some oddball behaviour post upgrade that I can&#8217;t live with. Anyway, I do my mdadm fail and stop to detach one half of my boot and root mirrors and do the update to 6.1.</p>
<p>It all seemed to go well. I reboot &#8230; and it starts to boot but X windows does not start. I look at the Xorg log and there&#8217;s some Segmentation Fault without much detail, but I see its trying to access some dri stuff before the fault, and I know this dri stuff doesn&#8217;t exist when you have nomodeset set. See, I can&#8217;t get X to run reliably under SL 6.0 on my Thinkpad R60 without turning KMS off (I get lots of stupid flicker). Anyway, I think maybe this new kernel has fixed the flicker problem so I get rid of &#8216;nomodeset&#8217; and reboot, and sure enough X now starts and looks kind of OK.</p>
<p>However leaving it on for a while the flickering starts to occur again, and then I start noticing these &#8216;kernel:Uhhuh. NMI received for unknown reason&#8217; messages on my terminal sessions periodically. The system seems to still be going OK, but I do some research and find this <a href="http://bugs.centos.org/view.php?id=5369">centos page</a>. So it&#8217;s not sounding like a good upgrade at this point; I can&#8217;t start X unless Kernel Mode Setting is set, and when I have Kernel Mode Setting set I can&#8217;t look at the screen because it flickers badly. Crazy!. So in less than an hour I&#8217;ve had enough pain and reverted my md mirrors back to SL 6.0.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/upgrading-and-downgrading/2012/02/20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux power problems</title>
		<link>http://www.kernelcrash.com/blog/linux-power/2011/06/29/</link>
		<comments>http://www.kernelcrash.com/blog/linux-power/2011/06/29/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 09:55:14 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=572</guid>
		<description><![CDATA[So I&#8217;ve had Scientific Linux 6.0 64 bit on my Thinkpad R60 for a while now, and for the most part it has been fine. But one thing that has really annoyed me is that everytime there is a kernel update, I notice that the laptop fan is stuck on (when the system is essentially [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve had Scientific Linux 6.0 64 bit on my Thinkpad R60 for a while now, and for the most part it has been fine. But one thing that has really annoyed me is that everytime there is a kernel update, I notice that the laptop fan is stuck on (when the system is essentially idle). I always think &#8220;This can&#8217;t be right&#8221; and reboot back off my old kernel.</p>
<p>The thing is the only kernel I have now that has &#8216;good&#8217; fan behaviour is 2.6.32-71.24.1 which is the one that went in when I first installed SL 6.0. Under that kernel , when the R60 is relatively idle, the fan will come on at 2500 to 2900rpm or so for say 60 secs, then be completely off for another 60 secs.  That&#8217;s kind of how I expect it to be when the system is idle (it would be nicer if the fan was off for longer periods &#8230; but sometimes off is better than never off)</p>
<p>A few yum updates later I also have 2.6.32-71.29.1 and the latest being 2.6.32-131.2.1. These two always run with the fan stuck on at 3300rpm or so (while the R60 is essentially idle). Very annoying. So it&#8217;s been interesting to read the various &#8216;linux power regression&#8217; articles on Phoronix lately. <a href="ttp://www.phoronix.com/scan.php?page=article&amp;item=linux_2638_aspm&amp;num=1">The leading cause of the Recent Linux Kernel Power Problems</a> article explains a key source of the problem related to some ASPM subsystem &#8230; and a boot option workaround; &#8220;pcie_aspm=force&#8221;</p>
<p>So I had a go at adding that option into the grub.conf for the 2.6.32-131.2.1 kernel and amazingly the fan behaviour is back to the &#8220;right&#8221; behaviour. The fan now comes on for about 60 secs at 2800rpm, then goes off for 60 secs and so on. Cool stuff. Many thanks to the Phoronix site for figuring this out.</p>
<p>Now, a key thing to remember with Redhat/SL kernels is that they contain many patches from more recent kernels &#8216;backported&#8217; into an older kernel such as 2.6.32 &#8230; and hence that partly explains why this problem exists on the recent SL 6.0 kernels.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/linux-power/2011/06/29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying Scientific Linux 6.0</title>
		<link>http://www.kernelcrash.com/blog/trying-scientific-linux-6-0/2011/05/06/</link>
		<comments>http://www.kernelcrash.com/blog/trying-scientific-linux-6-0/2011/05/06/#comments</comments>
		<pubDate>Sat, 07 May 2011 04:00:44 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=564</guid>
		<description><![CDATA[So, as per my previous post, I was searching for an upgrade path for my Thinkpad R60 virtualistation server running Debian Lenny. I&#8217;d tried upgrading to Squeeze a few times &#8230; and didn&#8217;t like it &#8230; always reverting back to Lenny. So after trying a few different distros/virtualisation hypervisors (using a spare disk), I settled [...]]]></description>
			<content:encoded><![CDATA[<p>So, as per my previous post, I was searching for an upgrade path for my Thinkpad R60 virtualistation server running Debian Lenny. I&#8217;d tried upgrading to Squeeze a few times &#8230; and didn&#8217;t like it &#8230; always reverting back to Lenny.</p>
<p>So after trying a few different distros/virtualisation hypervisors (using a spare disk), I settled on installing Scientific Linux 6.0 64 bit. Key reasons are;</p>
<ul>
<li>It&#8217;s effectively Redhat 6.0, and Redhat &#8216;target&#8217; stability rather than &#8216;latest and greatest&#8217; which is what I&#8217;m after with a virtualisation box.</li>
<li>By using KVM virtualisation on SL 6.0, it contains a version of libvirt that will let you disable the memory balloon (the one in Squeeze always has the memory balloon enabled). The memory balloon stuff is more annoying than useful on my little laptop server.</li>
<li>It didn&#8217;t seem too annoying. Well that&#8217;s what I thought. Less annoying the Debian Squeeze I guess.</li>
</ul>
<p>So I&#8217;d been trying out SL 6 on a spare disk &#8230; so now I thought I&#8217;d put it &#8216;properly&#8217; on the two 500GB drives in the R60. I&#8217;d always run Lenny with a mirrored root and /boot so I wanted to do the same with SL 6.0. I&#8217;d already set split mirrors on the two 500GB drives. The original md devices I used on the first disk were md2 and md3. They currently had an old Debian Squeeze on them with a deliberately failed mirror. The other disk now had md20 and md30 which was the original Lenny install that I had &#8216;split off&#8217; prior to my last Squeeze upgrade (md20 and md30 also being a degraded mirror). So I still wanted to keep md20 and md30 for now in case I wanted to go back to Lenny, and I would overwrite md2 and md3 with SL 6.0. I still wanted to put SL onto RAID1 mirror devices, because at some point I would kill md20 and md30 on the 2nd disk and properly mirror md2 and md3 again.</p>
<p>So I wanted to install SL 6.0 onto md2 and md3 which were both currently failed mirrors. Do you think it would let me do this? Nope. It seems the anaconda installer won&#8217;t let you do this &#8230; which is very very sad. To me it seems an obvious thing that you&#8217;d want to do. I found <a href="https://bugzilla.redhat.com/show_bug.cgi?id=188314">redhat bug 188314</a> which is basically a depressing read.</p>
<p>So, I dug out yet another spare disk (an old 30GB IDE) , removed the 2nd 500GB drive, repartitioned the 30GB drive to match the root and /boot partition sizes and then used mdadm to add in the extra partitions and eventually md2 and md3 were active RAID1 mirrors.</p>
<p>Then I tried to install again (lucky you can boot off a USB attached DVD drive on the R60). This time I got past the partitioning hiccup and had it installed. I used the SL 6.0 x86_64 LiveMiniCD &#8230; which doesn&#8217;t ask too many questions and gives you a reasonable (for 2011) size install. One thing on my R60 that I learnt from previous attempts, that at the inital GRUB screen press a key to get the boot menu, cursor down to &#8216;install&#8217;, press tab, edit the 2nd line, then add the word &#8216;nomodeset&#8217; onto the end of the main kernel boot line. The &#8216;nomodeset&#8217; turns off KMS and prevents the extremely annoying flickering I would previously get.</p>
<p>Once I had it installed, I then went about getting it sorted to work much the same as my Lenny setup. I&#8217;ll include some of my notes further down for reference, and just discuss some of the aspects of KVM setup right now.</p>
<p>So in order to get KVM set up right, I installed the main virtualisation stuff;</p>
<p>yum groupinstall Virtualization<br />
yum groupinstall &#8220;Virtualization Client&#8221;<br />
yum groupinstall &#8220;Virtualization Platform&#8221;</p>
<p>Then I had to edit /etc/libvirt/libvirtd.conf in order to get rid of the dependence on PolicyKit (or attempt to get rid of the dependence). Then I copied in the xml libvirt files from my Lenny install and started modifying them. I changed the kvm binary references to /usr/libexec/qemu-kvm and as I mentioned in my previous post, my Windows 7 32 bit VM always crashed on shutdown until I switched the cpu from i686 to x86_64 (as I had recently upgraded the CPU in my R60 from a 32 bit T2400 to a 64 bit T7200). The machine type in the xml files is also a puzzle. Lenny has a completely different set of them compared to Redhat/SL. Lenny had &#8216;pc&#8217; as the main machine type, and on most of my attempted Squeeze upgrades, somehow the upgrade process seemed to think it was smart to change all my &#8216;pc&#8217; machine references to &#8216;pc-0.12&#8242;. I remember noticing that this makes Windows think it has a new network card, new hard drive etc&#8230;.</p>
<p>With Redhat/SL the QEMU/KVM machine types are pc, rhel6.0.0, rhel5.5.0, rhel5.4.0. It says &#8216;pc&#8217; is the same as &#8216;rhel6.0.0&#8242;, so if I&#8217;d left my libvirt xml files all with &#8216;pc&#8217; they&#8217;d be automatically upgraded &#8230; just like Squeeze did.  I think I currently have rhel5.4.0 as the choice for my Windows 7 VM for lack of a better choice.</p>
<p>Anyway, in the process of getting Windows 7 going again, I got the dreaded &#8216;Windows Actiation error&#8217;. Sure it now thought that not only had the network card changed, the hard drive and now it thinks it has a new CPU. I thought one of the &#8216;features&#8217; of virtualisation is to have the ability to have a &#8216;constant&#8217; hardware abstraction.</p>
<p>So I try to activate Windows 7 online. That fails, so I have to &#8216;ring MS$&#8217; which is definitely the low point of the week. I type in a very long string of numbers on the phone keypad, only to be told that I needed to be put through to an operator. I read the same long series of numbers to a human, who then reads a similarly long series of numbers back to me &#8230; which finally does the trick.</p>
<p>I&#8217;m thinking at this point &#8230; that maybe I should listen to all the people that comment on my ESXi posts and ditch KVM and just switch to ESXi.;-)</p>
<p>But I am a glutton for punishment.</p>
<p>Anyway, it is all kind of working OK now. I added in the line to disable the memory balloon for my KVM guests, and also found there was some ksm daemons that also needed to be disabled, as they sporadically ate lots of CPU as well.</p>
<p>My notes;</p>
<pre># Get rid of the leftovers from doing the LiveCD install
chkconfig --del livesys
chkconfig --del livesys-late
# Turn SSH on
chkconfig --level 345 sshd on
service sshd start
# Turn NetworkManager off.
chkconfig NetworkManager off
service NetworkManager off
# Updated eth0 and br0 network configs</pre>
<pre>edit /etc/sysconfig/network-scripts/ifcfg-eth0 and ifcfg-br0
chkconfig --level 345 network on
service network start</pre>
<pre># The LiveCD never seems to set the hostname
set HOSTNAME in /etc/sysconfig/network
Add our own hostname and IP to /etc/hosts
Comment out hiddenmenu in /boot/grub/menu.lst. Also add in my Lenny boot menu item
# Fix up some sudo rules
visudo
sudo yum upgrade</pre>
<pre># Add in all the virtualistion stuff
yum groupinstall Virtualization
yum groupinstall "Virtualization Client"
yum groupinstall "Virtualization Platform"</pre>
<pre>
# Turn off ksm
chkconfig ksm off
chkconfig ksmtuned off
service ksmtuned stop
service ksm stop
#LiveCD leaves firewall on, so need to do some updates to /etc/sysconfig/iptables and restart the iptables service</pre>
<pre>#I installed the development tools and some other stuff</pre>
<pre>yum groupinstall "Development tools"
yum install libX11-devel
yum install sg3_utils
yum install expect
yum install libXfont-devel</pre>
<pre>#downloaded EPEL release 6.5 rpm to get EPEL set up</pre>
<pre>#Compiled X11rdp and xrdp from svn and cvs respectively. Needed automake1.9 for  X11rdp. Downloaded a srpm for it and compiled by hand.
xrdp 0.6 has changed a bit. Still has the bug where it eats heaps of CPU though, so added the changes mentioned on this page;

http://sourceforge.net/projects/xrdp/forums/forum/389417/topic/3706601</pre>
<pre>#Quite a few deps to handle to do the xrdp compile. Can't remember all of them
yum install pam-devel
yum install libXfixes-devel</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/trying-scientific-linux-6-0/2011/05/06/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying out other virtualisation solutions</title>
		<link>http://www.kernelcrash.com/blog/trying-out-other-virtualisation-solutions/2011/04/02/</link>
		<comments>http://www.kernelcrash.com/blog/trying-out-other-virtualisation-solutions/2011/04/02/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 10:12:19 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=557</guid>
		<description><![CDATA[So, my main virtualisation machine here at home is a Thinkpad R60 running Debian Lenny, with KVM as the virtualisation engine. This has been my main &#8216;server&#8217; host for over a year and a half now. I have quite a few VMs on it, but most are for testing out stuff, so there is only [...]]]></description>
			<content:encoded><![CDATA[<p>So, my main virtualisation machine here at home is a Thinkpad R60 running Debian Lenny, with <a href="http://www.linux-kvm.org/page/Main_Page">KVM</a> as the virtualisation engine. This has been my main &#8216;server&#8217; host for over a year and a half now. I have quite a few VMs on it, but most are for testing out stuff, so there is only one or two VMs that are active constantly. One is a Debian Lenny guest running Asterisk for the most part. The other is a Windows 7 VM. I&#8217;ve been reasonably happy with this setup. Key positive points to me are;</p>
<ul>
<li>I can use the host as a regular linux box with a graphical desktop</li>
<li>Performance is OK</li>
<li>The Debian Lenny guest is idle most of the time, and is lucky to consume 2 or 3% of the host cpu.</li>
<li>It all works with a 32 bit VT capable CPU such as the T2400 core duo in the R60</li>
</ul>
<p>Negatives of this setup are;</p>
<ul>
<li>The T2400 is only 32 bit so no 64 bit guests.</li>
<li>Physical host CPU use when the Windows 7 guest runs is high; 14% or so. I eventually tracked this down to the USB tablet driver. Once removed, host CPU use for the related kvm process is about 2 to 3% for an idle Windows 7.</li>
<li>You cannot do easy snapshots and reverts like you can say with Vmware&#8217;s products.</li>
</ul>
<p>So Debian Squeeze is the new stable &#8216;Debian&#8217;, so I have attempted to upgrade my system. I&#8217;ve actually done this now several times, first using some of the &#8216;pre stable&#8217; releases of Squeeze, as well as the current stable Squeeze. Each time I have reverted back to Lenny. Key negatives of Squeeze are;</p>
<ul>
<li>Host CPU use seems higher for all guests for me.</li>
<li>The extra CPU use by the USB tablet driver in a Windows guest still seems to be there. Makes a big difference if you remove it.</li>
<li>The Windows 7 guest now seems to BSOD (ie. crash) when you shut it down (I&#8217;m just using a virtual IDE disk and a virtual RTL3129)</li>
<li>The Laptop fan seems to stay on more often now.</li>
</ul>
<p>So this has had me looking at alternatives. I am a big fan of Vmware ESXi, but because of the 32 bit CPU in the R60 I am limited to ESXi 3.5 on it. With that in mind, I did my research and discovered that you can put a T7200 core 2 duo CPU into my R60 which is a 64 bit VT capable CPU. So I ordered one off eaby and have had it running in it for a few days now.</p>
<p>So here&#8217;s a quick breakdown of what I&#8217;ve tried lately. Some of these I&#8217;ve only set up on my desktop core 2 duo system, but I intend to try them all on the R60</p>
<ul>
<li><a href="http://www.debian.org/">Squeeze</a> 64 bit. Much the same as the problems I&#8217;ve had with Squeeze mentioned above.</li>
<li>ESXi 3.5u5. This works pretty well. On the R60, all the hardware works, except when you do a shutdown on the console, you get a purple screen of death. Reboots are OK though.</li>
<li><a href="http://www.vmware.com/products/vsphere-hypervisor/overview.html">ESXi</a> 4.0 (I will try 4.1 shortly, but I had the 4.0 CD handy). That works pretty good too. The main negatives for ESXi on this box are; 1) no graphical console anymore, 2) one disk has to &#8216;generally&#8217; be set aside as ESXi vm storage, 3) I have to use Windows to administer it, 4) I can&#8217;t read any of the Thinkpad thermal or fan information.</li>
<li><a href="http://www.scientificlinux.org/">Scientific Linux 6.0</a> 64 bit. I tried the &#8216;LiveMiniCD&#8217; which is pretty good. It installs an IceWM desktop. I&#8217;ve been running my Asterisk VM and my Windows 7 VM on it under kvm. In this case CPU use for both is low, but the Asterisk VM CPU use is still quite a bit higher than my Lenny setup. Also the Windows 7 VM crashes on shutdown just like under Squeeze. Scientific Linux 6 and Squeeze both use a very similar version of qemu-kvm. I might persists a bit of Scientific Linux. It doesn&#8217;t seem too bad (for a Redhat clone). One problem I had with SL 6.0 was a strange flicker on the X desktop every 10 secs. Changing the GRUB kernel args to include &#8216;nomodeset&#8217; (ie. turn off KMS), cured this.</li>
<li><a href="http://www.citrix.com/English/ps2/products/product.asp?contentID=683148&amp;ntref=prod_top">Xenserver</a> 5.6 FP1 . I haven&#8217;t tried it on the R60, just my desktop core 2 duo box. This I thought worked pretty well &#8230; and Citrix have done a lot to make it &#8216;feel&#8217; just like ESXi for the most part, and the Windows admin tool seems to let you do most stuff that Vmware&#8217;s admin client let&#8217;s you do. I did have problems installing the guest tools into a Windows 7 guest though. This was a week or too back and I can&#8217;t quite remember what it was. But I was impressed by it in general, and I&#8217;d like to spend more time looking at it (or XCP below)</li>
<li><a href="http://www.xen.org/products/cloudxen.html">XCP</a> 1.0. This to me looked to be almost exactly the same as Xenserver 5.6 FP1. It had exactly the same problems re the guest tools in Windows 7.</li>
</ul>
<p>So still undecided at the moment. I need to do a bit more research on the ESXi front. The R60 can only handle 3GB of RAM, and I think the newer ESXi&#8217;s have quite a large default memory footprint (but I think there is a way to reduce it a bit). If I could sort out the problem with the Windows 7 BSOD on shutdown then I might consider Scientific Linux. Lot&#8217;s of options.</p>
<p>UPDATE (2011.5.2). The Windows 7 BSOD I was getting when performing a shutdown on Scientific Linux or Squeeze was a IRQL_NOT_LESS_OR_EQUAL. I think I&#8217;ve found what causes this. All my VMs are created with i686 as the CPU type in the libvirt xml files (since my old T2400 chip was 32 bit only). Of course now I have a 64 bit capable chip (T7200) and the new versions of qemu-kvm don&#8217;t seem to like me specifying a i686 for my Windows 7 32 bit instance. If I change the xml file to use x86_64 instead of i686, I can now (finally) gracefully shut the Windows 7 32 bit VM down.;</p>
<p>&lt;type arch=&#8217;x86_64&#8242; &#8230;</p>
<p>Another useful thing to keep my CPU utilisation low is to disable the memory balloon (which I discovered is enabled by default in more recent libvirt&#8217;s). You just need to add this to the &lt;devices&gt; section of your libvirt xml file;</p>
<p>&lt;memballoon model=&#8217;none&#8217;/&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/trying-out-other-virtualisation-solutions/2011/04/02/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to Snow Leopard</title>
		<link>http://www.kernelcrash.com/blog/upgrading-to-snow-leopard/2010/04/27/</link>
		<comments>http://www.kernelcrash.com/blog/upgrading-to-snow-leopard/2010/04/27/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 05:27:26 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=534</guid>
		<description><![CDATA[Yes, I know Snow Leopard has been out for ages, and I did actually purchase the &#8216;real&#8217; install DVD for it some time ago, but well &#8216;Leopard&#8217; seemed to be working fine on my Macbook, and well I&#8217;m very cynical of these claims that &#8216;upgrading is easy and trouble free&#8217;. However, I bought a Hitachi [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I know Snow Leopard has been out for ages, and I did actually purchase the &#8216;real&#8217; install DVD for it some time ago, but well &#8216;Leopard&#8217; seemed to be working fine on my Macbook, and well I&#8217;m very cynical of these claims that &#8216;upgrading is easy and trouble free&#8217;. However, I bought a Hitachi 5K500.B 500GB drive recently as either an upgrade for the 160GB drive in the macbook or as a replacement for the original 80GB drive in my R60. </p>
<p>Given that I had a new (larger) drive. I thought I&#8217;d play with how well Time Machine and the Migration Assistant work. So as a test I setup a large mount point on a linux box and shared it out using Samba to the Macbook, then did the defaults command below to enable a samba share as a Time Machine destination:</p>
<blockquote>
<pre>defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1</pre>
</blockquote>
<p>I also did the mucking around with hdiutil to create the necessary sparsebundle (if you google for &#8216;TMShowUnsupportedNetworkVolumes hdiutil&#8217; you&#8217;ll find a heap of references). It takes a long time to do the first backup. I then set it to &#8216;manual&#8217; mode so it&#8217;s not doing continual backups. Then I did one last Time Machine backup and shut the Macbook down (running Leopard).</p>
<p>Now I swapped in the 500GB drive. Put in the snow leopard DVD, held down &#8216;c&#8217; and let it boot up off the DVD.  Then formatted the drive, and installed Snow Leopard (I picked a different account name than the one I used on my Leopard install, as Migration Assistant will complain later on if you try to restore into the account you are currently logged in as). Once I had SL installed, I then did a &#8216;connect to server&#8217; in finder to mount my Samba share, then you need to click on the sparsebundle that you see, and your time machine backup should now be mounted. Now you can run &#8216;Migration Assistant&#8217;. Tell it you want to restore from a &#8216;Time Machine&#8217; backup, then you should see your time machine backup to choose, then you get some screen with a few tick boxes and you have to wait while it says &#8216;Calculating&#8217;. I just left everything ticked and let it chug away restoring (it takes some time). Eventually, I just restarted, logged in as the username I used to use and voila it all looked suspiciously like my old Leopard setup.</p>
<p>The first thing I wanted to make sure was working was Mail. I started it up and it gives you some messages saying it needs to re-import everything and away it goes. Now, I use Mail.app as my main mail client, and I have an IMAP server that it connects to. I have some anal security in place for the IMAP server, so when Mail was restarted after the re-import I didn&#8217;t let it connect properly to the IMAP server. I then started going through my Inbox to see whether it looked OK. Everything seemed to be there, but I had a weird problem when I clicked on attachments. They would never load. There&#8217;d be some delay and then a popup highlighting there was a permission problem. This led to much trawling through Apple discussion threads and trying various things, but I could not get attachments to display. I just received that error instead</p>
<p>So I switched back to the original 160GB drive for a while. Then I tried again, clean format of the 500GB drive, installed SL, then this time I upgraded to 10.6.2, then did the Migration Assistant restore. No luck. Still had the same permission problem.</p>
<p>So by this time I was getting frustrated with Snow Leopard, so I thought I&#8217;d try to just put Leopard on the 500GB drive. Rather than use something sane like Carbon Copy Cloner or similar I thought I&#8217;d see how good a full restore from &#8216;Time Machine&#8217; would go onto the 500GB drive. So with the old 160GB drive containing leopard, I did another Time Machine backup to the Samba share, shut down, swapped in the 500GB drive and booted off the Leopard install DVD that came with the macbook. Booted off the DVD, formatted the 500GB drive, then chose the option to restore from backup. This is where I learnt that the Apple install DVDs cannot mount a Samba share (or any kind of smb based share). They can mount a afp share though. So I thought, I&#8217;ll install netatalk on my Debian Lenny server that was running Samba, and just get it to share out the same mount that Samba was sharing. </p>
<p>This is when I discovered that the Debian Lenny version of netatalk cannot deal with encrypted passwords. Guess what OSX will only connect to? Yep, it only connects to a netatalk server that can do encrypted passwords (there is actually a defaults &#8216;switch&#8217; that will allow you to connect to a netatalk user ; defaults write com.apple.AppleShareClient afp_cleartext_allow -bool true, but alas I could not get that to work from the shell environment offered on the install DVD), so then I ended up recompiling netatalk on Debian Lenny to handle encrypted passwords, which goes somehting like this;</p>
<blockquote>
<pre>$ sudo apt-get install libdb-dev
$ sudo apt-get install cdbs
$ sudo apt-get install libcrack2-dev
$ sudo apt-get install dh-buildinfo

$ cd debtmp
$ mkdir debtmp
$ sudo apt-get source netatalk
$ sudo apt-get install libcups2-dev
$ sudo apt-get build-dep netatalk
$ cd netatalk-2.0.3
$ sudo DEB_BUILD_OPTIONS=openssl fakeroot debian/rules binary
$ sudo dpkg -i ../netatalk_2.0.3-11+lenny1_amd64.deb

sudo afppasswd -ac
sudo afppasswd myuser</pre>
</blockquote>
<p>You might need to tweak some of the other files under /etc/netatalk too. </p>
<p>OK, so now using the notes on mounting <a href="http://veys.com/2009/08/16/restoring-from-a-samba-based-time-machine-backup-kinda/">here</a>; I could mount my Time Machine backup from the Leopard install DVD;</p>
<blockquote>
<pre>mkdir /Volumes/tmachine
mount -t afp afp://username:password@server.hostname/tmachine /Volumes/tmachine
</pre>
</blockquote>
<p>So then I kicked off my restore. Maybe 5 or 10 mins later the restore had encountered an error. I honestly can&#8217;t remember what it was. The discussion threads I found when googling for the error hinted that it has something to do with using the wrong install DVD (ie. one that came with a different Mac). I was definitely using the DVD that came with my Macbook, but I thought since I had the Snow Leopard DVD as well, then surely a full restore of a Leopard backup using the Snow Leopard boot DVD would end up with a Leopard system. So I did that, mounted the afp share OK, then started the restore &#8230; which continued just fine. Odd.</p>
<p>So that chugged away, and eventually I had a Leopard system on a bigger drive. I opened Mail.app, and again it said it needed to reimport Mail (just like for Snow Leopard). It chugged away for a bit, and then I had my Inbox open and it looked intact. I then found some of the messages with attachments I had had trouble with before and tried to open them. Instead of getting a permission error, I received no message at all &#8230; and in fact nothing happened (ie. my attachment still did not display). Hmmmm. Odd.  It&#8217;s about now that I somehow realised that by blocking access to my IMAP server, I was preventing it from grabbing the attachment. This is probably obvious, but I imagine that Mail.app downloads attachment when you first click on them, and then caches them in the ~/Library/Mail\ Downloads directory, so that normally you&#8217;d be viewing the cached copy. However, I know that Time Machine ignores most cache directories in order to save space &#8230; so after my &#8216;fresh&#8217; install plus restore, the cache directory was empty. I guess I was able to confirm my theory quickly by simply allowing my connection to my IMAP server to work (I noticed after I did this that there is a lot of activity in the &#8216;Activity&#8217; window regarding caching etc.)</p>
<p>So after all that hoopla about Mail attachments, I thought I&#8217;ll reinstall Snow Leopard again. So same deal as before; boot off the SL DVD, format the 500GB drive, let it install SL, get it booted, perhaps upgrade to 10.6.3 or whatever, then use the Migration Assistant to restore from my Time Machine backup. This time when I ran Mail.app I let it connect to my IMAP server, and attachments worked as expected. All good</p>
<p>Apart from my funny Mail.app issue (which was sort of my fault), I was quite impressed with the whole Time Machine backup/restore. I am often asked by family or friends about &#8216;backing up their Windows PC&#8217;, and well there are a bunch of ways to back things up &#8230; but I always think a backup is only as good as your ability to restore it. My thoughts were that I could probably talk someone through doing a full restore of a Mac using a Time Machine backup &#8230; over the phone (maybe not from my convoluted AFP/Samba shared Time Machine server, but from a local USB drive). I am sure there are Windows products that claim to do something similar, but an enticing thing is that Time Machine is pretty much supported &#8216;out of the box&#8217;. </p>
<p>My upgrade was not all good. I have several vmware fusion guests on my Macbook, and when these were restored on the 500GB drive, all of them seemed to have very scary filesystem errors (the ones you get when there&#8217;s been some serious corruption). I thought maybe this was to do with Time Machine, but I ended up using my crazy rsync backups to restore from as well &#8230; and I still had the same filesystem errors. In the end, I booted back up off the 160GB drive in the macbook, and went through every Vmware guest and told them to power down (pretty much all of them were just &#8216;suspended&#8217;), then I did my rsync backup again, and restored them with the 500GB drive inside. And now they all work and have no filesystem errors. Obviously there is some strange inconsistency that occurs with the guest &#8216;state&#8217; information during the upgrade to Snow Leopard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/upgrading-to-snow-leopard/2010/04/27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverting LVM snapshots</title>
		<link>http://www.kernelcrash.com/blog/reverting-lvm-snapshots/2009/12/11/</link>
		<comments>http://www.kernelcrash.com/blog/reverting-lvm-snapshots/2009/12/11/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 23:31:11 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=492</guid>
		<description><![CDATA[One thing that would be nice to have in linux LVM is the ability to take a snapshot of a logical volume, make some changes then &#8216;roll back&#8217; to the state preserved in the snapshot. If you look at the current set of lv commands on most linux distros there is no such option to [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that would be nice to have in linux LVM is the ability to take a snapshot of a logical volume, make some changes then &#8216;roll back&#8217; to the state preserved in the snapshot. If you look at the current set of lv commands on most linux distros there is no such option to &#8216;revert to snapshot&#8217;. Now, that I&#8217;m using KVM more, the ability to &#8216;rollback&#8217; a virtual machine installed on a logical volume would be particularly handy.</p>
<p>Well it turns out you can &#8216;revert to snapshot&#8217;, but you just have to use a non-standard tool and some dmsetup commands.  The tool is called dm-merge. Go to the <a href="http://repo.or.cz/w/dm-merge.git">dm-merge git repository</a> or <a href="http://repo.or.cz/w/dm-merge.git?a=snapshot;h=HEAD;sf=tgz">download the latest dm-merge snapshot</a> . dm-merge just looks at the &#8216;changed blocks&#8217; and pushes the old copies of them back into the original logical volume.  You&#8217;ll need to compile the dm-merge program (just do a &#8216;make&#8217;). dm-merge comes with some doco. It explains two possible methods; reverting with an active logical volume OR reverting with an inactive one. In the former case you&#8217;re attempting to revert to a snapshot when the filesystem you&#8217;re trying to change is already mounted. I imagine that to be a very dangerous activity (but I guess it works well enough if there is little filesystem activity). I chose the latter (safer) method. </p>
<p>Here are my notes on the procedure. If this were a document for work, I would a) tell people they were crazy to even attempt this and b) if you&#8217;re still crazy make sure you make a backup. At least try this procedure out on a test machine first. The possibility of screwing your disk by virtue of a small typing mistake is quite high. </p>
<p>In the example below, I had a logical volume /dev/vgz/lvubuntu910full32bit that I was using as my hda drive in a KVM guest machine, and I had created a snapshot &#8216;snap1&#8242; beforehand;</p>
<blockquote><pre>
   lvcreate --size 1G --snapshot --name snap1 /dev/vgz/lvubuntu910full32bit
</pre>
</blockquote>
<p>One important thing I realised recently is that the amount of space you allocate to a snapshot (eg. 1GB in the example above) can actually be resized without killing the snapshot (eg. lvresize -L 20G /dev/vgz/snap1)</p>
<p>Most of the following is a rehash of what is in the README that comes with dm-merge. I&#8217;m only referring to the method involving an inactive logical volume</p>
<blockquote><pre>
# Firstly, shut down access to your logical volume (ie. /dev/vgz/vgzlvubuntu910full32bit).
   Since this is a KVM guest, all I did was shut down the guest. If you're doing this on a
   mounted logical volume then you should umount it.

# Duplicate the tables of the logical volumes and snapshot storage (note the use of the
   special -real and -cow suffixes)

dmsetup table vgz-lvubuntu910full32bit-real |dmsetup create tmplv
dmsetup table vgz-snap1-cow |dmsetup create tmpcow

# Deactivate the main lv

lvchange -a n /dev/vgz/lvubuntu910full32bit

# flush buffers

blockdev --flushbufs /dev/mapper/{tmplv,tmpcow}

# Do a dm-merge test run. You see lots of lines that start with 'dd' and a summary at the bottom.

dm-merge -i /dev/mapper/tmpcow -o /dev/mapper/tmplv -vd
...
dd of="/dev/mapper/tmplv" seek=2135444 if='/dev/mapper/tmpcow' iflag=direct skip=8275 count=1 bs=8b
dd of="/dev/mapper/tmplv" seek=2135445 if='/dev/mapper/tmpcow' iflag=direct skip=8276 count=1 bs=8b
dd of="/dev/mapper/tmplv" seek=2135446 if='/dev/mapper/tmpcow' iflag=direct skip=8277 count=1 bs=8b
dd of="/dev/mapper/tmplv" seek=5056466 if='/dev/mapper/tmpcow' iflag=direct skip=8278 count=1 bs=8b
dd of="/dev/mapper/tmplv" seek=5056467 if='/dev/mapper/tmpcow' iflag=direct skip=8279 count=1 bs=8b
Found 8246 exceptions of chunksize 4096, total size 33775616 bytes (32984 KiB, 32.211 MiB, 0.031 GiB).

# Do it for real. You get a couple of lines of output plus the same summary line.

 dm-merge -i /dev/mapper/tmpcow -o /dev/mapper/tmplv -f

Artificial sleep (1 second)
Found a proper MAGIC header: 0x70416e53
valid = 1
version = 1
chunk_size = 8 (4096 bytes)
Found 8246 exceptions of chunksize 4096, total size 33775616 bytes (32984 KiB, 32.211 MiB, 0.031 GiB).

# Flush buffers again

blockdev --flushbufs /dev/mapper/{tmplv,tmpcow}

# Remove the tmp lv's. These are just references to data, so it won't delete your real data.

dmsetup remove tmplv
dmsetup remove tmpcow

# Activate it

lvchange -a y /dev/vgz/lvubuntu910full32bit
</pre>
</blockquote>
<p>Now try to start your KVM guest again &#8230; or remount it to check it out and confirm that it&#8217;s reverted to the original state. If you snapshotted a live KVM guest or a mounted filesystem, then you may find that your KVM guest will do a filesystem check on boot (fair enough), or you may need to run fsck on your filesystem before you can mount it.</p>
<p>Don&#8217;t forget to remove the snapshot you initially made (eg. lvremove /dev/vgz/snap1)</p>
<p>One thing to note is the &#8216;revert to snapshot&#8217; capability has been &#8216;coming&#8217; for a while in mainstream LVM. There&#8217;s a <a href="http://lwn.net/Articles/363575/">recent mention on LWN</a> about it</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/reverting-lvm-snapshots/2009/12/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So I bought an R60</title>
		<link>http://www.kernelcrash.com/blog/so-i-bought-an-r60/2009/12/11/</link>
		<comments>http://www.kernelcrash.com/blog/so-i-bought-an-r60/2009/12/11/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 23:28:24 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=470</guid>
		<description><![CDATA[For some time now, my old Thinkpad T42 has been running as a lightweight server at home. Some people think I&#8217;m a bit mad using a laptop as a server, but my vague reasons are a) they&#8217;re generally quiet, b) they don&#8217;t use a heap of power, c) the battery is in some ways a [...]]]></description>
			<content:encoded><![CDATA[<p>For some time now, my old Thinkpad T42 has been running as a lightweight server at home. Some people think I&#8217;m a bit mad using a laptop as a server, but my vague reasons are a) they&#8217;re generally quiet, b) they don&#8217;t use a heap of power, c) the battery is in some ways a built-in UPS and d) whenever I&#8217;ve tried to take a regular desktop system and make it quiet I end up spending lots of $$$ on various quiet fans and power supplies only to be moderately satisfied with the results. To me, an old 2nd hand laptop is generally better value. Of course, you can&#8217;t fit many disks into laptops, but with the T42  I discovered that even though the primary drive has to be a 2.5&#8243; IDE drive,  you can fit a large 2.5&#8243; sata drive into them by buying a sata HDD caddy (look on ebay).</p>
<p>Anyway,  I have Debian Lenny on the T42 with several OpenVZ containers for things like Asterisk and a mercurial server. In addition it&#8217;s a streaming server, as I have two internal drives plus a large external 3.5&#8243; USB drive.</p>
<p>The T42 is getting old, and I&#8217;d like to be able to run <a href="http://www.linux-kvm.org/page/Main_Page">KVM</a> on it &#8230; because basically  I like KVM, but KVM needs a <a href="http://en.wikipedia.org/wiki/Intel_Virtualization_Technology">VT</a> capable CPU. So I kept my eye out for a cheap 2nd hand VT capable laptop. I ended up buying a 2nd hand Thinkpad R60. This is probably one of the ugliest Thinkpads ever made which might explain the good price I got it for. I certainly wouldn&#8217;t buy one to lug around, but sitting on a desk at home quietly running a number of VMs is all I really wanted. It has a T2400 core duo (not core 2) cpu. Technically it is &#8216;VT capable&#8217;, but its a bit of an odd one (which probably applies to the T2500, T2600 etc) in that its not a 64 bit CPU like most other VT cpus. Other than being ugly and having an odd CPU, this R60 does have a lot going for it; 3GB of RAM, DVD burner, firewire, wifi, bluetooth, cardbus and expresscard slots (so I could add an esata expresscard device to add some highspeed desktop drives later on). And the HDD caddies I had for my T42 also fit in the R60.</p>
<p>I originally tried Ubuntu 9.10 on the R60, but the version of qemu they use in combination with KVM actually does not work properly on this old T2400 CPU. I could seemingly install a guest OS, but after reboot I had errors galore. Something to do with the &#8216;No execute&#8217; bit I think. Anyway, this was yet another case of ubuntu quickly irritating me, so I ended up installing something else. Back to Debian Lenny. And of course VM&#8217;s work fine under Lenny and it&#8217;s older KVM and older qemu tools. </p>
<p>So far I&#8217;ve just run debian lenny 32 bit and Windows 2008 R2 32 bit in some KVM VMs. Both seem to run quite well. The laptop has 3GB of ram, so I can run quite a few VMs at the same time OK.  I&#8217;ve migrated my asterisk installation from the openVZ container it was in on my T42 to a KVM VM on the R60. It works quite well.</p>
<p>One thing that does bug me about using KVM is the lack of easy to use snapshots. ESXi spoils you in the simplicity of it&#8217;s snapshots on running or shutdown VMs. You can use them for backups or easily roll back to them. However, KVM has a haphazard collection of tools that don&#8217;t quite do the same thing. virt-manager offers no option for snapshots. If you use virsh instead it does have a &#8216;save&#8217; option to snapshot a machine &#8230; but it seems to always shut the machine down when it runs. If you don&#8217;t use libvirtd to manage your VMs and instead use kvm directly, then you can interact directly with the qemu monitor of a VM and it has a savevm option which does something akin to a snapshot, but everytime I&#8217;ve tried it on a live VM, it pauses the VM for several minutes which is somewhat annoying. The closest thing to ESXi snapshots that I can think of is to use logical volumes for the VM&#8217;s virtual disk, then use LVM snapshots to create snapshots of them. These aren&#8217;t full &#8216;state&#8217; snapshots that include a ram snapshot etc, but are probably good enough for my purposes. The tricky part is rolling back to a snapshot which is not really supported with logical volumes out of the box, but you can do it with something like the dm-merge tool.</p>
<p>I also tried Fedora 12 on the R60. The motivation was that the version of KVM on Debian Lenny is old, and Fedora 12 has quite a number of new features of KVM including better qcow2 performance and something that looks for identical memory pages in VMs to reduce memory usage. This latter feature appears as some ksmd daemon that seems to hog 50% of one CPU. Very annoying, so I killed it. I was hoping that the qcow2 enhancements might solve my &#8216;snapshots&#8217; issue, but so far it doesn&#8217;t look like it. I need to investigate more. In the meantime, I&#8217;ll go back to Debian Lenny on the R60.</p>
<p>Of course, I did try running ESXi on the R60. ESXi 3.5u4 seemingly worked perfectly on it. I didn&#8217;t't need any fancy DIY network drivers. It just picked up the internal broadcom gigabit and was able to see the two internal drives. The only problem is that I get a Purple screen of death when I try do a shutdown (some error to do with ACPI, and setting acpi=off in the kernel options does not help). However, if you tell ESXi to reboot it reboots as expected (UPDATE: I have just tried ESXi 3.5u5 &#8230; and is has the same purple screen when you attempt a shutdown). I didn&#8217;t bother trying ESXi 4, as I am pretty sure that needs a 64 bit CPU.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/so-i-bought-an-r60/2009/12/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time for an upgrade</title>
		<link>http://www.kernelcrash.com/blog/time-for-an-upgrade/2009/11/15/</link>
		<comments>http://www.kernelcrash.com/blog/time-for-an-upgrade/2009/11/15/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 06:12:34 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=451</guid>
		<description><![CDATA[My main linux box here is about 3 years old now. The case is older, but I bought the cpu, motherboard, graphics card and some of the ram when the first Core 2 Duo&#8217;s were announced. It was expensive at the time, but it was well worth it. I bought a 1.86GHz E6300 C2D (not [...]]]></description>
			<content:encoded><![CDATA[<p>My main linux box here is about 3 years old now. The case is older, but I bought the cpu, motherboard, graphics card and some of the ram when the first Core 2 Duo&#8217;s were announced. It was expensive at the time, but it was well worth it. I bought a 1.86GHz E6300 C2D (not to be confused with the more recent 2.8GHz Pentium E6300 that Intel make).</p>
<p>The motherboard was a <a href="http://asus.com/product.aspx?P_ID=gD1ljCkUWy1Y3yMG&amp;templete=2">Asus P5LD2</a> which was one of the few &#8216;cheaper&#8217; socket 775 boards available at the time that were compatible with the (then) new Core 2 Duos. It&#8217;s an interesting board as it has three IDE channels (ie. up to 6 IDE drives) and four SATA II interfaces. It uses a 945P chipset which doesn&#8217;t have a great reputation for overclocking. However, I could get the E6300 to run at 2.33GHz reliably which was ok.</p>
<p>More recently I&#8217;ve added more ram to the board ( four 1GB DIMMS in total) and discovered the problem of some of these older socket 775 chipsets. They can really only have 3GB maximum RAM. I thought this was just a 32bit OS problem, but 64 bit OS&#8217;s have the same problem with this board. Basically the chipset can only address 4GB of memory, and quite large chunks of memory are mapped for various IO purposes, which is made worse by certain types of cards (I think I get 3.5GB if I pull out my TV tuner card, 3 or 3.2GB with it plugged in). I know some older motherboards have an option for remapping a memory hole &#8230; but even on the latest BIOS, I don&#8217;t have such an option.</p>
<p>Also, the board is limited to mostly older core 2 duo chips, and quad cores are definitely a no go.</p>
<p>So, like any tech nutter, I&#8217;ve been researching the best &#8216;bang for buck&#8217; upgrade. All the Intel socket 1156  i5/i7 chips came out a month or two ago and they do indeed look quite interesting. The i5 750 is quad core, but all the i7 models have a newer form of hyperthreading so it is a bit like getting &#8217;8 cores&#8217;. To upgrade my system to i5/i7 there is quite a bit of expense (close to NZ$1000 just for an i7 860, motherboard and 4GB of ram), so I wondered exactly how much faster they really are. A good tool I found is the <a href="http://www.anandtech.com/bench">anandtech bench (beta)</a>.</p>
<p>With the Anandtech bench you can compare benchmarks between any two CPUs that they happen to have reviewed. A good test I thought would be to compare the i5 750 against an older quad core like the Q8400. The i5 is definitely faster in most tests, but in some of the tests that I&#8217;m interested in (like the x264 tests) it&#8217;s not &#8216;amazingly&#8217; faster.</p>
<p>So feeling quite &#8216;cheap&#8217; I thought I&#8217;d just upgrade my motherboard to a newer socket 775 board. That way I could keep my DDR2 ram, keep my core2duo and immediately get a full 4GB of ram, plus the ability to get a quad core core2duo later on. Sounded reasonable at the time. So I did some research and ended up coming home with a <a href="http://www.gigabyte.com.tw/Products/Motherboard/Products_Overview.aspx?ProductID=2951">Gigabyte EP45-UD3LR</a> board.</p>
<p>Supposedly the EP45-UD3LR can handle 16GB of ram &#8230; but until someone makes cheap 4GB DDR2 DIMMs, I&#8217;ll be happy with 4GB. It&#8217;s a full ATX board and has no onboard gfx. Just sound and the usual plethora of usb and sata ports. Now, I usually run linux on this system, but a secondary reason for getting this board is that these &#8216;EP45&#8242; boards are very popular in the Hackintosh community for turning regular PC&#8217;s into &#8216;hacked&#8217; OSX systems. I don&#8217;t really need another Mac, but all this hackintosh stuff is quite an interesting diversion in my pursuit of time wasting activities.</p>
<p>So for the past few weekends I&#8217;ve been playing with installing Snow Leopard on this thing (I actually bought the retail DVD for it). It&#8217;s still a far from simple process, that requires reading copious Howto&#8217;s and forum posts on InsanelyMac and other related sites. There are a number of complications; a) All the Gigabyte EP45 boards are slightly different, so while lifehacker.com might publish some nice howto&#8217;s for someone using a EP45-UD3P motherboard. My EP45-UD3LR is not &#8216;quite&#8217; the same b) There are different &#8216;approaches&#8217; you can take that have bizarre names that unless you&#8217;ve been trawling forums for quite some time you won&#8217;t understand; you can use hacked kexts, you can modify the DSDT, you can &#8216;inject&#8217; EFI strings and seemingly you can use a combination of these .. though I&#8217;m not entirely sure. I think what&#8217;s happened is that the hackintosh community is obviously trying to increase the probability that when you do an Apple &#8216;Software Update&#8217; that includes a kernel update (eg 10.6 to 10.6.1) that your machine doesn&#8217;t die painfully. I got the idea that  modding the DSDT instead of injecting EFI strings somehow makes things &#8216;better&#8217; and a big goal is to reduce the necessity for hacked kexts.</p>
<p>So does it work? Yes it does. A lot better than I thought it would even though I have had intermittent crashes (the screen goes dark and you get a message telling you to hold in the power button) which I think I&#8217;ve finally resolved (my Nvidia card seems to hate the 64 bit kernel drivers, but works OK booting in 32 bit mode). I won&#8217;t go into all the detail of what I did to build the thing, but here are my key points;</p>
<ul>
<li>I used the <a href="http://lifehacker.com/5351485/how-to-build-a-hackintosh-with-snow-leopard-start-to-finish">lifehacker.com &#8216;How to build a Hackintosh with Snow Leopard Start to Finish&#8217;</a> article (the original article, not the followup)</li>
<li>I also referred to this <a href="http://www.insanelymac.com/forum/index.php?showtopic=187677">EP45-UD3R guide on insanelymac</a>. Especially the bits about setting the UUID in /Extra/smbios.plist and the PlatformUUID.kext. I found I couldn&#8217;t install Chameleon onto the hard drive until I got the UUID fixed</li>
<li>I have an old GeForce 7300LE card with 128MB of RAM. This card is not listed in EFIStudio, but originally I just selected GeForce 7300 GT 256MB which seemed to work OK. I also noticed the Front Row would not work at all unless I had something like the following in /Extra/com.apple.Boot.plist:
<pre>    &lt;key&gt;Graphics Mode&lt;/key&gt;
    &lt;string&gt;1280x1024x32&lt;/string&gt;</pre>
</li>
<li>I used the &#8216;SL Pack&#8217; that is referred to on various insanelymac howtos, especially the Extras folder it tells you to start with. ie. I didnt use the one that the LifeHacker article refers to. Though I did originally use the lifehacker one. I have no idea if there is any difference.</li>
<li>To get my ALC888 sound to work required quite a few steps. There&#8217;s a really useful comment by Dith close to the bottom of <a href="http://www.insanelymac.com/forum/lofiversion/index.php/t181509.html">this forum page</a>. I followed the steps that start with &#8216;Redid my whole Snow Leopard installation&#8217;. And then I grabbed the LegacyHDA.kext that is at this path in the SL Pack and copied it into /Extra/Extensions replacing the one I already had.;
<pre>SL Pack/DSDT Stuff/How to Patch DSDT /series of LegacyHDA 888 (ALC888)/3out2in HDA headphone/LegacyHDA.kext</pre>
</li>
<li>I manually enable QE/CI (well I think I did) by sudo&#8217;ing to root and running;
<pre>defaults write /Library/Preferences/com.apple.windowserver GLCompositor -dict tileHeight -int 256 tileWidth -int 256</pre>
</li>
<li>I tended to run &#8216;Kext Utility&#8217; between a lot of the above steps. Never sure if it makes much difference.</li>
<li>I later found that OSX86Tools can generate the EFI string for my GeForce 7300LE 128MB card. So I used that in my /Extra/com.apple.Boot.plist hoping that it would fix my intermittent crash problem. It didn&#8217;t fix the crashes, but it did make me feel warm and fuzzy.</li>
<li>I found that I could consistently crash the machine by running &#8216;Chess&#8217; and just moving the mouse. Obviously Apple knows that I&#8217;m not very good at Chess, and was saving me some misery &#8230; These crashes were with a 64 bit kernel. Then I tried booting with a 32 bit kernel and Chess works fine, and so far no crashes (though I still can&#8217;t play Chess very well). I&#8217;m using Chameleon RC3 and had to put &#8216;arch=i386&#8242; in the /Extra/com.apple.Boot.plist file like so;
<pre>        &lt;key&gt;Kernel Flags&lt;/key&gt;
	&lt;string&gt;arch=i386&lt;/string&gt;</pre>
</li>
</ul>
<p>I&#8217;ve since updated from 10.6 to 10.6.1 with no dramas. The upgrade to 10.6.2 had some minor hitches in that you need to remove the older SleepEnabler.kext. See <a href="http://netkas.org/?p=315">here</a> for more info.</p>
<p>And of course, the new motherboard works fine running linux too!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/time-for-an-upgrade/2009/11/15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>btrfs and 2.6.31</title>
		<link>http://www.kernelcrash.com/blog/btrfs-and-2-6-31/2009/10/03/</link>
		<comments>http://www.kernelcrash.com/blog/btrfs-and-2-6-31/2009/10/03/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 02:26:02 +0000</pubDate>
		<dc:creator>kernel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kernelcrash.com/blog/?p=409</guid>
		<description><![CDATA[I&#8217;d read about quite a few new features in the linux 2.6.31 kernel,so I thought I&#8217;d download the official source for 2.6.31 from kernel.org and build a custom kernel on my Debian Lenny 64 bit core2duo system. Thats the usual make-kpkg melarchy which takes an eternity. It took me a while to get 2.6.31 to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d read about quite a few new features in the linux 2.6.31 kernel,so I thought I&#8217;d download the official source for 2.6.31 from kernel.org and build a custom kernel on my Debian Lenny 64 bit core2duo system. Thats the usual make-kpkg melarchy which takes an eternity.</p>
<p>It took me a while to get 2.6.31 to boot properly. I have an older nvidia card in this system, and the default setup had the kernel loading the nvidiafb module &#8230; which does not seem to work with my system (I just get a black or gray screen). Fortunately I could still ssh in from another box. It took me a while to work out how to properly disable nvidiafb, which ended up being somehting like;</p>
<blockquote><pre>
cd /etc
mv modules.conf modules.conf.orig
cd modprobe.d
# Edit the blacklist file and add 'blacklist nvidiafb' to the end.
vi blacklist
# now update the initrd
update-initramfs -u
</pre>
</blockquote>
<p>Also, in order to get X windows working I ended up downloading the driver from nvidia.com ( I used NVIDIA-Linux-x86_64-185.18.36-pkg2.run).</p>
<p>Once I had it booted (properly) off 2.6.31, I thought I&#8217;d have a look at btrfs. It&#8217;s a new filesystem for linux which is meant to be a lot like ZFS, but it&#8217;s not quite there yet in the stability department. However, I thought I read somewhere that the version included in 2.6.31 was &#8216;pretty good&#8217;, so it was worth a look. What I wanted to try was to have a btrfs root partition.</p>
<p>The first thing was to recompile my kernel again. Btrfs seemed to be turned off by default if you&#8217;re doing the make-kpkg stuff. So my setup process was something like;</p>
<blockquote><pre>
cd /usr/src
tar xvjf /tmp/linux-2.6.31.tar.bz2
mv linux linux.orig
ln -s linux-2.6.31 linux
cd linux
make-kpkg clean
make menuconfig  <--- make sure you go to filesystems and enable btrfs as a module)
fakeroot make-kpkg --initrd --append-to-version=-custom2 kernel_image kernel_headers
# Wait 10 years
cd ..
dpkg -i linux-headers-2.6.31-custom2_2.6.31-custom2-10.00.Custom_amd64.deb
dpkg -i linux-image-2.6.31-custom2_2.6.31-custom2-10.00.Custom_amd64.deb
</pre>
</blockquote>
<p>Now my plan was to make a copy of my root fs into a btrfs partition and boot off that. I have /boot as an ext2 partition, and my normal lenny root fs is on a logical volume as an ext3 fs. I thought I'd take a snapshot of the ext3 rootfs and copy it into a btrfs logical volume and boot off that. But the first thing to do is to get the btrfs user space tools;</p>
<blockquote><pre>
git clone git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
cd btrfs-progs-unstable
make
make install
</pre>
</blockquote>
<p>Then setup the logical volumes and copy the data (NB: You might have to do a 'modprobe libcrc32c ; modprobe btrfs' first). For reference, I use a volume group called vgz which will undoubtedly be different to whatever system you might have.</p>
<blockquote><pre>
mkdir /tmp/src
mkdir /tmp/dest
lvcreate -L 1G -s -n snap1 /dev/vgz/lvlenny64root
mount /dev/vgz/snap1 /tmp/src
lvcreate -L 12G -n lvlenny64btrfsroot /dev/vgz
mkfs.btrfs /dev/vgz/lvlenny64btrfsroot
mount -t btrfs /dev/vgz/lvlenny64btrfsroot /tmp/dest
cd /tmp/src
find . -print | cpio -dumpv /tmp/dest
cd /
# You'll need to edit the fstab to change the root device and filesystem type. For example:
#    /dev/mapper/vgz-lvlenny64btrfsroot /               btrfs    errors=remount-ro 0       1
vi /tmp/dest/etc/fstab
umount /tmp/dest
lvremove /dev/vgz/snap1
umount /tmp/src
</pre>
</blockquote>
<p>Now we need to convince your initrd to load the btrfs modules (this is debian/ubuntu/whatever specific). I edited /etc/initramfs-tools/modules and added these lines in;</p>
<blockquote><pre>
libcrc32c
zlib_deflate
crc32c
btrfs
</pre>
</blockquote>
<p>And then you need to run <b>update-initramfs -u</b><br />
At this point I had to do some fiddling with /boot/grub/menu.lst. I just made an extra stanza in the file that looked like;</p>
<blockquote><pre>
title           BTRFS Debian GNU/Linux, kernel 2.6.31-custom2
root            (hd1,1)
kernel          /vmlinuz-2.6.31-custom2 root=/dev/mapper/vgz-lvlenny64btrfsroot rootfstype=btrfs ro
initrd          /initrd.img-2.6.31-custom2
</pre>
</blockquote>
<p>Obviously don't just copy this for your own setup, as the root line will be different and possibly some other stuff. Admitedly, I am probably missing something with this setup as when I go to boot off my btrfs root partition, I get kernel boot message up to the point where it's mounting the root filesystem, then just sits there for 5 minutes before eventually mounting it ok and continuing on. It's all a bit odd (UPDATE:  This long pause is to do with the initramfs fstype and/or vol_id tools not being able to recognise btrfs filesystems. Eventually someone will update those tools, but until then you might want to edit /usr/share/initramfs-tools/scripts/local, hack the get_fstype function and then run update-initramfs-u. I'll put some notes at the <a href=#btrfs2631update1>bottom of the post</a>).</p>
<p>Anyway, so I got a bootable system with btrfs. The first thing I wanted to try was snapshots, so I duely did something like;</p>
<blockquote><pre>
btrfsctl -s snap1 /
</pre>
</blockquote>
<p>When I first did that I thought it would create a snap1 directory under the / (ie. root) of my root fs. It didn't. It actually created a snap1 directory in the directory I was currently in. So within that directory was an intact snapshot of my root filesystem. Of course the first thing you want to do is delete the snapshot ... which in 2.6.31 is a 'future feature'. You can try and rm -rf the snapshot directory ... but I always got some circular file reference errors and it took ages as well. In fact I took a few snapshots as I played around, then left it running over night. In the morning it told me my filesystem was full and the hard drive light was permanantly on. Odd.</p>
<p>Fortunately, the ability to delete snapshots has actually been added to btrfs. You just need an even more recent kernel ... or what I did was to just check out the btrfs kernel tree (I went to <a href="http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-unstable.git;a=summary">here</a> and clicked 'tree' up the top, then 'fs', then 'btrfs' then the 'snapshot' button near the top) and shove it into my 2.6.31 kernel and go through the whole make-kpkg thing again and try booting again (actually I did a few more steps and just deleted my whole btrfs example logical volume and created a new one with no snapshots).</p>
<p>Now with my '2.6.31 and a bit' kernel I can make a snapshot (I have now learned that putting a leading / in front of the snapshot name is probably sensible);</p>
<blockquote><pre>
btrfsctl -s /snap1 /
</pre>
</blockquote>
<p>And so if I cd /snap1 I can access my snapshot. But more importantly I can delete it;</p>
<blockquote><pre>
btrfsctl -D snap1 /
</pre>
</blockquote>
<p>The arguments to the 'btrfsctl -D' seem to be the snapshot name followed by the directory in which it was made. </p>
<p>I also found <a href="http://blogs.igalia.com/aperez/2008/06/more-btrfs-goodness-snapshots/">this post on root'ing the net</a> that shows how you can mount the snapshot using the mount command (ie. in addition to the snapshot appearing as a subdirectory);</p>
<blockquote><pre>
mount -o subvol=snap1 /dev/vgz/lvlenny64btrfsroot /mnt
</pre>
</blockquote>
<p>Most stuff on btrfs indicates that subvols and snapshots are treated the same. If you create a new snapshot you get a copy of what you snapshotted. Creating a new subvol gives you an empty directory which I assume can be controlled separately, but uses the same pool of disk resources of my main btrfs filesystem. I'm not entirely sure. There is an option to the btrfsctl command which can resize a 'something' but I'm not too sure exactly what it does. I tried resizing down and df doesn't reflect any difference, but doing a btrfs-show did show some change. At the moment there aren't really any commands to list snapshots or show usage. There is a btrfs-debug-tree command that spits out reams of info ... and does mention my snapshots deep within it.</p>
<p>btrfs can apparently do RAID1, RAID0 and RAID10. I like that redundancy is a feature of the filesystem. I've never really understood why LVM2 for linux has no redundancy features (and the mirroring capability it does have is not very useful). I haven't tried any of the btrfs RAID features yet.</p>
<p>So that's all I've looked at so far.  One of the key features of ZFS that I'd really like to see in btrfs is 'rollback to snapshot'. This is such an incredibly useful feature in a fast paced IT environment. Given that btrfs is a copy-on-write filesystem, I am hoping they put rollback in at some point.</p>
<p>Honestly I haven't tested it enough to determine how stable it is. It seems fine so far, but this is not a server type machine.</p>
<p><a name=btrfs2631update1>UPDATE</a>: re getting rid of the long pause on boot.<br />
I edited /usr/share/initramfs-tools/scripts/local, and added the extra lines shown below. Be warned, this is an awful 'hack' that assumes that any filesystem type that is not recognised is 'btrfs'. Once you've updated the file you'll need to run update-initramfs -u</p>
<blockquote><pre>
get_fstype ()
{
        local FS FSTYPE FSSIZE RET
        FS="${1}"

        # vol_id has a more complete list of file systems,
        # but fstype is more robust
        eval $(fstype "${FS}" 2> /dev/null)
        if [ "$FSTYPE" = "unknown" ] &#038;&#038; [ -x /lib/udev/vol_id ]; then
                FSTYPE=$(/lib/udev/vol_id -t "${FS}" 2> /dev/null)
        fi
        RET=$?

        if [ -z "${FSTYPE}" ]; then
                FSTYPE="unknown"
        fi

# Hack for my btrfs root. Terrible hack
        if [ "${FSTYPE}" = unknown ];then
                FSTYPE=btrfs
                RET=0
        fi
# End of my hack

        echo "${FSTYPE}"
        return ${RET}
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kernelcrash.com/blog/btrfs-and-2-6-31/2009/10/03/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

