<?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>BrainDeadProjects.com</title>
	<atom:link href="http://www.braindeadprojects.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.braindeadprojects.com/blog</link>
	<description>A place for low-grade evil.</description>
	<lastBuildDate>Thu, 24 Nov 2011 02:28:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OpenWRT on the MikroTik RouterBoard 493AH</title>
		<link>http://www.braindeadprojects.com/blog/what/openwrt-on-the-mikrotik-routerboard-493ah/</link>
		<comments>http://www.braindeadprojects.com/blog/what/openwrt-on-the-mikrotik-routerboard-493ah/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 02:28:59 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[MikroTik]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[What?!]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1536</guid>
		<description><![CDATA[I recently came across a MikroTik RouterBoard 493AH at work. We&#8217;d acquired the device among numerous other pieces of equipment from a now defunct wireless ISP. The 493AH features 9 ethernet ports, can accept POE on its WAN interface, has 64M NAND,  128M RAM, and can support 3 mini-PCI cards. Configuration can be performed via [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a <a title="RouterBoard 493AH" href="http://routerboard.com/RB493AH" target="_blank">MikroTik RouterBoard 493AH</a> at work. We&#8217;d acquired the device among numerous other pieces of equipment from a now defunct wireless ISP.</p>
<div id="attachment_1545" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/IMAG0694.jpg"><img class="size-medium wp-image-1545" title="RouterBoard 493AH" src="http://www.braindeadprojects.com/blog/wp-content/IMAG0694-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">It smells of Goo-Gone and looks to have dandruff.</p></div>
<p>The 493AH features 9 ethernet ports, can accept POE on its WAN interface, has 64M NAND,  128M RAM, and can support 3 mini-PCI cards. Configuration can be performed via a serial interface and there is an external power connector available if POE isn&#8217;t used.</p>
<p>The device itself wouldn&#8217;t boot, only hang at the RouterBoot bootloader. Attempts to boot the NAND image failed, but the bootloader gives an easy option for downloading an image to it via <a title="TFTP" href="http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol" target="_blank">TFTP</a>.</p>
<div id="attachment_1571" class="wp-caption aligncenter" style="width: 226px"><a href="http://www.braindeadprojects.com/blog/wp-content/logo_mikrotik.jpg"><img class="size-full wp-image-1571  " title="MikroTik Logo" src="http://www.braindeadprojects.com/blog/wp-content/logo_mikrotik.jpg" alt="MikroTik Logo" width="216" height="216" /></a><p class="wp-caption-text">A brand that&#39;s loved by WISPs</p></div>
<p>Looking around, it appears the 493AH is an <a title="Atheros7161" href="http://www.qca.qualcomm.com/networking/brand.php?brand=4&amp;product=68" target="_blank">Atheros AR7161</a> .. an architecture readily supported under <a title="OpenWRT" href="https://openwrt.org/" target="_blank">OpenWRT</a>. Sure, I could just re-install <a title="RouterOS" href="http://www.qca.qualcomm.com/networking/brand.php?brand=4&amp;product=68" target="_blank">RouterOS</a>&#8230; but let&#8217;s do that later.</p>
<p>To install OpenWRT to the 493AH, first format the NAND. This can easily be done via the bootloader (option e):</p>
<div id="attachment_1580" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/formatNAND.png"><img class="size-medium wp-image-1580" title="FormatNAND" src="http://www.braindeadprojects.com/blog/wp-content/formatNAND-300x189.png" alt="FormatNAND" width="300" height="189" /></a><p class="wp-caption-text">Waxing the memory</p></div>
<p>Next, use subversion to check out the Backfire version of OpenWRT:</p>
<blockquote><p>mkdir ~/svn/</p>
<p>cd ~/svn/</p>
<p>svn co svn://svn.openwrt.org/openwrt/branches/backfire backfire</p></blockquote>
<p>Building the image is fairly easy, all configuration is done via a &#8220;<em>make menuconfig</em>&#8220;. First, we&#8217;ll build a small <a title="InitRAMFS" href="http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Introducing-initramfs-a-new-model-for-initial-RAM-disks/" target="_blank">initramfs</a>. This will give us a tiny environment to boot into the device and later install our kernel with.</p>
<p>Ensure that you&#8217;ve selected the AR71xx target architecture&#8230;</p>
<div id="attachment_1548" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/platformtarget.png"><img class="size-medium wp-image-1548" title="PlatformTarget" src="http://www.braindeadprojects.com/blog/wp-content/platformtarget-300x189.png" alt="" width="300" height="189" /></a><p class="wp-caption-text">Building an AR71XX System</p></div>
<p>Next, I opt for the default profile (to give me all the modules I should need)</p>
<div id="attachment_1549" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/targetprofile.png"><img class="size-medium wp-image-1549" title="TargetProfileSelection" src="http://www.braindeadprojects.com/blog/wp-content/targetprofile-300x189.png" alt="TargetProfileSelection" width="300" height="189" /></a><p class="wp-caption-text">I demand everything!</p></div>
<p>And finally, select the build of a ramdisk image:</p>
<div id="attachment_1550" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/ramdiskbuild.png"><img class="size-medium wp-image-1550" title="BuildRamDisk" src="http://www.braindeadprojects.com/blog/wp-content/ramdiskbuild-300x189.png" alt="BuildRamDisk" width="300" height="189" /></a><p class="wp-caption-text">Fun with arrow keys and a spacebar.</p></div>
<p>After you&#8217;ve made your selections, exit saving your changes, and run <em>make</em>. The build itself will take some time, but when you&#8217;re finished you&#8217;ll have the first key ingredient &#8211; a basic root filesystem embedded into the kernel. This image is essentially a &#8220;Live CD&#8221; that we&#8217;ll use to install our real kernel.</p>
<p>As with all of the images you create, you&#8217;ll find them under ~/svn/backfire/bin/ar71xx/ Our newly created image is <strong>openwrt-ar71xx-vmlinux-initramfs.elf</strong></p>
<p>Next, we&#8217;ll want to build our actual system. To do this, re-run <em>make menuconfig</em> and select the packages that you wish to compile and include in your firmware image. After you&#8217;ve made all of your selections, change your Target Image to squashfs and exit saving your changes.</p>
<div id="attachment_1552" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/squashfsbuild.png"><img class="size-medium wp-image-1552" title="SquashFSBuild" src="http://www.braindeadprojects.com/blog/wp-content/squashfsbuild-300x189.png" alt="SquashFSBuild" width="300" height="189" /></a><p class="wp-caption-text">Planting a SquashFS Garden</p></div>
<p>A quick <em>make</em> later, and we now have a working rootfs and kernel &#8211; in addition to our initramfs to install the system with:</p>
<p><strong><strong>openwrt-ar71xx-vmlinux-initramfs.elf </strong></strong>(Our temporary kernel)<br />
<strong>openwrt-ar71xx-vmlinux.elf</strong> (The kernel)<br />
<strong></strong><strong>openwrt-ar71xx-root.squashfs</strong> (Our Root Filesystem)</p>
<p>We now have <em>almost</em> everything we need.</p>
<div id="attachment_1543" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/IMAG0702.jpg"><img class="size-medium wp-image-1543" title="InsideTheRouterBoard" src="http://www.braindeadprojects.com/blog/wp-content/IMAG0702-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Oh, the sticker says &quot;Warranty Void if Removed&quot;...</p></div>
<p>To install our kernel, we need a few additional tools. First off, we need to configure a <a title="ISC DHCP" href="http://www.isc.org/software/dhcp" target="_blank">DHCP</a> server (I&#8217;m using ISC&#8217;s). Here&#8217;s an example from my dhcpd.conf file:</p>
<blockquote><p>authoritative;<br />
ddns-update-style interim;<br />
subnet 192.168.1.0 netmask 255.255.255.0 {<br />
range 192.168.1.20 192.168.1.40;<br />
option subnet-mask 255.255.255.0;<br />
option routers 192.168.1.1;<br />
}</p>
<p>host routerboard<br />
{<br />
hardware ethernet 00:0c:xx:xx:xx:xx;<br />
fixed-address 192.168.1.17;<br />
}</p>
<p>&nbsp;</p></blockquote>
<p>Next, we&#8217;ll need a TFTP server. I prefer <a title="ATFTPD" href="http://freecode.com/projects/atftp" target="_blank">atftpd</a>. No configuration is necessary, simply create a directory to serve files from and start the server:</p>
<blockquote><p>mkdir /tftpboot/</p>
<p>chmod 777 /tftpboot/</p>
<p>atftpd ––daemon /tftpboot/</p></blockquote>
<p>The only file that has to be loaded via TFTP is the initramfs kernel. Copy it to /tftpboot with the filename vmlinux and we&#8217;re ready to start.</p>
<blockquote><p>cp ~/svn/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux-initramfs.elf  /tftpboot/vmlinux</p></blockquote>
<p>Power up the RouterBoard and quickly press the space bar. Select &#8220;<em>boot over Ethernet</em>&#8221; and it will download and boot the linux kernel.</p>
<div id="attachment_1582" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/BootEthernet.png"><img class="size-medium wp-image-1582" title="BootEthernet" src="http://www.braindeadprojects.com/blog/wp-content/BootEthernet-300x189.png" alt="BootEthernet" width="300" height="189" /></a><p class="wp-caption-text">Opting to boot via TFTP</p></div>
<p>Next ,we need to install the kernel and root filesystem. Here&#8217;s where I ran into my first problem &#8211; the kernel has no init variable specified so it panics. Thankfully it clearly states this: &#8220;<strong>Kernel panic &#8211; not syncing: No init found.  Try passing init= option to kernel.</strong>&#8221;</p>
<div id="attachment_1606" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/KernelPanic.png"><img class="size-medium wp-image-1606" title="KernelPanic" src="http://www.braindeadprojects.com/blog/wp-content/KernelPanic-300x189.png" alt="KernelPanic" width="300" height="189" /></a><p class="wp-caption-text">Gratitous Image of a Kernel Panic</p></div>
<p>Unfortunately the boot loader doesn&#8217;t appear to allow one to specify command line options for the kernel and I was unable to find a way to set this when configuring the kernel. (I vaguely recall seeing it when compiling for x86, but may be mistaken). Either way, the solution is simple:</p>
<p>Add your kernel parameters to a file (kernel-params in my instance) and use objcopy to insert it into the ELF file:</p>
<p>The options I used are:</p>
<blockquote><p>root=/dev/mtdblock2 rootfstype=squashfs,yaffs,jffs2 noinitrd console=ttyS0,115200 init=/etc/preinit</p></blockquote>
<p>The toolchain supplied with OpenWRT contains a MIPs compatible version of objcopy that will allow you to add a kernel parameters section to the ELF file:</p>
<blockquote><p>cd ~/svn/bin/ar71xx/</p>
<p>~/svn/backfire/build_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/binutils-2.19.1/binutils/objcopy ––add-section kernparm=kernel-params openwrt-ar71xx-vmlinux.elf</p></blockquote>
<p>To install the kernel, configure an IP on your ethernet  (or bridge) interface, mount /dev/mtdblock1 and use scp to copy your kernel to the device (as &#8220;kernel&#8221;).</p>
<blockquote><p>ifconfig br-lan 192.168.1.10</p>
<p>mkdir /mnt/boot</p>
<p>mount /dev/mtdblock1 /mnt/boot</p>
<p>cd /mnt/boot/</p>
<p>scp 192.168.1.1:~/svn/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux.elf kernel</p></blockquote>
<p>&nbsp;</p>
<p>Next, install your squashfs root filesystem to /dev/mtdblock2. Unlike the kernel, This shouldn&#8217;t be mounted when installed.</p>
<blockquote><p>cd /tmp/</p>
<p>scp 192.168.1.1:~/svn/backfire/bin/ar71xx/openwrt-ar71xx-root.squashfs .</p>
<p>cat openwrt-ar71xx-root.squashfs &gt; /dev/mtdblock2</p></blockquote>
<p>After the root filesystem is installed, reboot the device and welcome to OpenWRT on the RouterBoard 493AH</p>
<div id="attachment_1616" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/ItBoots.png"><img class="size-medium wp-image-1616" title="ItBoots" src="http://www.braindeadprojects.com/blog/wp-content/ItBoots-300x189.png" alt="ItBoots" width="300" height="189" /></a><p class="wp-caption-text">It&#39;s Alive!</p></div>
<p>I&#8217;m not quite sure what I&#8217;ll end up doing with the 493AH just yet. The neighborhood wireless system now consists of 2 Engenius EOC2610 units running firmware images based off OpenWRT&#8230; so there may be the potential to add it to the fray.  The 9 ethernet ports would make it ideal for a Quagga router (although I already have one). Installing the MikroTik RouterOS and working with MPLS is another options. Right now it sits on my desk at work as a &#8220;pretty cool paperweight with a lot of potential&#8221;.</p>
<p>If you have any suggestions &#8211; please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/openwrt-on-the-mikrotik-routerboard-493ah/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a VM cluster with your bare hands.</title>
		<link>http://www.braindeadprojects.com/blog/what/building-a-vm-cluster-with-your-bare-hands/</link>
		<comments>http://www.braindeadprojects.com/blog/what/building-a-vm-cluster-with-your-bare-hands/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 21:31:49 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[KVM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1372</guid>
		<description><![CDATA[I&#8217;ve been using KVM more and more frequently in the past year (with nearly 25 virtual guests in production). While there are graphical user interfaces for KVM out there, I&#8217;ve yet to see one that supports DRBD replication (although one may exist). For that reason, I&#8217;ve basically built my Virtualization cluster using a handful of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a title="KVM" href="http://www.linux-kvm.org/page/Main_Page" target="_blank">KVM</a> more and more frequently in the past year (with nearly 25 virtual guests in production). While there are graphical user interfaces for KVM out there, I&#8217;ve yet to see one that supports <a title="DRBD" href="http://www.drbd.org/" target="_blank">DRBD replication</a> (although one may exist). For that reason, I&#8217;ve basically built my Virtualization cluster using a handful of open-source tools &#8220;by hand&#8221;.</p>
<div id="attachment_1401" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/kvmbanner-logo2.png"><img class="size-full wp-image-1401" title="KVM" src="http://www.braindeadprojects.com/blog/wp-content/kvmbanner-logo2.png" alt="Kernel-Based Virtualization Machine" width="300" height="93" /></a><p class="wp-caption-text">A penguin juggling multiple tasks and OSes</p></div>
<p>KVM has the capability to run both Windows and Linux operating systems (as well as numerous others), supports both CPU based virtualization and <a title="ParaVirtualization" href="http://en.wikipedia.org/wiki/Paravirtualization" target="_blank">para-virtualization</a>, and has virtual drivers that can run in the guest instance speeding up disk and network IO as well as <a title="Balloon Memory Drivers" href="http://www.linux-kvm.org/page/FAQ#Is_dynamic_memory_management_for_guests_supported.3F" target="_blank">balloon memory drivers</a> to reduce the actual utilization of memory on the host machine.</p>
<p>I&#8217;ll stop here and say this &#8211; For home use, I&#8217;d probably suggest avoiding anything laid out in this article and simply use <a title="VirtualBox" href="http://www.virtualbox.org/" target="_blank">Virtualbox</a>. I use it on my desktop extensively and have for many years, but for this article I&#8217;m focusing on building a cluster with KVM.</p>
<div id="attachment_1420" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/VirtualBox-Meego.png"><img class="size-medium wp-image-1420" title="VirtualBox-Meego" src="http://www.braindeadprojects.com/blog/wp-content/VirtualBox-Meego-300x223.png" alt="VirtualBox" width="300" height="223" /></a><p class="wp-caption-text">VirtualBox running Meego (another project of mine)</p></div>
<p>With the absence of a proper <a title="Storage Area Network" href="http://en.wikipedia.org/wiki/Storage_area_network" target="_blank">Storage Area Network</a> (SAN), I&#8217;m utilizing DRBD (Distributed Replicated Block Device) to provide VM disk replication across both virtual nodes. This allows for live migration of a guest from front-end node to front-end node. Additionally, this architecture will still allow for replacement of storage OR supplementing of storage with a SAN in the future.</p>
<div id="attachment_1373" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/VMLayout.png"><img class="size-medium wp-image-1373" title="The VM Cluster Layout" src="http://www.braindeadprojects.com/blog/wp-content/VMLayout-300x227.png" alt="VM Cluster" width="300" height="227" /></a><p class="wp-caption-text">The VM Cluster Layout.</p></div>
<p>DRBD replicates individual <a title="LVM" href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29" target="_blank">LVM volumes</a> (and not the raid array as a whole) across my 2 host nodes. Each virtual guest has it&#8217;s own logical volume assigned to it, which is accessed via DRBD block device interfaces  (/dev/drbd&lt;number&gt;).</p>
<p>In the example image above, jabber0 and web0 (virtual &#8220;<em><strong>guests</strong></em>&#8220;) are running on virtual0 (a virtual &#8220;<em><strong>host</strong></em>&#8221; or &#8220;<em><strong>node</strong></em>&#8220;), with web1 (another &#8220;<em><strong>guest</strong></em>&#8220;) running on virtual1 (a virtual &#8220;<em><strong>host</strong></em>&#8221; or &#8220;<em><strong>node</strong></em>&#8220;). The DRBD resource is set to <em>Primary</em> mode on the virtual <strong><em>host</em></strong> connected to a <strong>running</strong> guest, with the disk being copied to the <em>Secondary</em> (the non-running virtual host) Primary mode allows the virtual host (and it&#8217;s guests) to access the DRBD resource (and read/write from the connected logical volume).</p>
<p>As far as a virtual guest is concerned, there is no DRBD, only a /dev/vda or /dev/sda device.</p>
<p>Only during live-migration should the DRBD resources on <strong>both</strong> virtual hosts be placed into <em>Primary</em> (a situation called <em>Dual Primary</em>). As one virtual guest is paused prior to the other going active, data corruption will not occur.</p>
<div id="attachment_1375" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/2950.jpg"><img class="size-medium wp-image-1375" title="A Dell PowerEdge 2950" src="http://www.braindeadprojects.com/blog/wp-content/2950-300x135.jpg" alt="" width="300" height="135" /></a><p class="wp-caption-text">The Virtual Server itself (Well, it looks like this)</p></div>
<p>Each node is presently a <a title="Dell PowerEdge 2950" href="http://www.dell.com/us/dfb/p/poweredge-2950/pd" target="_blank">Dell PowerEdge 2950</a> with 32G of memory and over 1 Terrabyte of storage. With the DRBD replication this gives approximately 1 Terrabyte of storage (and not a combined 2 Terrabytes).</p>
<p>Each node has 4 gigabit ethernet interfaces.</p>
<table style="text-align: center;" border="1">
<tbody>
<tr>
<td><strong>Interface</strong></td>
<td><strong>Purpose</strong></td>
</tr>
<tr>
<td>eth0</td>
<td>Administrative Access</td>
</tr>
<tr>
<td>eth1</td>
<td>DRBD Replication</td>
</tr>
<tr>
<td>eth2</td>
<td>Connected to the world_br0 bridge for guest host routing</td>
</tr>
<tr>
<td>eth3</td>
<td>Connected to the world_br1 bridge for guest host routing</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>There are presently three ethernet bridges on each node:</p>
<p>&nbsp;</p>
<table style="text-align: center;" border="1">
<tbody>
<tr>
<td><strong>Bridge Interface</strong></td>
<td><strong>Purpose</strong></td>
</tr>
<tr>
<td>kickstart_br0</td>
<td>Used to kickstart guest machines</td>
</tr>
<tr>
<td>world_br0</td>
<td>Used to connect guest machines to the public network</td>
</tr>
<tr>
<td>world_br1</td>
<td>Used to connect guest machines to the public network</td>
</tr>
</tbody>
</table>
<h4></h4>
<p>&nbsp;</p>
<h3>Connecting to a Guest:</h3>
<p>Each guest is accessible via standard means (ssh) when configured correctly. Additionally, one can connect to each guest by <a title="VNC" href="http://en.wikipedia.org/wiki/Virtual_Network_Computing" target="_blank">VNC</a>ing to a unique port on the virtual host. (I do maintain a list of which DRBD ports and VNC ports are used for each of my virtual guests)</p>
<h3>Configuring an LVM volume:</h3>
<p>The &#8220;vmdisks&#8221; <a title="LVM" href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29" target="_blank">LVM</a> volume group is approximately 1.3TB of disk storage, used to provide individual volumes to the guest instances. I use a logical volume of 30G for most guests.</p>
<p>To add a logical disk for guest usage is simple &#8211; and <strong>Must be done uniformly across all nodes</strong>:</p>
<blockquote><p><em>lvcreate -L &lt;size&gt;M -n &lt;name&gt; vmdisks</em></p></blockquote>
<h3></h3>
<h3></h3>
<p>&nbsp;</p>
<h3>Initial Configuration of the DRBD MD device:</h3>
<p>The DRBD MD device is the actual block device that the Guest machine will interface with.</p>
<p>The following <strong>MUST BE DONE ACROSS ALL NODES</strong>, however only upon initial creation:</p>
<p>Update the /etc/drbd.conf file to add your new node (here&#8217;s an example):</p>
<blockquote><p>resource &lt;resource name&gt;<br />
{<br />
net<br />
{<br />
allow-two-primaries;<br />
}</p>
<p>syncer<br />
{<br />
rate 33M;<br />
}</p>
<p>startup<br />
{<br />
become-primary-on virtual0.braindeadprojects.com;<br />
}</p>
<p>on virtual0.braindeadprojects.com<br />
{<br />
device /dev/drbd&lt;Next Available block&gt;;<br />
disk /dev/vmdisks/&lt;LVM Volume Group&gt;;<br />
address 10.255.255.1:&lt;Next available port&gt;;<br />
meta-disk internal;<br />
}</p>
<p>on virtual1.braindeadprojects.com<br />
{<br />
device /dev/drbd&lt;Next available block&gt;;<br />
disk /dev/vmdisks/&lt;LVM Volume Group&gt;;<br />
address 10.255.255.2:&lt;next available port&gt;;<br />
meta-disk internal;<br />
}</p>
<p>}</p></blockquote>
<p>&nbsp;</p>
<p>After updating the config, create the block device and enable it:</p>
<blockquote><p>#drbdadm create-md &lt;resource name&gt;<br />
#drbdadm up &lt;resource name&gt;</p></blockquote>
<p>&nbsp;</p>
<p>At this point, all nodes have a record of this DRBD resource. /proc/drbd will have additional information.</p>
<p><strong>The following must be done ONLY ON THE PRIMARY (MASTER) NODE</strong>:</p>
<blockquote><p><em>#drbdadm &#8212; &#8211;overwrite-data-of-peer primary &lt;resource name&gt;<br />
</em></p></blockquote>
<p>&nbsp;</p>
<p>This will begin an initial synchronization across the nodes. Again, this is only run on the &#8220;Master node&#8221; (the virtual host node that is initially running the VM guest).  At this time, the DRBD resource is available on ALL nodes, however until the synchronization is finished, reads/writes will take slightly longer.</p>
<p><strong>An important note on synchronization:</strong></p>
<p>The <a title="DRBD Syncer stanza" href="http://www.drbd.org/users-guide/s-resync.html" target="_blank">syncer{} stanza</a> in the resource config plays an important role in how fast a drive is synchronized. Default sync speed is roughly 340K/sec, which in turn causes a drive synchronization of a 30G drive to take appx 28 hours.</p>
<p>This can safely be set to 33M/sec in my environment, reducing sync-time to roughly 20 minutes, depending upon load.</p>
<p>Sync rate will play an important factor in instances where an entire node fails, and the resources of the failover node cannot keep up. In such an event, a 3rd node should be added to the system, with drives synced to it.</p>
<h3>Creating the VM Guest:</h3>
<p>I&#8217;m utilizing <a title="libVirt" href="http://libvirt.org/" target="_blank">libvirt</a> as a convenient way to provision and manage virtual machines.</p>
<div id="attachment_1422" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.braindeadprojects.com/blog/wp-content/libvirt-header-logo.png"><img class="size-full wp-image-1422" title="libVirt" src="http://www.braindeadprojects.com/blog/wp-content/libvirt-header-logo.png" alt="libVirt" width="400" height="104" /></a><p class="wp-caption-text">libVirt, handling all your hypervisor and sardine needs since 2009</p></div>
<p>Creation of a guest is fairly easy, and can be done interactively or via a one-liner:</p>
<blockquote><p>#virt-install &#8211;connect qemu:///system -n &lt;Guest Name&gt; -r &lt;RAM in MB&gt; &#8211;vcpus=1 \<br />
&#8211;arch=&lt;i686|x86_64|&#8230;&gt; &#8211;vnc &#8211;vncport=&lt;unused VNC port number&gt; &#8211;noautoconsole &#8211;os-type linux &#8211;accelerate \<br />
&#8211;network=bridge:&lt;kickstart_br0|world_br0|world_br1&gt; &#8211;hvm &#8211;disk path=/dev/drbd&lt;resource number&gt;,bus=virtio \<br />
&#8211;&lt;pxe|import|cdrom&gt;</p></blockquote>
<p>&nbsp;</p>
<p>After which time the guest will automatically start, with it&#8217;s vnetX interface bridging with kickstart_br0.</p>
<p>I&#8217;ve installed <a title="DNSMasq" href="http://thekelleys.org.uk/dnsmasq/doc.html" target="_blank">DNSMasq</a> on each host machine. It sits atop the kickstart_br0 interface, and assigns the VM an IP in the 192.168.6.0/24 network (via DHCP), and PXE boots/kickstarts it off a mirroring server. (The 192.168.6.0/24 network is MASQUERADEd in iptables so requests appear to come from virtual[01])</p>
<p>After kickstarting the guest, the reboot process tends to shut down the virtual guest so it may need to be restarted (Normal reboots are not prone to this shutdown). Once restarted, server configuration can be done via ssh from the host node, or VNC.</p>
<div class="wp-caption alignnone" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/trixbox-kvm.png"><img title="trixbox-kvm" src="http://www.braindeadprojects.com/blog/wp-content/trixbox-kvm-300x177.png" alt="Trixbox-KVM" width="300" height="177" /></a><p class="wp-caption-text">A KVM Trixbox guest: It&#39;s ALIVE!!!</p></div>
<p>Once the machine is built, customized and ready to be placed on the Internet, power down the VM guest and edit the XML config file (replacing <strong>kickstart_br0</strong> with <strong>world_br0</strong> or <strong>world_br1</strong>). If you find that the VM guest attempts to PXE boot once again, you may need to also change the boot device order (specifying <strong>hd</strong> instead of <strong>network</strong>)</p>
<p>You will also want to adjust the clock to source itself from the host machine.</p>
<blockquote><p># virsh<br />
Welcome to virsh, the virtualization interactive terminal.<br />
Type:  &#8216;help&#8217; for help with commands<br />
&#8216;quit&#8217; to quit<br />
virsh # edit &lt;guestname&gt;<br />
&#8230;<br />
&#8230;<br />
&lt;os&gt;<br />
&lt;type arch=&#8217;x86_64&#8242; machine=&#8217;rhel5.4.0&#8242;&gt;hvm&lt;/type&gt;<br />
&lt;boot dev=&#8217;network&#8217;/&gt;<br />
&lt;boot dev=&#8217;hd&#8217;/&gt;<br />
&lt;/os&gt;<br />
&#8230;<br />
&#8230;<br />
&lt;interface type=&#8217;bridge&#8217;&gt;<br />
&lt;mac address=&#8217;54:52:00:2d:21:10&#8242;/&gt;<br />
&lt;source bridge=&#8217;kickstart_br0&#8242;/&gt;<br />
&lt;target dev=&#8217;vnet1&#8242;/&gt;<br />
&lt;/interface&gt;<br />
&#8230;<br />
&#8230;<br />
&lt;clock offset=&#8217;localtime&#8217;/&gt;<br />
&#8230;<br />
&#8230;</p></blockquote>
<p>&nbsp;</p>
<h4>To boot from CD:</h4>
<p>&nbsp;</p>
<blockquote><p>&lt;disk type=&#8217;file&#8217; device=&#8217;cdrom&#8217;&gt;<br />
&lt;driver name=&#8217;qemu&#8217; type=&#8217;raw&#8217;/&gt;<br />
&lt;source file=&#8217;/usr/src/systemrescuecd-x86-1.6.2.iso&#8217;/&gt;<br />
&lt;target dev=&#8217;hdc&#8217; bus=&#8217;ide&#8217;/&gt;<br />
&lt;readonly/&gt;<br />
&lt;address type=&#8217;drive&#8217; controller=&#8217;0&#8242; bus=&#8217;1&#8242; unit=&#8217;0&#8242;/&gt;<br />
&lt;/disk&gt;</p></blockquote>
<p>&nbsp;</p>
<p>After editing the XML, you can restart the VM.</p>
<p>&nbsp;</p>
<blockquote><p>virsh # start &lt;guestname&gt;</p></blockquote>
<p>&nbsp;</p>
<h3>General usage:</h3>
<p>&nbsp;</p>
<p>I&#8217;ve made sure to install <a title="virt-top" href="http://people.redhat.com/~rjones/virt-top/" target="_blank">virt-top</a>, an interface to the hypervisor similar to the &#8220;top&#8221; command. This gives a nice overview of the system:</p>
<blockquote><p>#virt-top</p></blockquote>
<p>&nbsp;</p>
<div id="attachment_1474" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/virt-top.png"><img class="size-medium wp-image-1474" title="virt-top" src="http://www.braindeadprojects.com/blog/wp-content/virt-top-300x187.png" alt="virt-top" width="300" height="187" /></a><p class="wp-caption-text">virt-top: An overview of CPU and memory</p></div>
<p>The shell API for libvirt makes manipulating guest instances easy<em></em>. Here are a few of the more frequently used virsh commands:</p>
<blockquote><p>#list &lt;&#8211;all&gt; (Lists running and non-running guests)<br />
#start &lt;guestname&gt; (Starts guest instance)<br />
#autostart &lt;guestname&gt; (Marks guest to be autostarted at node boot)<br />
#destroy &lt;guestname&gt; (Immediately powers off guest)<br />
#suspend &lt;guestname&gt; (Powers down guest gracefully)<br />
#reboot &lt;guestname&gt; (Reboots guest)<br />
#edit &lt;guestname&gt; (Edits the guest XML config)<br />
#migrate (See the migration section for more info)</p></blockquote>
<p>&nbsp;</p>
<h3>Live migration:</h3>
<p>Live migration between nodes can be done via ssh (with shared keys) or TLS. I&#8217;m currently utilizing the ssh method:</p>
<p>Prior to migration, the DRBD resource needs to be place in Primary on <strong>both nodes</strong>:</p>
<blockquote><p>#drbdadm primary &lt;resource name&gt;</p></blockquote>
<p>&nbsp;</p>
<p>After doing so, the following is run on the <strong>SENDING</strong> node only:</p>
<blockquote><p>#virsh migrate &#8211;live &lt;GUEST&gt; qemu+ssh://&lt;RECEIVING NODE&gt;/system</p></blockquote>
<p>&nbsp;</p>
<p>As part of the migration process, the sending node copies memory and kernel state via ssh to the receiving node. During the migration process, the guest instance on the sending node is active, with the guest node being marked as paused.</p>
<p>&nbsp;</p>
<p>Once information is migrated, the sending node pauses it&#8217;s guest instance, with the receiving node un-pausing. Actual migration depends upon a number of factors, although is generally accomplished in under 35 seconds.</p>
<p>Following the migration, it&#8217;s essential to place the <strong>losing node</strong> into DRBD secondary mode. Should I accidentally try to start the guest on the losing node, this will prevent it from obtaining access to the disk (and corrupting data):</p>
<blockquote><p>#drbdadm secondary &lt;resource name&gt;</p></blockquote>
<p>&nbsp;</p>
<h3>Virtualizing Physical Machines:</h3>
<p>&nbsp;</p>
<p>Virtualizing a physical machine is extremely easy. Instead of PXE booting and kickstarting an install (<em><strong>&#8211;pxe</strong></em>),  I use the <em><strong>&#8211;cdrom /usr/src/systemrescuecd-x86-1.6.2.iso</strong></em> flag when creating the virtual guest. On each virtual host, I have a copy of the excellent Gentoo based <a title="SystemRescueCd" href="http://www.sysresccd.org/Main_Page" target="_blank">SystemRescueCd</a>.</p>
<p>When the system boots into the live CD, partition the drive (usually /dev/vda or /dev/sda) as you wish (taking advantage of LVM for non-boot partitions if possible).</p>
<p>Create a /mnt/migrate directory from the live cd, and mount your newly created partitions there.</p>
<blockquote><p>mount /dev/sda2 /mnt/migrate<br />
for dir in {boot,proc,dev}; do mkdir /mnt/migrate/$dir; done<br />
mount /dev/sda1 /mnt/migrate/boot</p>
<p>(Do the same for /var and any other directories you have partitioned separately)</p></blockquote>
<p>Utilizing rsync over ssh, synchronize all files from the physical host to the virtual one (taking care that you perform the action correctly, so as not to overwrite the original server). A handful of files and directories <strong>NEED TO BE OMITTED</strong>, namely:</p>
<blockquote><p>/proc<br />
/dev<br />
/sys<br />
/lost+found<br />
(possibly others)</p></blockquote>
<p>I generally use an rsync command similar to this one:</p>
<blockquote><p>#time rsync &#8211;exclude &#8216;/dev/&#8217; &#8211;exclude &#8216;/proc/&#8217; &#8211;exclude &#8216;/sys/&#8217; &#8211;exclude &#8216;/lost+found/&#8217;  -ave ssh &lt;originalserverip&gt;:/ /mnt/migrate/</p></blockquote>
<p>The following devices need to be present in order to boot into the OS.  <em>Either rsync them or manually make them with mknod.</em></p>
<blockquote><p>/dev/console<br />
/dev/initctl<br />
/dev/null<br />
/dev/zero</p></blockquote>
<p><em>Another easy way to accomplish this is:</em></p>
<blockquote><p><em></em>for file in {console,initctl,null,zero}; do cp -a /dev/$file /mnt/migrate/dev/$file ; done</p></blockquote>
<p>&nbsp;</p>
<p>Following the rsync, the virtual guest will need a bootloader and an updated initial ramdisk. Both of these are best done in a chroot environment:</p>
<blockquote><p>mount -o bind /dev/ /mnt/migrate/dev/<br />
mount -t proc none /mnt/migrate/proc/<br />
mount -o bind /sys/ /mnt/migrate/sys/<br />
chroot /mnt/migrate/ /bin/bash</p></blockquote>
<p>&nbsp;</p>
<p>Inside the chroot environment, you will need to update /etc/mtab and /etc/fstab to reflect your new partitioning (at the very least drives will likely change to /dev/vda). You will also need to update /boot/grub/device.map to reflect hd0 as a valid drive.</p>
<p>Once these changes have been made, grub installation should be as simple as:</p>
<blockquote><p>grub-install &#8211;no-floppy /dev/vda</p></blockquote>
<p>&nbsp;</p>
<p>(Although sometimes grub needs to be further caressed. See the <a title="Gentoo Handbook" href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=10" target="_blank">Gentoo Handbook section on installing the grub bootloader</a> for good documentation)</p>
<p><em><strong>If a simple grub-install does not work:</strong></em></p>
<blockquote><p># grub<br />
grub&gt; root (hd0,0)           &lt;&#8211; where hd0,0 is the first partition on the first drive<br />
grub&gt; setup (hd0)            &lt;&#8211; install grub on the mbr of the first drive<br />
grub&gt; quit</p></blockquote>
<p>&nbsp;</p>
<p>With the Bootloader installed, we need to create a working initial ramdisk with necessary drivers. Look for the most recent installed kernel in grub.conf and create the ramdisk (replace the version numbers with yours):</p>
<blockquote><p>mkinitrd -f /boot/initrd-2.6.18-194.32.1.el5.img 2.6.18-194.32.1.el5</p></blockquote>
<p>To take advantage of virtio (network and disk) modules on newer kernels, you may opt to include them in the initrd:</p>
<blockquote><p>mkinitrd -f &#8211;with virtio_pci &#8211;with virtio_blk \ &#8211;with virtio_net /boot/initrd-2.6.18-194.32.1.el5.img 2.6.18-194.32.1.el5</p></blockquote>
<p>&nbsp;</p>
<p><em><strong>Please be aware</strong></em> that many files (IE: databases) should only be rsynced when shutdown. For this reason, it&#8217;s often best to shutdown MySQL, PostgreSQL, and various other services PRIOR TO RSYNCing to prevent database corruption.</p>
<p><a name="How_to_physicalize_a_virtual_machine"></a></p>
<h3>How to physicalize a virtual machine:</h3>
<p>In the event of a major issue, converting a virtual machine back to a physical machine has the same process as physical to virtual, but reversed.</p>
<h3>Of Note:</h3>
<p>While Fedora currently supports (automatically, out of the box) SELinux profiles/labels for KVM guest instances, Centos 5.6 does not. It will be incorporated in Centos 6, however&#8230; and I plan on migrating to that OS eventually.</p>
<h3>Final Thoughts:</h3>
<p>As with everything, there&#8217;s pros and cons to this methodology.</p>
<ul>
<li>While I&#8217;ve always preferred avoiding GUIs, the fact is they standardize on what steps happen in which order (limiting the potential for user-induced errors.)</li>
</ul>
<ul>
<li>A high performance SAN (or perhaps an <a title="OpenFiler" href="http://www.openfiler.com/" target="_blank">OpenFiler</a> box) would make things much easier to configure and migrate, but at the same time introduce a possible single point of failure.</li>
</ul>
<ul>
<li>Utilizing an automation engine (like <a title="Puppet Automation Engine" href="http://www.puppetlabs.com/" target="_blank">puppet</a>) could limit the number of steps needed to provision a virtual guest across all nodes.</li>
</ul>
<ul>
<li>Outside of some possible restrictions (virtio drivers being specific to KVM, LVM2 support for Windows), migrating from the present day system to vmware, virtualbox, or &lt;insert your favorite hypervisor here&gt; &#8212; should be fairly easy, requiring simply creating a guest and pointing it at an LVM share.</li>
</ul>
<p>All in all, the system has been in production for nearly a year now and is performing beautifully. And best of all, I&#8217;m saving on power and generating less heat.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/building-a-vm-cluster-with-your-bare-hands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop the bleeding!</title>
		<link>http://www.braindeadprojects.com/blog/what/stop-the-bleeding/</link>
		<comments>http://www.braindeadprojects.com/blog/what/stop-the-bleeding/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 23:05:16 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[BrainDeadTip]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1350</guid>
		<description><![CDATA[I&#8217;ve been quite annoyed recently with my video card, the &#8220;nVidia Corporation GeForce 8400 GS (rev a1)&#8220;. A number of sites using Flash tend to bleed through Firefox or Chrome and into other tabs or even other workspaces. I&#8217;ve upgraded the nvidia-drivers a number of times, never actually fixing the problem. Other Gentoo users on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been quite annoyed recently with my video card, the &#8220;<a title="The GeForce 8400 GS" href="http://www.nvidia.com/object/geforce_8400.html" target="_blank">nVidia Corporation GeForce 8400 GS (rev a1)</a>&#8220;. A number of sites using Flash tend to bleed through Firefox or Chrome and into other tabs or even other workspaces.</p>
<div id="attachment_1351" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/this-is-annoying.jpg"><img class="size-medium wp-image-1351" title="This is annoying." src="http://www.braindeadprojects.com/blog/wp-content/this-is-annoying-300x229.jpg" alt="questo è fastidioso" width="300" height="229" /></a><p class="wp-caption-text">I can still SEE YOU!</p></div>
<p>I&#8217;ve upgraded the nvidia-drivers a number of times, never actually fixing the problem. Other Gentoo users on the #gentoo channel of <a title="Freenode" href="http://freenode.net/" target="_blank">freenode</a> have suggested migrating to <a title="Gnash" href="http://www.gnu.org/s/gnash/" target="_blank">gnash</a> instead&#8230; and while I have contemplated this, I&#8217;ve noticed a number of things that don&#8217;t work well under gnash on my netbook.</p>
<p>Thankfully I&#8217;m not the only person to be experiencing this. Earlier today I came across a solution (that while not optimal) definitely fixes the problem:</p>
<p>&nbsp;</p>
<div id="attachment_1353" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/disable-this-in-flash.png"><img class="size-medium wp-image-1353" title="disable-this-in-flash" src="http://www.braindeadprojects.com/blog/wp-content/disable-this-in-flash-300x226.png" alt="Untick this box" width="300" height="226" /></a><p class="wp-caption-text">No acceleration, but no bleeding either.</p></div>
<p>Disabling hardware acceleration thankfully stops the bleedthrough. (Just right click on a flash movie, select &#8220;Settings&#8221; and disable acceleration under &#8220;display&#8221;) You will need to restart your browsers for it to fully take effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/stop-the-bleeding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNS3 and Gentoo &#8211; fixing QEMU networking</title>
		<link>http://www.braindeadprojects.com/blog/what/gns3-and-gentoo-fixing-qemu-networking/</link>
		<comments>http://www.braindeadprojects.com/blog/what/gns3-and-gentoo-fixing-qemu-networking/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 02:54:22 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[BrainDeadTip]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[GNS3]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[KVM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1289</guid>
		<description><![CDATA[I was hoping to have time to further familiarize myself with IPv6 this weekend -  but workplace emergencies, sleep, and a technical glitch slowed me down. Here&#8217;s the story of the technical glitch. GNS3/dynamips can handle emulation of a number of routers, and I was happy to see that it can emulate host PCs as [...]]]></description>
			<content:encoded><![CDATA[<p>I was hoping to have time to further familiarize myself with <a title="IPv6" href="http://en.wikipedia.org/wiki/IPv6" target="_blank">IPv6</a> this weekend -  but workplace emergencies, sleep, and a technical glitch slowed me down. Here&#8217;s the story of the technical glitch.</p>
<div id="attachment_1320" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/GNS3.png"><img class="size-medium wp-image-1320" title="GNS3" src="http://www.braindeadprojects.com/blog/wp-content/GNS3-300x88.png" alt="" width="300" height="88" /></a><p class="wp-caption-text">GNS3 - this thing rocks.</p></div>
<p><a title="GNS3" href="http://www.gns3.net/" target="_blank">GNS3</a>/<a title="Dynamips" href="http://www.ipflow.utc.fr/index.php/Cisco_7200_Simulator" target="_blank">dynamips</a> can handle emulation of a number of routers, and I was happy to see that it can emulate host PCs as well. Unfortunately networking in GNS3  is done via <em>UDP tunnels</em> &#8211; something that requires a <a title="Qemu" href="http://wiki.qemu.org/Main_Page" target="_blank">Qemu</a> patch to implement.</p>
<div id="attachment_1306" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/GNS3-IPv6-test.png"><img class="size-medium wp-image-1306" title="GNS3-IPv6-test" src="http://www.braindeadprojects.com/blog/wp-content/GNS3-IPv6-test-300x209.png" alt="" width="300" height="209" /></a><p class="wp-caption-text">For some reason QEMU won&#39;t really start if it&#39;s networked.</p></div>
<p>In <a title="Gentoo" href="http://www.gentoo.org/">Gentoo</a>, simply building GNS3 from the <a title="Sunrise Overlay" href="http://overlays.gentoo.org/proj/sunrise" target="_blank">Sunrise Overlay</a> doesn&#8217;t provide sufficient support for this requirement. Emulated routers (and I&#8217;m assuming switches) work fine when networked together. Emulated host machines work fine when NOT connected to anything. But once you network things together you&#8217;ll discover that your Qemu host won&#8217;t start.</p>
<p>Here&#8217;s why &#8211; when you start a Qemu host, this is essentially what GNS3 runs:</p>
<blockquote><p>/usr/bin/qemu -name QEMU1 -m 256  /mnt/virtualmachines/dynips/IPv6-tc/working/QEMU1/FLASH -hdb  /mnt/virtualmachines/dynamips/IPv6-tc/working/QEMU1/SWAP -enable-kvm  -net nic,vlan=0,macaddr=00:aa:00:8f:e4:00,model=rtl8139 <strong>-net  udp,vlan=0,sport=20000,dport=10006,daddr=127.0.0.1 </strong>-net  nic,vlan=1,macaddr=00:00:ab:fa:72:01,model=rtl8139 -serial  telnet:127.0.0.1:3000,server,nowait -no-acpi -vnc :0</p></blockquote>
<p>GNS3 attempts to use the <strong>-net udp</strong> option, something not offered in the default QEMU-KVM distribution. With no Gentoo <a title="USE flags" href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&amp;chap=2#doc_chap1" target="_blank">USE flags</a> to add the patch in either 0.13.0 or 0.14.50, I decided to simply upgrade to 0.14.50 and see if it was part of the default build:</p>
<blockquote><p># kvm &#8211;version<br />
QEMU emulator version 0.14.50 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard<br />
# kvm &#8211;help | grep &#8220;net udp&#8221;<br />
#</p></blockquote>
<p>Nope, it&#8217;s not. So the next step is to remove app-emulation/qemu-kvm from your system and build it by hand.</p>
<p>First, remove kvm and download the source from kernel.org:</p>
<blockquote><p># emerge -C app-emulation/qemu-kvm</p>
<p># cd /usr/src/</p>
<p># wget http://mirrors.kernel.org/gentoo/distfiles/qemu-kvm-0.13.0.tar.gz</p></blockquote>
<p>Unpack and patch it, using the <a title="Patch" href="http://sourceforge.net/projects/gns-3/files/Qemu/qemu-0.13.0.patched.win32.zip/download" target="_blank">patch provided by the gns-3 team </a>.</p>
<blockquote><p># tar zxvpf qemu-kvm-0.13.0.tar.gz</p>
<p># cd qemu-kvm-0.13.0/</p></blockquote>
<p>Testing the patch, I ran into a handful of issues:</p>
<blockquote><p># patch &#8211;dry-run -p1 &lt; /mnt/nas/downloads/qemu-0.13.0-<br />
mcast-udp.patch<br />
patching file Makefile.objs<br />
Hunk #1 FAILED at 25.<br />
1 out of 1 hunk FAILED &#8212; saving rejects to file Makefile.objs.rej<br />
patching file block/raw-win32.c<br />
Hunk #1 FAILED at 93.<br />
Hunk #2 FAILED at 347.<br />
2 out of 2 hunks FAILED &#8212; saving rejects to file block/raw-win32.c.rej<br />
patching file hw/e1000.c<br />
Hunk #1 FAILED at 567.<br />
1 out of 1 hunk FAILED &#8212; saving rejects to file hw/e1000.c.rej<br />
patching file net/udp.c<br />
patching file net/udp.h<br />
patching file net.c<br />
Hunk #1 FAILED at 30.<br />
Hunk #2 FAILED at 1075.<br />
2 out of 2 hunks FAILED &#8212; saving rejects to file net.c.rej<br />
patching file net.h<br />
Hunk #1 FAILED at 33.<br />
1 out of 1 hunk FAILED &#8212; saving rejects to file net.h.rej<br />
patching file qemu-options.hx<br />
Hunk #1 FAILED at 996.<br />
1 out of 1 hunk FAILED &#8212; saving rejects to file qemu-options.hx.rej</p></blockquote>
<p>A quick modification and we&#8217;ve got <a title="Update Patch File" href="http://www.braindeadprojects.com/src/gentoo-qemu-0.13.0.gns3.patch" target="_blank">a new patch file</a>. This one applies nicely:</p>
<blockquote><p># patch &#8211;dry-run -p1 &lt; /mnt/nas/downloads/gentoo-qemu-0.13.0.gns3.patch<br />
patching file Makefile.objs<br />
patching file QMP/qmp-commands.txt<br />
patching file block/raw-win32.c<br />
patching file config-all-devices.mak<br />
patching file config-host.h<br />
patching file config-host.h-timestamp<br />
patching file config-host.ld<br />
patching file config-host.mak<br />
patching file hw/e1000.c<br />
patching file libdis/config.mak<br />
patching file libdis-user/config.mak<br />
patching file libhw32/config.mak<br />
patching file libhw64/config.mak<br />
patching file net/udp.c<br />
patching file net/udp.h<br />
patching file net.c<br />
patching file net.h<br />
patching file qemu-doc.html<br />
patching file qemu-img-cmds.texi<br />
patching file qemu-img.1<br />
patching file qemu-monitor.texi<br />
patching file qemu-nbd.8<br />
patching file qemu-options.hx<br />
patching file qemu-options.texi<br />
patching file qemu-tech.html<br />
patching file qemu.1<br />
patching file roms/seabios/config.mak<br />
patching file roms/vgabios/config.mak<br />
patching file x86_64-softmmu/config-devices.mak<br />
patching file x86_64-softmmu/config-devices.mak.old<br />
patching file x86_64-softmmu/config-target.mak<br />
vonnegut qemu-kvm-0.13.0 #</p></blockquote>
<p>So let&#8217;s apply it for real and then configure, build, and install our new Qemu:</p>
<blockquote><p># patch -p1 &lt; /mnt/nas/downloads/gentoo-qemu-0.13.0.gns3.patch</p>
<p>&#8230;</p>
<p># ./configure &#8211;prefix=/usr &#8211;target-list=i386-softmmu &#8211;enable-sdl</p>
<p># make &amp;&amp; make install</p></blockquote>
<p>A quick check to ensure UDP tunneling is compiled in:</p>
<blockquote><p># /usr/bin/qemu &#8211;version<br />
QEMU emulator version 0.13.0 (qemu-kvm-0.13.0), Copyright (c) 2003-2008 Fabrice Bellard<br />
# /usr/bin/qemu &#8211;help | grep &#8220;net udp&#8221;<br />
-net udp[,vlan=n]sport=sport,dport=dport,daddr=host<br />
#</p></blockquote>
<p>And voila &#8211; now not only does my host machine start when networked into my layout, it also has connectivity:</p>
<div id="attachment_1308" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/QEMU-working-host.png"><img class="size-medium wp-image-1308" title="QEMU-working-host" src="http://www.braindeadprojects.com/blog/wp-content/QEMU-working-host-300x177.png" alt="" width="300" height="177" /></a><p class="wp-caption-text">Yes, it finally works.</p></div>
<p>Next up &#8211; continue lab work with IPv6, and begin studying for my <a title="CCNP" href="http://www.cisco.com/web/learning/le3/le2/le37/le10/learning_certification_type_home.html" target="_blank">CCNP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/gns3-and-gentoo-fixing-qemu-networking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Packet Creation for IPv6</title>
		<link>http://www.braindeadprojects.com/blog/what/packet-creation-for-ipv6/</link>
		<comments>http://www.braindeadprojects.com/blog/what/packet-creation-for-ipv6/#comments</comments>
		<pubDate>Sun, 22 May 2011 17:35:06 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=27</guid>
		<description><![CDATA[With most of my projects, I&#8217;ve noticed that before I can really begin to delve into them, I first have to learn something completely new. I don&#8217;t do most of my work in Perl, but I can definitely make ends meet. My more recent work in Perl has dealt w/ RIP scanning and route-updating (a [...]]]></description>
			<content:encoded><![CDATA[<p>With most of my projects, I&#8217;ve noticed that before I can <em>really</em> begin to delve into them, I first have to learn something completely new.</p>
<p>I don&#8217;t do most of my work in <a title="Perl " href="http://www.perl.org/" target="_blank">Perl</a>, but I can definitely make ends meet. My more recent work in Perl has dealt w/ <a title="RIP" href="http://en.wikipedia.org/wiki/Routing_Information_Protocol" target="_blank">RIP</a> scanning and route-updating (a lot of DSL CPE tends to have RIP enabled). Packet creation isn&#8217;t that difficult, and using Perl I could bang out a script in a short period of time.</p>
<p>Usually for packet manipulation, I stay away from Perl &#8211; instead I&#8217;m a huge fan of <a href="http://www.hping.org/" target="_blank">Hping[23]</a>. If you&#8217;re wanting to watch and play w/ the transport layer &#8211; an old laptop with hping and wireshark running is definitely the way to go. If you want to test MTU problems, or ACLs  -  Hping is fast and easy.</p>
<p>Hping is an amazing tool &#8211; one of my favorites. Hand crafted TCP and UDP traceroutes are easy as hell, and hand crafting TCP timestamp requests is easy too. Just read the manpages and you&#8217;ll find all sorts of interesting features of TCP/IP.</p>
<div id="attachment_964" class="wp-caption aligncenter" style="width: 160px"><a href="http://www.braindeadprojects.com/blog/wp-content/hping.jpg"><img class="size-full wp-image-964" title="HPing" src="http://www.braindeadprojects.com/blog/wp-content/hping.jpg" alt="hping: A Great Tool" width="150" height="59" /></a><p class="wp-caption-text">hping: Like a screwdriver set with most of the bits.</p></div>
<p>The downside to Hping is that it doesn&#8217;t seem to be under regular development (last release 2005?), and IPv6 isn&#8217;t supported yet (Aside from some basic <a href="http://www.sfc.wide.ad.jp/~watari/Download/sendit.html" target="_blank">third-party patches</a>). Application layer creation is also left for other utilities to handle (But in all fairness &#8211; that&#8217;s not it&#8217;s job)</p>
<p>I was a late adopter, but about a year ago I made a new friend (and picked up some <a title="Python" href="http://www.python.org/" target="_blank">python</a> along the way). My new best friend is <a href="http://www.secdev.org/projects/scapy/doc/" target="_blank">Scapy</a>. &#8220;Scapy is a powerful interactive packet manipulation program. It is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, match requests and replies, and much more.&#8221; It runs in interactive and script-able mode, and thus far it&#8217;s proven to be quite powerful. It also supports IPv6.</p>
<p>Scapy understands a large number of Application level protocols (SNMP, TFTP, SMB, etc, etc), and makes it easy for one to craft such packets.  When I recently realized early versions of Cisco IP Router Export have corrupt headers &#8211; Scapy came to the rescue (albeit, only to rip the headers off, as fixing them wasn&#8217;t possible).  When I wanted to craft a quick and easy <a href="http://www.braindeadprojects.com/blog/what/freeradius-packet-of-death/" target="_blank">FreeRadius Packet of Death</a> &#8211; Scapy came to the rescue.</p>
<div id="attachment_1241" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/Exploits-Database-by-Offensive-Security_1306085049070.png"><img class="size-medium wp-image-1241" title="Exploits Database by Offensive Security_1306085049070" src="http://www.braindeadprojects.com/blog/wp-content/Exploits-Database-by-Offensive-Security_1306085049070-300x177.png" alt="Exploits Database" width="300" height="177" /></a><p class="wp-caption-text">FreeRadius PoD on www.exploit-db.com</p></div>
<p>Another great thing about Scapy is that it&#8217;s easy to add &#8220;layers&#8221; (protocols). Recently I sat down with the RFC&#8217;s for <a title="OSPF" href="http://en.wikipedia.org/wiki/Open_Shortest_Path_First" target="_blank">OSPF</a> and in about 2 days time had fully implemented OSPF in Scapy &#8211; learning a <strong>lot</strong> about the protocol along the way. (Dirk Loss had beat me and <a href="http://trac.secdev.org/scapy/attachment/wiki/OSPF/scapy_ospf.py" target="_blank">submitted</a> it first, but that was besides the point).</p>
<p>Looking for a fun new world to poke, and tired of IPv4? Sign up for a <a title="Sixxs.net" href="http://www.sixxs.net/" target="_blank">6-in-4 tunnel</a> and go exploring. Just make sure you pack Scapy and a <a href="http://www.packetlevel.ch/html/scapy/scapyipv6.html" target="_blank">handy guide</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/packet-creation-for-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing the WebConverger Kiosk &#8211; The fast way</title>
		<link>http://www.braindeadprojects.com/blog/what/customizing-the-webconverger-kiosk-the-fast-way/</link>
		<comments>http://www.braindeadprojects.com/blog/what/customizing-the-webconverger-kiosk-the-fast-way/#comments</comments>
		<pubDate>Sat, 07 May 2011 22:14:35 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[GIMP]]></category>
		<category><![CDATA[Kiosk]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1056</guid>
		<description><![CDATA[Recently I was asked to assist a co-worker find a good locked down Kiosk solution for a local coffee shop. The project requirement was small &#8211; mostly just a simple browser. There seems to have been a LOT of Linux based Kiosk projects out there, most of them now deprecated. After a bit of searching, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was asked to assist a co-worker find a good locked down Kiosk solution for a local coffee shop. The project requirement was small &#8211; mostly just a simple browser.</p>
<p>There seems to have been a LOT of Linux based Kiosk projects out there, most of them now deprecated. After a bit of searching, I came across a good one &#8211; <a title="WebConverger" href="http://webconverger.org/kiosk/">WebConverger</a>.</p>
<div id="attachment_1057" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/webconverger.png"><img class="size-medium wp-image-1057" title="webconverger" src="http://www.braindeadprojects.com/blog/wp-content/webconverger-300x225.png" alt="" width="300" height="225" /></a><p class="wp-caption-text">Webconverger</p></div>
<p>Webconverger is a Live Debian build, created and maintained by Kai Hendry using the <a title="Debian Live" href="http://live.debian.net/" target="_blank">Debian Live-builder packages</a>. The LiveCD includes the lightweight  <a title="Dynamic Window Manager" href="http://dwm.suckless.org/" target="_blank">Dynamic Window Manager (DWM) </a> , the <a title="IceWeasel" href="http://wiki.debian.org/Iceweasel" target="_blank">IceWeasel browser</a> with Webconverger kiosk extension (to lock things down), and&#8230; well that&#8217;s about it.</p>
<p>Kai has <a title="WebConverger for Developers" href="http://webconverger.org/develop/" target="_blank">excellent documentation</a> on rolling your own Webconverger LiveCD using his GIT repository, although being pressed for time I opted to go the <a title="BrainDeadProjects" href="http://www.braindeadprojects.com" target="_blank">BraindeadProjects</a> route: Just modify <a title="Webconverger ISO" href="http://download.webconverger.com/" target="_blank">his already released ISO</a>.</p>
<p>To begin modifying it in this manner, first mount the iso using a loopback device:</p>
<blockquote><p>#mkdir /mnt/webconverger<br />
#mount -o loop webc-7.2.iso /mnt/webconverger</p></blockquote>
<p>Next mount the <a title="Squash FS" href="http://squashfs.sourceforge.net/" target="_blank">SquashFS</a> image, also using a loopback device:</p>
<blockquote><p>#mkdir /mnt/webconverger-filesystem<br />
#mount -o loop -t squashfs /mnt/webconverger/live/filesystem.squashfs \<br />
/mnt/webconverger-filesystem</p></blockquote>
<p>As these two mounts are readonly, we need to create editable copies of each.</p>
<blockquote><p>#mkdir /devel/isolinux<br />
#rsync -av /mnt/webconverger/ /devel/isolinux/</p>
<p>#mkdir /devel/squashfs<br />
#rsync -av /mnt/webconverger-filesystem/ /devel/squashfs/</p></blockquote>
<p>Now we can go about modifying these two directories. Changing out the <a title="ISOLINUX" href="http://syslinux.zytor.com/wiki/index.php/ISOLINUX" target="_blank">ISOLINUX</a> boot splash image is an easy start. The image found under /devel/isolinux/isolinux/splash.png is actually an LSS16 image. To replace it, take or create an image 640&#215;480 in size, and convert it to 14 indexed colors. (In GIMP, these options are under Image/Index)</p>
<div id="attachment_1115" class="wp-caption aligncenter" style="width: 270px"><a href="http://www.braindeadprojects.com/blog/wp-content/indexed-gimp-splash.png"><img class="size-medium wp-image-1115" title="Indexing Colors in Gimp" src="http://www.braindeadprojects.com/blog/wp-content/indexed-gimp-splash-260x300.png" alt="" width="260" height="300" /></a><p class="wp-caption-text">Indexing Colors in Gimp</p></div>
<p>Once complete, save your image in <a title="PPM" href="http://netpbm.sourceforge.net/doc/ppm.html" target="_blank">PPM format</a>.</p>
<p>Next, you&#8217;ll need the syslinux package installed on your machine. The syslinux package includes a handy utility to convert PPM to LSS16 (for use as a bootsplash image)</p>
<blockquote><p>#ppmtolss16 &lt; /tmp/myimage-boot.ppm &gt; splash.png</p></blockquote>
<p>Since you&#8217;re already working on the ISOLINUX side of things, I recommend looking at and revising your boot menu. Once I have an image that I&#8217;m happy with, I set the following options to prevent someone from rebooting the Kiosk and tampering with boot parameters:</p>
<blockquote><p>menu background /isolinux/splash.png<br />
default /isolinux/vesamenu.c32<br />
noescape 1<br />
nocomplete 1<br />
prompt 0<br />
timeout 15<br />
allowoptions 0</p></blockquote>
<p>While you can nest a number of ISOLINUX boot configs together, I generally keep it to one file that includes the above directives. Dont&#8217; forget to include at least one label for a kernel to boot.</p>
<p>After updating the Boot Splash screen, have a look at /devel/squashfs/home/webc/pb.sh. This script is what causes IceWeasel to start, restart if closed, and sets the desktop background image (amongst other things). This script also downloads a background image from your homepage at boot &#8211; which can come in handy if you want to rotate daily ads.  I&#8217;ve personally modified my installation to always load the same background image, and fullscreen that image.</p>
<p>The webpage that appears each time IceWeasel starts is passed as kernel boot parameter (homepage). To update the homepage, simply edit the labels in the ISOLINUX  directory.</p>
<p>You will notice that when pressing the home button in the browser however, that you&#8217;re actually taken to an about: page that gives details about the current IceWeasel build. To configure this homepage, look at /usr/lib/iceweasel/browserconfig.properties</p>
<blockquote><p>browser.startup.homepage=www.braindeadprojects.com</p></blockquote>
<p>I personally like to lock things down a bit more than the standard release. For that reason I also add the following to /etc/iceweasel/pref/local.js</p>
<blockquote><p>pref(&#8220;network.protocol-handler.external.snews&#8221;, false);<br />
pref(&#8220;network.protocol-handler.external.news&#8221;, false);<br />
pref(&#8220;network.protocol-handler.external.irc&#8221;, false);<br />
pref(&#8220;network.protocol-handler.external.mail&#8221;, false);<br />
pref(&#8220;network.protocol-handler.external.mailto&#8221;, false);</p></blockquote>
<p>Another thing that may prove beneficial is to remove any and all remnants of xterm. As xorg does depend upon xterm, it will have to be forceably removed. This is best done in a chroot environment</p>
<blockquote><p>#chroot /devel/squashfs/ /bin/bash<br />
#dpkg &#8211;force-all -p xterm<br />
#exit</p></blockquote>
<p>Once you have your modifications complete, you will want to re-squash the squash filesystem. To do this, you&#8217;ll need squashfs-tools version 4 (Centos is currently distributing version 3, so do keep that in mind). Squashing using version 3 of the tools will result in a non-bootable kiosk.</p>
<blockquote><p>#mksquashfs /devel/squashfs/ /tmp/webc.squashfs<br />
#mv /tmp/webc.squashfs /devel/isolinux/live/filesystem.squashfs<br />
#cd /devel/isolinux/<br />
#mkisofs -o /tmp/my-webc.iso -b -r -J -l -cache-inodes -allow-multidot -no-emul-boot \<br />
-boot-load-size 4 -boot-info-table -b  isolinux/isolinux.bin -c isolinux/boot.cat \<br />
/devel/isolinux</p></blockquote>
<p>Finally, isohybrid your ISO:</p>
<blockquote><p>isohybrid /tmp/my-webc.iso</p></blockquote>
<p>I highly recommend testing your ISO image in <a title="VirtualBox" href="www.virtualbox.org/ " target="_blank">VirtualBox</a>. Using VirtualBox (or any other virtualization option), saves you from constantly burning an image to  a CD or USB drive. Be mindful that you can skip the isohybrid step and test with VirtualBox, although you won&#8217;t be able to install it later using dd.</p>
<p>Once you have an image that you&#8217;re happy with, use dd to copy the ISO onto the hard drive of your Kiosk machine. Personally, I copy my ISO to a USB thumbdrive running the Gentoo Based  <a title="System Rescue CD" href="http://www.sysresccd.org/Main_Page" target="_blank">System Rescue CD</a>, boot into it and then install onto the harddrive:</p>
<blockquote><p>dd if =/livemnt/boot/kiosk/my-kiosk.iso of=/dev/sda</p></blockquote>
<p>&nbsp;</p>
<p>Of course, one could save time and simply use the <a title="WebConvergers Customization Service" href="http://webconverger.com/buy/" target="_blank">WebConverger Customization Service</a>&#8230; but why not use this as an opportunity to sharpen one&#8217;s skills.</p>
<p>Coming soon to &#8211; a walkthrough on how to build and customize a WebConverger ISO from Kai&#8217;s GIT repository (as opposed to re-rolling his ISO).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/customizing-the-webconverger-kiosk-the-fast-way/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Back in the dark ages</title>
		<link>http://www.braindeadprojects.com/blog/what/back-in-the-dark-ages/</link>
		<comments>http://www.braindeadprojects.com/blog/what/back-in-the-dark-ages/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 18:26:52 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[BrainDeadTip]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=830</guid>
		<description><![CDATA[Recently (don&#8217;t ask me why, seriously) I had to migrate a physical Redhat 9 server to a virtualized platform (KVM). Yes, ideally one rebuilds the deprecated server anew, but due to time-constraints and a number of other issues that wasn&#8217;t a possibility. Unfortunately, sometimes you just have no choice but to kick the can down [...]]]></description>
			<content:encoded><![CDATA[<p>Recently (don&#8217;t ask me why, seriously) I had to migrate a physical <a title="Redhat 9" href="http://www.redhat.com/about/presscenter/2003/press_rhl9.html">Redhat 9 </a>server to a virtualized platform (<a title="KVM" href="http://www.linux-kvm.org/page/Main_Page">KVM</a>).</p>
<p>Yes, ideally one rebuilds the deprecated server anew, but due to time-constraints and a number of other issues that wasn&#8217;t a possibility. Unfortunately, sometimes you just have no choice but to kick the can down the street.</p>
<p>The migration from physical to virtual is simple &#8211; create the virtual guest, create an <a title="LVM" href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29">LVM</a> logical volume for the disk,  format it and rsync the contents from the physical to the virtual drive. After that, install grub on the guest and voila &#8211; you&#8217;re done.</p>
<p>Keeping some consistency (although unnecessary), I went with an <a title="The EXT3 filesystem" href="http://en.wikipedia.org/wiki/Ext3" target="_blank">EXT3 filesystem</a> on the &#8220;new&#8221; guest. Unfortunately, I came across the following snags:</p>
<ul>
<li>The inode size used in Redhat 9 is 128 bytes, but modern systems (ie: the host I formatted the partitions from ) use 256 bytes.</li>
<li>There&#8217;s a number of attributes that weren&#8217;t present in Redhat 9.</li>
</ul>
<p>Here&#8217;s the output of tune2fs on a Redhat 9 EXT3 partition:</p>
<blockquote><p># tune2fs -l /dev/hda1<br />
tune2fs 1.32 (09-Nov-2002)<br />
Filesystem volume name:   /boot<br />
Last mounted on:          &lt;not available&gt;<br />
Filesystem UUID:          9e6fa853-18bc-4c08-bb7c-51c74e0c11ae<br />
Filesystem magic number:  0xEF53<br />
Filesystem revision #:    1 (dynamic)<br />
Filesystem features:      <strong>has_journal filetype ﻿needs_recovery ﻿ sparse_super</strong><br />
Default mount options:    (none)<br />
Filesystem state:         clean<br />
Errors behavior:          Continue<br />
Filesystem OS type:       Linux<br />
Inode count:              8032<br />
Block count:              32096<br />
Reserved block count:     1604<br />
Free blocks:              17451<br />
Free inodes:              7982<br />
First block:              1<br />
Block size:               1024<br />
Fragment size:            1024<br />
Blocks per group:         8192<br />
Fragments per group:      8192<br />
Inodes per group:         2008<br />
Inode blocks per group:   251<br />
Filesystem created:       Tue Oct 26 12:48:49 2010<br />
Last mount time:          Thu Oct 28 15:58:10 2010<br />
Last write time:          Thu Oct 28 15:58:10 2010<br />
Mount count:              11<br />
Maximum mount count:      28<br />
Last checked:             Tue Oct 26 12:48:49 2010<br />
Check interval:           15552000 (6 months)<br />
Next check after:         Sun Apr 24 12:48:49 2011<br />
Reserved blocks uid:      0 (user root)<br />
Reserved blocks gid:      0 (group root)<br />
First inode:              11<br />
Inode size:               <strong>128</strong><br />
Journal UUID:             &lt;none&gt;<br />
Journal inode:            8<br />
Journal device:           0&#215;0000<br />
First orphan inode:       0</p></blockquote>
<p>The following is output from a Centos 5.5 formatted EXT3 filesystem:</p>
<blockquote><p># tune2fs -l /dev/mapper/VolGroup00-LogVol00<br />
tune2fs 1.39 (29-May-2006)<br />
Filesystem volume name:   &lt;none&gt;<br />
Last mounted on:          &lt;not available&gt;<br />
Filesystem UUID:          7384cac8-b098-4c85-be6d-643443ae3d3d<br />
Filesystem magic number:  0xEF53<br />
Filesystem revision #:    1 (dynamic)<br />
Filesystem features:     <strong> has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file</strong><br />
Default mount options:    user_xattr acl<br />
Filesystem state:         clean<br />
Errors behavior:          Continue<br />
Filesystem OS type:       Linux<br />
Inode count:              6809088<br />
Block count:              6807552<br />
Reserved block count:     340377<br />
Free blocks:              6204875<br />
Free inodes:              6752521<br />
First block:              0<br />
Block size:               4096<br />
Fragment size:            4096<br />
Reserved GDT blocks:      1022<br />
Blocks per group:         32768<br />
Fragments per group:      32768<br />
Inodes per group:         32736<br />
Inode blocks per group:   1023<br />
Filesystem created:       Thu Oct 28 13:31:34 2010<br />
Last mount time:          Thu Oct 28 17:43:57 2010<br />
Last write time:          Thu Oct 28 17:43:57 2010<br />
Mount count:              2<br />
Maximum mount count:      -1<br />
Last checked:             Thu Oct 28 13:31:34 2010<br />
Check interval:           0 (&lt;none&gt;)<br />
Reserved blocks uid:      0 (user root)<br />
Reserved blocks gid:      0 (group root)<br />
First inode:              11<br />
Inode size:              <strong> 128</strong><br />
Journal inode:            8<br />
Default directory hash:   tea<br />
Directory Hash Seed:      42eb54b3-8f66-4aef-8578-388c9863423c<br />
Journal backup:           inode blocks</p></blockquote>
<p>As you can see, some basic features and the inode size has changed in 10+ years. The solution:  format the &#8220;new&#8221; guest  to match the specs of the old:</p>
<blockquote><p>#mke2fs -O has_journal,filetype,sparse_super,^ext_attr,^resize_inode,^dir_index \<br />
-I 128 -j /dev/sda$disk</p></blockquote>
<p>And that&#8217;s it- rysnc the files over to the guest VM, install grub, verify your fstab is good, and voila &#8211; you&#8217;ve transferred a physical server to a virtual one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/back-in-the-dark-ages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quit Googling your Passwords</title>
		<link>http://www.braindeadprojects.com/blog/what/quit-googling-your-passwords/</link>
		<comments>http://www.braindeadprojects.com/blog/what/quit-googling-your-passwords/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 22:09:14 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[BrainDeadTip]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1034</guid>
		<description><![CDATA[Recently, I noticed someone using one of the QuickSearch toolbars included in Firefox as a place to temporarily paste something while working on their desktop. It makes sense, you need to place to hold something for a moment &#8211; it&#8217;s right there and readily available. And since you&#8217;re not pressing the Enter key, it&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I noticed someone using one of the QuickSearch toolbars included in <a title="FireFox" href="http://www.mozilla.com/" target="_blank">Firefox</a> as a place to temporarily paste something while working on their desktop.</p>
<div id="attachment_1041" class="wp-caption aligncenter" style="width: 273px"><a href="http://www.braindeadprojects.com/blog/wp-content/putithere.png"><img class="size-full wp-image-1041" title="I'll put it here" src="http://www.braindeadprojects.com/blog/wp-content/putithere.png" alt="" width="263" height="227" /></a><p class="wp-caption-text">Put it here temporarily?</p></div>
<p>It makes sense, you need to place to hold something for a moment &#8211; it&#8217;s right there and readily available. And since you&#8217;re not pressing the Enter key, it&#8217;s not going to be sent anywhere right?</p>
<p>Well, actually it is. After you stop typing, it immediately sends an <a title="HTTP POST" href="http://en.wikipedia.org/wiki/POST_%28HTTP%29" target="_blank">HTTP POST </a>request to it&#8217;s target (<a title="Google" href="http://www.google.com" target="_blank">Google</a> in this case). And while the search does takes place, it doesn&#8217;t update your browser (so you might not realize it even happens). Here&#8217;s a copy of the content in the packet:</p>
<p>&nbsp;</p>
<blockquote><p>GET /complete/search?output=firefox&amp;client=firefox&amp;hl=en-US&amp;q=<strong>mysuperleetpassword </strong>HTTP/1.1<br />
Host: suggestqueries.google.com<br />
User-Agent: &lt;omitted&gt;<br />
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</p></blockquote>
<p>&nbsp;</p>
<p>Does this matter? That depends on what you put there. You probably wouldn&#8217;t pick up the phone and call Google (or <a title="Yahoo!" href="http://yahoo.com" target="_blank">Yahoo!</a>, or <a title="Bing" href="http://bing.com" target="_blank">BING</a>, etc) and tell the receptionist &#8220;Hey, my <a title="FaceBook" href="http://facebook.com" target="_blank">Facebook</a> username is &#8230; and my password is &#8230;&#8221;, but you can very easily do this by simply pasting ANYTHING in that handy little search bar.</p>
<p>Here&#8217;s a quick video of me running a packet capture and typing something into the search area. Again, I only moved my cursor &#8211; never did I press Enter (View it fullscreen for better detail).</p>
<p>&nbsp;</p>
<p><object width="480" height="390"><param name="movie" value="http://www.youtube.com/v/O7Bv4-aCRBM?fs=1&amp;hl=en_US" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="480" height="390" src="http://www.youtube.com/v/O7Bv4-aCRBM?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I wonder how much garbage accidentally falls into search engine pits like this. I&#8217;m also curious as to how many sites log mistyped passwords (think of it this way &#8211; you accidentally type your webmail password into Facebook or vice versa).</p>
<p>All the misguided traffic reminds me of  the <a title="IPv4 pollution" href="http://labs.ripe.net/Members/franz/content-pollution-18" target="_blank">pollution problem of 1.0.0.0/8</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/quit-googling-your-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blast you, PinEntry!!!</title>
		<link>http://www.braindeadprojects.com/blog/what/blast-you-pinentry/</link>
		<comments>http://www.braindeadprojects.com/blog/what/blast-you-pinentry/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 22:00:31 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1019</guid>
		<description><![CDATA[Following a recent update to my Gentoo installation at work, I found myself pestered by PinEntry acting as my new SSH Authentication Agent. Formerly, I used the normal ssh-agent, as it&#8217;s console only and doesn&#8217;t steal focus on the terminal window I&#8217;m currently working in. &#160; A quick look at the process-list shows why: gillespiem@kovacs2 [...]]]></description>
			<content:encoded><![CDATA[<p>Following a recent update to my <a title="Gentoo Linux" href="http://gentoo.org/" target="_blank">Gentoo</a> installation at work, I found myself pestered by <a title="Pin Entry" href="http://www.gnupg.org/" target="_blank">PinEntry</a> acting as my new <a title="Wikipedia - ssh-agent" href="http://en.wikipedia.org/wiki/Ssh-agent" target="_blank">SSH Authentication Agent</a>. Formerly, I used the normal ssh-agent, as it&#8217;s console only and doesn&#8217;t steal focus on the terminal window I&#8217;m currently working in.</p>
<p>&nbsp;</p>
<div id="attachment_1023" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.braindeadprojects.com/blog/wp-content/pinentry.png"><img class="size-medium wp-image-1023" title="PinEntry" src="http://www.braindeadprojects.com/blog/wp-content/pinentry-300x237.png" alt="" width="300" height="237" /></a><p class="wp-caption-text">Popups Must Die</p></div>
<p>A quick look at the process-list shows why:</p>
<blockquote><p>gillespiem@kovacs2 ~ $ ps axu | grep gpg-agent<br />
30847 ?        Ss     0:00 gpg-agent &#8211;daemon &#8211;enable-ssh-support &#8211;write-env-file /home/gillespiem/.cache/gpg-agent-info</p></blockquote>
<p>&nbsp;</p>
<p>The GPG-Agent is being run with the <strong><em>&#8211;enable-ssh-support </em></strong>flag. Here&#8217;s how you can turn it off if you&#8217;re using <a title="XFCE4" href="http://www.xfce.org/" target="_blank">XFCE4</a>:</p>
<p>The script /etc/xdg/xfce4/xinitrc handles chosing the correct authentication agent at line 129:</p>
<blockquote><p>129 # launch gpg-agent or ssh-agent if enabled.<br />
<strong>130 ssh_agent_enabled=`xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled 2&gt; /dev/null`</strong><br />
131 if test &#8220;$ssh_agent_enabled&#8221; != &#8220;false&#8221;; then<br />
132     # if the user has pam_ssh installed, it will start ssh-agent for us, but<br />
133     # of course won&#8217;t start gpg-agent.  so, if ssh-agent is already running,<br />
134     # but we want gpg-agent (and that&#8217;s not running yet) start gpg-agent<br />
135     # without ssh support<br />
136<br />
<strong>137     ssh_agent_type=`xfconf-query -c xfce4-session -p /startup/ssh-agent/type 2&gt; /dev/null`</strong><br />
138     if test -z &#8220;$ssh_agent_type&#8221;; then<br />
139         if which gpg-agent &gt;/dev/null 2&gt;&amp;1; then<br />
140             ssh_agent_type=gpg-agent<br />
141         else<br />
142             ssh_agent_type=ssh-agent<br />
143         fi<br />
144     fi</p></blockquote>
<p>To pass the first test (line 130), set ssh-agent to be enabled by running this (it only needs to be run once):</p>
<p><em><strong>xfconf-query -n -t bool -c xfce4-session  -p /startup/ssh-agent/enabled -s true<br />
</strong></em></p>
<p>To pass the second test (line 137), set /startup/ssh-agent/type to &#8230; well, pretty much anything will do, as it only tests that it&#8217;s a non-zero length string &#8211; I&#8217;m setting it to &#8220;ssh-agent&#8221;:</p>
<p><em><strong>xfconf-query -n -t string -c xfce4-session  -p /startup/ssh-agent/type -s ssh-agent</strong></em></p>
<p>If you&#8217;re currently in XFCE4, kill gpg-agent and restart XFCE. You&#8217;ll find when you return, ssh-agent will act as your SSH Authentication Agent, and gpg-agent will handle <a title="Mozilla Thunderbird Plugin" href="http://enigmail.mozdev.org/home/index.php.html" target="_blank">GPG specific transactions.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/blast-you-pinentry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BrainDeadUpgrade</title>
		<link>http://www.braindeadprojects.com/blog/what/braindeadupgrade/</link>
		<comments>http://www.braindeadprojects.com/blog/what/braindeadupgrade/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 01:02:16 +0000</pubDate>
		<dc:creator>Matthew Gillespie (admin)</dc:creator>
				<category><![CDATA[BrainDeadTip]]></category>
		<category><![CDATA[What?!]]></category>

		<guid isPermaLink="false">http://www.braindeadprojects.com/blog/?p=1008</guid>
		<description><![CDATA[Not much has happened project-wise in the last few weeks. Any free time I&#8217;ve had has gone to updating the wireless firmware to capture MAC addresses and pass them off to an Elgg plugin I&#8217;ve written. I&#8217;m still waiting on a box of 10 Servo&#8217;s from China to continue my RC Car modification project. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Not much has happened project-wise in the last few weeks. Any free time I&#8217;ve had has gone to updating the <a href="/blog/what/engenius-eoc-2610-and-openwrt-getting-started/" target="_blank">wireless firmware</a> to capture MAC addresses and pass them off to an <a href="http://elgg.org/" target="_blank">Elgg</a> plugin I&#8217;ve written. I&#8217;m still waiting on a box of 10 Servo&#8217;s from China to continue my<a href="/blog/what/every-police-car-needs-flashing-lights/" target="_blank"> RC Car modification project</a>.</p>
<p>I&#8217;ve also got plenty of work to do around the house until May.</p>
<p>But now, after almost 4 years, I&#8217;ve decided it&#8217;s time to spruce up BrainDeadProjects.com.  I&#8217;m retiring the  <a title="Glowing Brains" href="/blog/wp-content/themes/ColdBlue/images/dumbozpony.gif" target="_blank">glowing brains </a> that have been the personification of <a href="http://braindeadprojects.com" target="_blank">BrainDeadProjects</a> for these past few years. Sure, remnants will probably remain (the favicon for instance)&#8230; but now let me introduce you to &#8220;<em><strong>Tin Can Head</strong></em>&#8220;:</p>
<p><img class="aligncenter" title="TinCan Head" src="/blog/wp-content/themes/ColdBlue/images/braindeadprojects.png" alt="" width="200" height="172" /></p>
<p>Tin Can Head is the work of <a href="http://www.logodesigncreation.com" target="_blank">LogoDesignCreation.com</a>. Give them your idea, and for a modest amount  (under $60), they&#8217;ll propose a few design ideas for you. Turnaround is fast, Wired.com gave them <a href="http://www.wired.com/wired/archive/13.10/start.html?pg=13" target="_blank">a good grade</a>, and overall I have to say that I&#8217;m pretty satisfied.</p>
<p>More project updates soon, in the meantime stare at the glowing brains of Tin Can Head.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.braindeadprojects.com/blog/what/braindeadupgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.braindeadprojects.com @ 2012-02-06 08:19:44 -->
