<?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>Moonflare Blog</title>
	<atom:link href="http://blog.moonflare.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.moonflare.com</link>
	<description>Technical miscellanea by Derrick Coetzee</description>
	<lastBuildDate>Tue, 24 Apr 2012 06:47:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Full disk encryption for both Windows and Ubuntu on a dual-boot drive</title>
		<link>http://blog.moonflare.com/2012/04/18/full-disk-encryption-for-both-windows-and-ubuntu-on-a-dual-boot-drive/</link>
		<comments>http://blog.moonflare.com/2012/04/18/full-disk-encryption-for-both-windows-and-ubuntu-on-a-dual-boot-drive/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 04:43:41 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=101</guid>
		<description><![CDATA[I recently set up a dual-boot system with Windows 7 Professional and Ubuntu 11.10, both  64-bit, and I was looking to get full disk encryption for both of them, including the swap and hibernation files. It turns out that this is not too difficult, but does require a careful order of operations to get the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently set up a dual-boot system with Windows 7 Professional and Ubuntu 11.10, both  64-bit, and I was looking to get full disk encryption for both of them, including the swap and hibernation files. It turns out that this is not too difficult, but does require a careful order of operations to get the desired result. The solution below results in all of the Windows volume being encrypted, and all Ubuntu partitions <em>except</em> for the boot partition.</p>
<p><strong>Prelude and cleaning drive</strong></p>
<p>I recommend downloading the latest service pack for your version of Windows on another system while you do the rest of this &#8211; then you&#8217;ll be able to install it quickly once you&#8217;re done. Windows 7 SP1 is downloadable <a href="http://www.microsoft.com/download/en/details.aspx?id=5842">as an ISO</a>.</p>
<p>Similarly, if you have another Ubuntu machine, you may wish to update it to the most recent packages during your install, then <a href="https://help.ubuntu.com/community/AptMoveHowto">copy the packages over</a> later.</p>
<p>In this tutorial I&#8217;m describing how to build a fresh installation, so first back up any important data on the drive. If your existing drive had any sensitive data on it, use a third-party tool like CMRR&#8217;s <a href="http://cmrr.ucsd.edu/people/Hughes/SecureErase.shtml">Secure Erase</a> to do a secure wipe of it. Even if it doesn&#8217;t contain sensitive information, if it is an SSD, a secure wipe may be needed if your Windows install freezes unexpectedly.</p>
<p><strong>Install Windows</strong></p>
<p>In the Windows installer choose the option to manually partition the disk. Delete any existing partitions and then create a new one, leaving enough space for your desired Ubuntu partitions. Windows will automatically create a small system partition. Proceed with the rest of the install normally.</p>
<p><strong>Install Ubuntu</strong></p>
<p>The easiest way to get full disk encryption with Ubuntu is using the <a href="http://www.ubuntu.com/download/ubuntu/alternative-download">alternate installer CD</a>, which includes partition encryption options. Follow <a href="http://learninginlinux.wordpress.com/2008/04/23/installing-ubuntu-804-with-full-disk-encryption/">this guide</a> (&#8220;Installing Ubuntu 8.04 with full disk encryption&#8221;, yungchin, Learning in Linux) to set it up with encryption for your root partition and swap (it still works in Ubuntu 11.10). This method of encryption covers everything but the boot partition and supports hibernation and resume from an encrypted swap partition, unlike some other methods. When asked to install the bootloader, install it to the MBR.</p>
<p>Test booting into Ubuntu. You should be asked for your passphrase during boot. In my case, I had to boot in recovery mode first to install the restricted NVIDIA drivers, and then could reboot and boot in normal mode. You can also test hibernation and resume under Linux now.</p>
<p><strong>Install Grub into boot partition</strong></p>
<p>This is the trickiest bit &#8211; and I&#8217;m not even totally sure it&#8217;s necessary (because TrueCrypt may chain the old MBR when it&#8217;s installed, I&#8217;m just not sure).</p>
<p>Boot into Ubuntu. Find your boot partition device with &#8220;df&#8221;. Install grub into it with: sudo grub-setup &#8211;force (your boot partition device, e.g. /dev/sda3) (note: make sure to use grub-setup, <em>not</em> grub-install)</p>
<p>If you did not install grub into the MBR during setup, you&#8217;ll get an error saying that /boot/grub/core.img does not exist. You can create it with this command: grub-install &#8211;grub-setup=/bin/true /dev/sda (or whatever your boot device is). This will not actually write to the MBR, but will create core.img. Then try grub-setup as above.</p>
<p><strong>TrueCrypt</strong></p>
<p>Reboot into Windows, download the latest version of <a href="http://www.truecrypt.org/">TrueCrypt</a>, install it, and then open TrueCrypt and do System-&gt;Encrypt System Partition/Drive. This will encrypt your entire system partition including your swap and hibernation files, your users directory, and so on. Select to encrypt only the system partition. It will ask if you are multibooting (say yes) and if you have another bootloader loaded into the MBR (lie and say no). You do not need to erase the drive, since it has no private data on it yet.</p>
<p>It will then create a recovery disc and do a test reboot. During the test reboot, make sure you can still boot into Ubuntu normally by pressing ESC, selecting Linux from the grub menu, and entering your passphrase. Reboot, enter your TrueCrypt passphrase, and if the grub menu appears, select your Windows OS. TrueCrypt should verify that the test boot succeeded, and give you the option to being encrypting the drive. Let the drive encryption complete before proceeding (since any disk activity will slow it down). If you downloaded SP1, you may install Virtual CloneDrive while you&#8217;re waiting.</p>
<p>You now have Windows and Linux with full disk encryption on a single drive!</p>
<p><strong>Install updates on Windows and Linux</strong></p>
<p>On Windows, use Virtual CloneDrive to mount the Service Pack downloaded earlier and install it. You will have to temporarily set the boot volume created by Windows, a small volume of size 100 MB, to be the active partition in Disk Management (under Control Panel-&gt;Administrative tools-&gt;Computer Management) in order to install SP1.</p>
<p>Then retrieve any additional updates from Windows Update.</p>
<p>On Linux, install Synaptic and use its Settings-&gt;Repositories-&gt;Download from-&gt;Other-&gt;Select Best Server to choose a good package server. Then use the update manager or &#8220;sudo apt-get update &amp;&amp; sudo apt-get upgrade&#8221; to upgrade to the latest versions of packages. You can also do &#8220;sudo apt-get dist-upgrade&#8221; to upgrade your kernel.</p>
<p><strong>Is not encrypting the boot partition okay?</strong></p>
<p>Most of us don&#8217;t keep any kind of secrets in the boot partition, so the only reason to encrypt it would be to make tampering more difficult. However, this isn&#8217;t really what encryption is designed for &#8211; encryption is not authentication. Moreover, while someone could capture your passphrase by tampering with your boot files, if they had physical access anyway, they could just replace the MBR and capture it anyway. It&#8217;s still essential to ensure that you don&#8217;t leave your device unattended in a place others can access it.</p>
<p><strong>Cold boot attacks</strong></p>
<p>The primary reason that I wanted so badly to get hibernation working properly in both OSs with a fully encrypted hibernation file is that hibernation and shutting down are essentially the only viable defenses against <a href="http://en.wikipedia.org/wiki/Cold_boot_attack">cold-boot attacks</a>, an attack on disk encryption in which a person with physical access to your machine extracts and reads the contents of your memory modules before the information has faded, including your encryption keys. You should always hibernate your machine if you are leaving it unattended, especially for a long period of time or in an easily-accessible area.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2012/04/18/full-disk-encryption-for-both-windows-and-ubuntu-on-a-dual-boot-drive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expanding an Ubuntu EC2 root volume</title>
		<link>http://blog.moonflare.com/2012/04/01/expanding-an-ubuntu-ec2-root-volume/</link>
		<comments>http://blog.moonflare.com/2012/04/01/expanding-an-ubuntu-ec2-root-volume/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 08:36:52 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=97</guid>
		<description><![CDATA[I have a VM on EC2 running Ubuntu 11.10 (which hosts this very blog). I was running out of space in my initial 8 GB and decided to expand to 20 GB. It took me a while to figure out how to do this, but it&#8217;s actually quite straightforward. Create a new volume of the [...]]]></description>
			<content:encoded><![CDATA[<p>I have a VM on EC2 running Ubuntu 11.10 (which hosts this very blog). I was running out of space in my initial 8 GB and decided to expand to 20 GB. It took me a while to figure out how to do this, but it&#8217;s actually quite straightforward.</p>
<ol>
<li>Create a new volume of the desired size.</li>
<li>Launch another instance (ideally the same distro/version as the server you&#8217;re expanding, but doesn&#8217;t really matter). This server will be used to migrate the data from the old disk to the new disk.</li>
<li>Attach the new volume to the migration server as /dev/sdf and boot it up. Connect to it via SSH. Format the new volume (e.g. with &#8220;mkext4 /dev/sdf&#8221;), and mount it with &#8220;mkdir /mnt/new; mount /dev/sdf /mnt/new&#8221;.</li>
<li>Stop the instance that you want to expand the root volume for. Detach its volume. To be safe, take a snapshot at this point for backup purposes. Attach it to the migration server as /dev/sdg, and then mount it with &#8220;mkdir /mnt/old; mount /dev/sdg /mnt/old&#8221;.</li>
<li>Do: &#8220;cd /mnt/old; cp -a . /mnt/new&#8221;. The &#8220;-a&#8221; switch preserves all file attributes including owner, mode, etc. You can monitor progress easily with &#8220;df -h&#8221;.</li>
<li>Dismount the new volume. Run this command to mark the new volume as a valid root volume: e2label /dev/sdf uec-rootfs</li>
<li>Stop the migration server. Detach the new volume from the migration server, and attach it to the original server as &#8220;/dev/sda1&#8243; (it suggests /dev/sdf, etc. but you can type &#8220;/dev/sda1&#8243; in directly).</li>
<li>Start up the original server. Make sure to reassociate the public IP if necessary.</li>
</ol>
<p>And now I have 60% space free! Let me know if you have trouble with this or need extra steps to get it working in your environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2012/04/01/expanding-an-ubuntu-ec2-root-volume/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Eclipse&#8217;s EGit with GitHub</title>
		<link>http://blog.moonflare.com/2012/03/31/eclipse-egit-with-github/</link>
		<comments>http://blog.moonflare.com/2012/03/31/eclipse-egit-with-github/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 05:51:00 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=94</guid>
		<description><![CDATA[Although most people seem to rely on the command-line git client, I recently tried to get Eclipse integration for Git going in order to help someone out who was not so command-line savvy. But I want them to also be able to store their public repositories on GitHub easily. So I figured out how to [...]]]></description>
			<content:encoded><![CDATA[<p>Although most people seem to rely on the command-line git client, I recently tried to get Eclipse integration for Git going in order to help someone out who was not so command-line savvy. But I want them to also be able to store their public repositories on GitHub easily. So I figured out how to go about this on Ubuntu 11.10, using the standard version of Eclipse, currently version 3.7.0, and installed version 1.3.0 of EGit. I relied on the <a href="http://wiki.eclipse.org/EGit/User_Guide/Getting_Started">Getting Started</a> and <a href="http://wiki.eclipse.org/EGit/User_Guide/Remote#Pushing_a_Local_Repository_to_GitHub">Pushing a Local Project to GitHub</a> parts of the EGit user guide.</p>
<p>Plugin installation:</p>
<ol>
<li>Open Eclipse. Make sure it is either installed in your home directory (user directory on Windows) or that you are running as root/administrator.</li>
<li>I read claims that EGit comes with version 3.7.0, but it didn&#8217;t come with mine. To see if yours has it, go to Help-&gt;About and choose &#8220;Installation Details&#8221;. If you see &#8220;Eclipse EGit&#8221;, it is already installed.</li>
<li>Go to Help-&gt;Install new software. Enter the EGit plugin update URL http://download.eclipse.org/egit/updates and hit &#8220;Add&#8230;&#8221; Enter EGit for the name. Click OK.</li>
<li>Open up the items provided and check &#8220;Eclipse EGit&#8221;, &#8220;EGit Project Set Support&#8221;, and &#8220;Eclipse JGit&#8221;. Don&#8217;t check the remaining items.</li>
<li>Click Next. Continue clicking Next until the install is complete, then Finish.</li>
<li>Close Eclipse and re-open it as your normal user.</li>
</ol>
<p>Setting up keys (must be done only once per user)</p>
<ol>
<li>Go to Window-&gt;Preferences. Select General-&gt;Network connections-&gt;SSH2.</li>
<li>If you have already generated a key pair for use with Github, skip to step 4. Otherwise, go to the Key management tab and select Generate RSA Key. Then click Save Private Key to save the private key file, which you will use in step 3. Copy the public key. If you wish to use an existing key pair you generated in the past, instead click Load Existing Key, then copy the public key.</li>
<li>Go to Github, log in, click your username in the upper-right, click the &#8220;Edit your profile&#8221; button, click SSH keys, click Add SSH key, and paste in the public key from step 2.</li>
<li>Go back to the Eclipse SSH2 preferences. Select the General tab. Click Browse and select the directory where your private key is stored. Enter its filename in the &#8220;Private keys&#8221; field.</li>
</ol>
<p>Putting a new/existing project into a new GitHub repository</p>
<ol>
<li>Go to Github. Click your username in the upper-right. Click New repository.</li>
<li>Fill out the fields and click &#8220;Create repository&#8221;. You will be given an information screen. You&#8217;ll need to refer back to this screen.</li>
<li>Go to Eclipse. Create/open the project.</li>
<li>Right-click the project in the Package Explorer pane and select Team-&gt;Share Project. Select Git. Click Next.</li>
<li>Click &#8220;Create&#8221;. Enter a name (the same name as your GitHub repository is fine). Click OK. Click Finish. Your project should now say next to it &#8220;NO-HEAD&#8221;.</li>
<li>Right-click your project, choose Team-&gt;Commit. The name should be the name you wish your check-ins to be attributed to, and the e-mail should match the one given on Github&#8217;s information page from step 2 (after user.email).</li>
<li>Check all the files you want to commit &#8211; you should usually include at least any source files, &#8220;.classpath&#8221;, and &#8220;.project&#8221;. Enter a commit message. Click OK.</li>
<li>Right-click your project, choose Team-&gt;Remote-&gt;Push. On Github&#8217;s information page from step 2, find the line that looks like &#8220;git remote add origin git@github.com:username/Blah.git&#8221; and copy the part after &#8220;origin&#8221;. Put it in the &#8220;URI&#8221; field.</li>
<li>For Protocol select SSH. Change nothing else. Click Next. If you are asked to accept Github&#8217;s host key, click Yes.</li>
<li>For Source ref select from the dropdown &#8220;master [branch]&#8220;. Destination ref will fill in with the same. Click &#8220;Add all branches spec&#8221;. Click Finish.</li>
<li>Refresh the information screen on Github to verify your check-in completed successfully.</li>
</ol>
<p>Importing an existing GitHub repository</p>
<ol>
<li>Choose File-&gt;Import. Select Git-&gt;Projects from Git. Click Next.</li>
<li>Choose URI. Click Next.</li>
<li>On the GitHub project&#8217;s page, click &#8220;SSH&#8221; (selected by default), then copy the full URI (starting with git@&#8230;). Make sure it says &#8220;Read+Write access&#8221; to the right of it.</li>
<li>Enter the URI in Eclipse. Select SSH for protocol. Click Next.</li>
<li>Select the branches you want (usually only one, master, will be offered and will be automatically selected). Click Next.</li>
<li>Select where the local files and git metadata will be stored. The default should be fine. Click Next.</li>
<li>If it is an Eclipse project previously added using EGit, choose Import existing project. Otherwise choose one of the other options.</li>
<li>Click Next. Click Finish.</li>
</ol>
<p>Once you&#8217;ve gotten your project set up, try right-clicking on source files and messing around with the options under &#8220;Team&#8221; to see what they do. &#8220;Show in history&#8221; is particularly useful, opening the history view which allows you to explore previous versions of files. If you do Team-&gt;Commit, it should automatically select previously committed files that have changes, but new files have to be checked to add them.</p>
<p>You can use the &#8220;Compare with&#8221; menu to view changes to your file over time; &#8220;Compare with HEAD revision&#8221; shows changes since your last commit. Compare views dynamically update as you make modifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2012/03/31/eclipse-egit-with-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flickr geofences and EXIF metadata</title>
		<link>http://blog.moonflare.com/2012/03/12/flickr-geofences-and-exif-metadata/</link>
		<comments>http://blog.moonflare.com/2012/03/12/flickr-geofences-and-exif-metadata/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 05:02:46 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=84</guid>
		<description><![CDATA[Flickr recently implemented geofences, a simple but neat mechanism to hide locations of photos taken near your home, your kid&#8217;s school, or any other place whose location you consider private. You set the center point, radius, and who should be able to see locations of those photos. There is one enormous problem with this: if [...]]]></description>
			<content:encoded><![CDATA[<p>Flickr recently implemented geofences, a simple but neat mechanism to hide locations of photos taken near your home, your kid&#8217;s school, or any other place whose location you consider private. You set the center point, radius, and who should be able to see locations of those photos.</p>
<p>There is one enormous problem with this: if your Flickr is set up to allow downloads of original images, those original images are unprocessed/unmodified and contain any EXIF data that was in the original file. If your camera automatically inserts location information using a GPS, or you added it using a third-party tool, most likely it&#8217;s still available in there. Flickr, to their credit, has a giant scary warning about this:</p>
<p><em>Please note: If you upload a photo with geo data, that info will be embedded in the EXIF data of the original file. If you don’t want people to have access to this information, you should restrict who can download your originals.</em></p>
<p><em></em>This is a terrible solution however, since I want people to have the full-size versions of my images. Is there another way?</p>
<p>Turns out yes, but it requires some manual steps and is a bit taxing:</p>
<ol>
<li>Visit <a href="http://www.flickr.com/map/">http://www.flickr.com/map/</a> and visit the private location. Zoom until only the area you want to remove location information from is in view (or as close as possible).</li>
<li>Use &#8220;Search the map&#8221; and select &#8220;Your photostream&#8221; to show only your photos.</li>
<li>There is a strip with two arrows listing every photo of yours in the map area. Click each one and, if it is close enough to your center point, open it in a new tab. (Don&#8217;t use the pink bubbles on the map itself. The pink bubbles may not be displayed for every photo or may be hard to click on.) Download the original size versions of each of them. Put them all in a single directory.</li>
<li>Strip the geographical EXIF data. To do this: Install <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">exiftool</a>. Make sure it&#8217;s in your path. Open a command prompt, cd to the directory where you downloaded the files, and type: exiftool -a -gps:all= *<br />
Note that this will destroy the EXIF data forever, so make a private copy of the images first if you want to preserve the original versions with full EXIF data. Flickr location data, although based on your EXIF data, is stored separately and will still be displayed to you and people permitted to see inside your geofence.</li>
<li>Use &#8220;Actions-&gt;Replace this photo&#8221; to re-upload the modified images over the old ones. When replacing, you can easily find the matching image by copying the last bit of the URL after the final &#8220;/&#8221;, which will be the prefix of the filename.</li>
<li>You have to do this again if you upload new photos in this area, preferably before your initial upload for maximum security &#8211; if you do it afterwards, someone quick enough may still grab the data.</li>
</ol>
<div>This is quite a pain and I hope Flickr will in the future make it easy to automatically remove GPS EXIF from photos inside your geofence.</div>
<div>Geofences can be dangerous and can actually give <em>more</em> information about your location if you&#8217;re not careful. If you take many photos in the area just outside the perimeter of the circle, anyone looking at your photostream on Flickr will notice a giant empty circle with a very precise center location. A sufficiently clever attacker could infer the circle&#8217;s center from an even smaller number of photos. This isn&#8217;t a concern if most of your photos are not taken anywhere near you, but keep it in mind.</div>
<div>Also note that if you implement a geofence that covers existing images, anyone who is already actively tracking you will notice exactly which locations were hidden. This will point out which ones are near you. For this reason it&#8217;s best used as a pre-emptive measure.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2012/03/12/flickr-geofences-and-exif-metadata/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Redirecting access log with .htaccess</title>
		<link>http://blog.moonflare.com/2012/02/11/redirecting-access-log-with-htaccess/</link>
		<comments>http://blog.moonflare.com/2012/02/11/redirecting-access-log-with-htaccess/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 15:46:02 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=79</guid>
		<description><![CDATA[I had an account on a seedbox server with a shared web server. The access logs were off limits to me, and the admins weren&#8217;t about to reconfigure the server for me. But I really wanted to see who was accessing my site. What to do? Turns out I do have .htaccess on this server. [...]]]></description>
			<content:encoded><![CDATA[<p>I had an account on a seedbox server with a shared web server. The access logs were off limits to me, and the admins weren&#8217;t about to reconfigure the server for me. But I really wanted to see who was accessing my site. What to do?</p>
<p>Turns out I do have .htaccess on this server. However, the access log is not one of the configurable parameters. But through a hackish combination of several tricks, I can log all accesses to my public_html tree. Here&#8217;s my .htaccess:</p>
<pre>RewriteEngine on
RewriteCond %{REQUEST_URI} !^/hitcounter.php
RewriteRule ^ http%1://www.%{HTTP_HOST}/hitcounter.php?uri=%{REQUEST_URI} [L,R=301]</pre>
<p>It redirects all incoming accesses to the &#8220;hitcounter.php&#8221; script, which logs the access to a file called &#8220;log&#8221; in the usual Apache access log format:</p>
<pre>&lt;?php
if (getenv(HTTP_X_FORWARDED_FOR)) {
    $ip = getenv(HTTP_X_FORWARDED_FOR);
    $vip = getenv(REMOTE_ADDR);
} else {
    $ip = getenv(REMOTE_ADDR);
}
$uri = $_GET['uri'];
$date = date('d/m/Y:H:i:s O');
$fh = fopen('log', 'a');
fwrite($fh, "$ip - - [$date] \"GET $uri HTTP/1.0\" 200 -\n");
fclose($fh);

header("Location: /nocount$uri");
?&gt;</pre>
<p>At the end of the script it redirects to the original URL prepended with &#8220;/nocount&#8221;. The directory &#8220;/nocount&#8221; simply contains symbolic links to everything in the webroot, along with a new .htaccess that turns rewriting back off again:</p>
<pre>RewriteEngine off</pre>
<p>One handy feature of this is I can bookmark or give out links containing &#8220;nocount&#8221; and those won&#8217;t be logged, so I can avoid self-logging. Downside is, this particular scheme results in &#8220;/nocount&#8221; being prepended to all my URLs.</p>
<p>I ended up abandoning this scheme because I was using my web server to web seed torrents and these redirects confused and broke the uTorrent client somehow. It also turned out to be unnecessary because Feral Hosting actually lets me configure my own private Apache server even on shared hosts via the .apache2 directory in my home directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2012/02/11/redirecting-access-log-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Eclipse with PyDev for Python development in Ubuntu</title>
		<link>http://blog.moonflare.com/2011/11/23/installing-eclipse-with-pydev-for-python-development-in-ubuntu/</link>
		<comments>http://blog.moonflare.com/2011/11/23/installing-eclipse-with-pydev-for-python-development-in-ubuntu/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 21:31:34 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=69</guid>
		<description><![CDATA[The following instructions been tested with Ubuntu 11.04 (Natty Narwhal), Eclipse 3.5.2, Python 2.7.1+, and PyDev 2.2.1, all of which were current on 2011 August 22. They were later tested again with Ubuntu 11.10 (Oneiric Ocelot). Installation part based on this blog entry, with modifications. Installing Sun JDK First, assuming you want to use the Sun JDK, we [...]]]></description>
			<content:encoded><![CDATA[<p>The following instructions been tested with Ubuntu 11.04 (Natty Narwhal), Eclipse 3.5.2, Python 2.7.1+, and PyDev 2.2.1, all of which were current on 2011 August 22. They were later tested again with Ubuntu 11.10 (Oneiric Ocelot).</p>
<p>Installation part based on <a href="http://techcolleague.com/2011/02/install-eclipse-and-pydev-on-ubuntu/">this blog entry</a>, with modifications.</p>
<h2>Installing Sun JDK</h2>
<p>First, assuming you want to use the Sun JDK, we need to get access to the Sun JDK package. Uncomment this in your /etc/apt/sources.list:</p>
<p>deb http://archive.canonical.com/ubuntu natty partner<br />
deb-src http://archive.canonical.com/ubuntu natty partner</p>
<p>And do this (from <a href="http://myubuntuarchive.blogspot.com/2011/03/java-on-ubuntu.html">this post</a>):</p>
<p>sudo add-apt-repository ppa:sun-java-community-team/sun-java6<br />
sudo apt-get update</p>
<p>Install Eclipse and Sun JDK and plug-in:</p>
<p>sudo apt-get install eclipse sun-java6-jdk sun-java6-jre sun-java6-bin sun-java6-plugin</p>
<p>Accept license terms when prompted. After this completes, make Sun&#8217;s JDK the default:</p>
<p>sudo update-java-alternatives -s java-6-sun</p>
<h2>Installing PyDev</h2>
<ol>
<li>Run Eclipse and then go to Help | Install New Software</li>
<li>Click Add&#8230; next to the &#8220;Work with&#8221; drop down. Specify the following:<br />
<strong>Name</strong>: PyDev<br />
<strong>URL</strong>: http://pydev.org/updates</li>
<li>Check &#8220;PyDev&#8221;. Do not check &#8220;Pydev Mylyn Integration&#8221;. Press Next.</li>
<li>Press Next again, accept license terms, click Finish to begin install. Installation may proceed in background &#8211; see lower-right of the window for status.</li>
<li>If prompted to accept a certificate, click Select All, then OK. If prompted to restart Eclipse, click Yes.</li>
<li>Open Windows | Preferences | Pydev | Interpreter &#8211; Python.</li>
<li>Click Auto Config. A &#8220;selection needed&#8221; window will appear for the SYSTEM pythonpath. Click Select All, click OK.</li>
<li>When Auto Config completes, click OK and wait for Pydev to scan your system Python libraries.</li>
</ol>
<p>PyDev installation is now complete.</p>
<h2>Trying out PyDev</h2>
<p>To create a new (fresh) Python project in Eclipse with PyDev:</p>
<ol>
<li>Click File | New | Project | PyDev | PyDev Project, and click Next.</li>
<li>Enter a project name. Click Finish.</li>
<li>An Open Associated Perspective dialog will appear. Check the checkbox and click Yes.</li>
<li>Right-click &#8220;src&#8221; and choose New | PyDev Module. Enter a Name (you need not enter a Package). Click Finish.</li>
<li>Type some Python into the text file, like:<br />
print(&#8216;hello world&#8217;.capitalize())<br />
You can press ENTER to autocomplete the capitalize() call while typing it.</li>
<li>Click Run | Run. Leave set to &#8220;Python Run&#8221; and click OK. A Console window tab should appear showing the program output.</li>
<li>Add the following two lines of source code:<br />
x = &#8216;hello there&#8217;<br />
print(x)<br />
Right-click in the margin to the left of the first source code line and choose &#8220;Add Breakpoint&#8221;.</li>
<li>Choose Run | Debug. When &#8220;Confirm Perspective Switch&#8221; appears, check the box and click Yes.</li>
<li>Execution will break at the first line. Select Run | Step Over, click the &#8220;Step Over&#8221; toolbar button, or press F6 to step through the source code line by line. After stepping over the line &#8220;x = &#8216;hello there&#8217;&#8221; the variable x should appear in the &#8220;Variables&#8221; window (you may have to scroll it down). Use Run | Debug or F11 to start the program over again during debugging.</li>
<li>When done debugging, click the &#8220;PyDev perspective&#8221; in the upper right hand corner to return to the normal source editing view.</li>
<li>To use PyDev with an existing Python project you&#8217;re working on, see &#8220;<a href="http://pydev.org/manual_101_project_conf.html#creating-a-project-from-existing-sources">Creating a Project from existing sources</a>&#8220;.</li>
</ol>
<h2>Keyboard shortcuts</h2>
<div>Important keyboard shortcuts to know with PyDev:</div>
<div>
<ul>
<li>F3: Go to definition</li>
<li>CTRL+SHIFT+G: Find all references (this one isn&#8217;t even in the menus!)</li>
<li>CTRL+SHIFT+B: Add breakpoint</li>
<li>F11: Run in debug mode</li>
<li>F6: Step over</li>
<li>F5: Step into</li>
</ul>
<div>See <a href="http://pydev.org/manual_adv_keybindings.html">Appcelerator PyDev keyboard shortcut list</a> for more, or press CTRL+SHIFT+L.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2011/11/23/installing-eclipse-with-pydev-for-python-development-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby 1.9.2 and gems on Ubuntu 11.10</title>
		<link>http://blog.moonflare.com/2011/10/25/installing-ruby-1-9-2-and-gems-on-ubuntu-11-10/</link>
		<comments>http://blog.moonflare.com/2011/10/25/installing-ruby-1-9-2-and-gems-on-ubuntu-11-10/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 07:24:37 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=64</guid>
		<description><![CDATA[By default, the &#8220;ruby&#8221; package on Ubuntu 11.10 (Oneiric) refers to an older version of Ruby, 1.8.7 &#8211; probably for compatibility reasons. To use the newest version of Ruby and Gem, do: sudo apt-get install ruby1.9.1 update-alternatives --config ruby (select the option reading &#8220;/usr/bin/ruby1.9.1&#8243;) update-alternatives --config gem (select the option reading &#8220;/usr/bin/gem1.9.1&#8243;) Contrary to their [...]]]></description>
			<content:encoded><![CDATA[<p>By default, the &#8220;ruby&#8221; package on Ubuntu 11.10 (Oneiric) refers to an older version of Ruby, 1.8.7 &#8211; probably for compatibility reasons. To use the newest version of Ruby and Gem, do:</p>
<ul>
<li><code>sudo apt-get install ruby1.9.1</code></li>
<li><code>update-alternatives --config ruby</code></li>
<li>(select the option reading &#8220;/usr/bin/ruby1.9.1&#8243;)</li>
<li><code>update-alternatives --config gem</code></li>
<li>(select the option reading &#8220;/usr/bin/gem1.9.1&#8243;)</li>
</ul>
<p>Contrary to their names, <code>/usr/bin/ruby1.9.1</code> is actually a newer version (1.9.2p290 at the present time) and <code>/usr/bin/gem1.9.1</code> is actually RubyGems 1.3.7 (there is no RubyGems 1.9.1). These numbers refer to the package name ruby1.9.1.</p>
<p>During a &#8220;bundle install&#8221;, depending on what gems are being installed, you may encounter other errors. I encountered the following three:</p>
<ul>
<li>
<pre>ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
&lt;internal:lib/rubygems/custom_require&gt;:29:in `require': no such file or load -- mkmf (LoadError)
from &lt;internal:lib/rubygems/custom_require&gt;:29:in `require`
from extconf.rb:5:in `&lt;main&gt;'</pre>
<p><strong>To fix this one do:</strong> <code>apt-get install ruby1.9.1-dev</code></p>
<pre>ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----</pre>
<p><strong>To fix this one do:</strong> <code>apt-get install libxml2-dev</code></p>
<pre>ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----</pre>
<p><strong>To fix this one do:</strong> <code>apt-get install libxslt1-dev</code></li>
<li>
<pre>Installing sqlite3 (1.3.4) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 + universal'
or 'yum install sqlite3-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).</pre>
<p><strong>To fix this one do:</strong> <code>sudo apt-get install libsqlite3-dev</code></li>
<li>
<pre>Gem::InstallError: hoe requires RubyGems version &gt;= 1.4. Try 'gem update --system' to update RubyGems itself.</pre>
<p>Version 1.9.2 of the &#8220;hoe&#8221; gem requires a newer version of RubyGems than is presently available via the Ubuntu package manager. You have to force an upgrade with:</p>
<pre>sudo REALLY_GEM_UPDATE_SYSTEM=1 gem update --system</pre>
<p>After doing so, you must redo &#8220;gem install bundler&#8221; and &#8220;bundle install&#8221;. Note that this might screw up other things, since you&#8217;re upgrading gem outside the package manager interface now.</li>
</ul>
<p>If these instructions don&#8217;t work for you, or you encounter problems with other gems and figure out how to fix them, please post in the comments below!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2011/10/25/installing-ruby-1-9-2-and-gems-on-ubuntu-11-10/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Getting the ASUS USB-N13 working under FreeNAS</title>
		<link>http://blog.moonflare.com/2011/10/21/getting-the-asus-usb-n13-working-under-freenas/</link>
		<comments>http://blog.moonflare.com/2011/10/21/getting-the-asus-usb-n13-working-under-freenas/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 05:22:03 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=61</guid>
		<description><![CDATA[I set up a new FreeNAS system today that is dual-homed, with a wired connection to an isolated Gigabit LAN (for performance), and a wireless connection to the Internet (for updates, management, etc.). Since my HP ProLiant MicroServer did not come with built-in wireless, I got a USB wireless card, the ASUS-N13, that has a [...]]]></description>
			<content:encoded><![CDATA[<p>I set up a new FreeNAS system today that is dual-homed, with a wired connection to an isolated Gigabit LAN (for performance), and a wireless connection to the Internet (for updates, management, etc.). Since my HP ProLiant MicroServer did not come with built-in wireless, I got a USB wireless card, the ASUS-N13, that has a good record of compatibility with Linux and FreeBSD.</p>
<p>However out-of-the-box, FreeNAS is a very minimal distribution, missing a lot of kernel modules needed to make this device work. To fix this, I followed these steps:</p>
<ul>
<li>Download the installer ISO for the matching version and platform of FreeBSD.</li>
<li>Mount the ISO and dug into /boot/kernel</li>
<li>Use &#8220;mount -uw /&#8221; on the NAS to remount the root as read/write so you can write to /boot and /conf.</li>
<li>Use scp to upload the following kernel modules from the FreeBSD ISO to your running FreeNAS install under /boot/kernel:</li>
<ul>
<li>if_run.ko runfw.ko wlan*.ko</li>
</ul>
<li>Edit /boot/loader.conf and add the lines:
<pre>if_run_load="YES"
runfw_load="YES"</pre>
</li>
<li>Go to /conf/base/etc and edit/create the necessary files as described in the <a href="http://www.freebsd.org/doc/handbook/network-wireless.html">FreeBSD Handbook Wireless Networking Guide</a>. I have a WPA-authenticated network so I created wpa_supplicant.conf and edited rc.conf to add:
<pre>wlans_run0="wlan0"
ifconfig_wlan0="WPA DHCP"</pre>
<p>Note the use of &#8220;<code>run0</code>&#8221; here, since this device uses the &#8220;run&#8221; kernel module.</li>
<li>Copy your modified files from /conf/base/etc to /etc and test with:
<pre>/etc/rc.d/netif start</pre>
<p>If you connect successfully, ping a host like google.com to confirm connectivity.</li>
<li>Reboot. Log back in. Use /sbin/ifconfig and ping to confirm you are still connected.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2011/10/21/getting-the-asus-usb-n13-working-under-freenas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running Ubuntu Server 11.10 Linux on the Thecus N7700 NAS</title>
		<link>http://blog.moonflare.com/2011/10/17/running-ubuntu-server-11-10-linux-on-the-thecus-n7700-nas/</link>
		<comments>http://blog.moonflare.com/2011/10/17/running-ubuntu-server-11-10-linux-on-the-thecus-n7700-nas/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 21:02:44 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=53</guid>
		<description><![CDATA[A couple years ago I bought the Thecus N7700, a low-end NAS with 7 hot swappable SATA disks. I wanted an affordable solution that would give me a lot of capacity at home for raw photos, videos, and ISOs/VMs, so I filled it with consumer-grade 2 TB disks in RAID 5 configuration. Unfortunately, I would [...]]]></description>
			<content:encoded><![CDATA[<p>A couple years ago I bought the <a href="http://www.thecus.com/product.php?PROD_ID=14">Thecus N7700</a>, a low-end NAS with 7 hot swappable SATA disks. I wanted an affordable solution that would give me a lot of capacity at home for raw photos, videos, and ISOs/VMs, so I filled it with consumer-grade 2 TB disks in RAID 5 configuration. Unfortunately, I would soon discover that Thecus has a very short &#8220;compatibility list&#8221; of drives they test with, all of them enterprise-grade disks, and the drives I bought were not on it. On at least a dozen occasions, the system reported I/O errors with one or more disks. I would reboot and rebuild the RAID, then check the SMART data, just to discover the disks had experienced no errors at all &#8211; it was a firmware issue. Despite releasing many updates to the firmware since then (several of which claimed to fix this issue), the problem persists.</p>
<p>Fortunately, the machine is x86 and made entirely of commodity parts, so it&#8217;s possible to install any OS I like on it. The catch is, it has no VGA out. However, it does have integrated video on the motherboard &#8211; they just didn&#8217;t solder a connector onto it. Following the <a href="http://www.andymillar.co.uk/blog/2010/04/11/installing-linux-on-a-thecus-n8800pro/">directions here</a>, I disassembled one end of a VGA cable (first I used a flathead screwdriver to push off the plastic cover, then used some needlenose pliers to twist the metal tabs until they broke off, exposing the pins). I then poked the pins through a small piece of paper, for insulation, and inserted them directly into the motherboard. The VGA holes are at the back of the motherboard near the other connectors. I was successful in getting VGA out, although it took quite a bit of fiddling with the angle of the cable to make it touch things just right &#8211; in the future I may want to solder a connector onto the board for convenience. Once I&#8217;d done this, I could plug in a USB keyboard and hit DEL to enter BIOS at boot and turn on USB booting &#8211; note that you do not want to set USB-CDROM/USB-FDD etc. as the boot device, but rather you must plug in a USB flash drive first, which the BIOS will correctly see as a disk device, and then change the priority of boot disk devices. After that, I could set up the USB flash drive with any installer or OS I wanted &#8211; I used an 8 GB flash drive. There are alternative ways to getting another OS to run on the board &#8211; like replacing the internal 128 MB flash drive &#8211; but it&#8217;s much easier to diagnose boot issues if you can see the VGA out.</p>
<p>I started out by installing FreeNAS, just to discover it doesn&#8217;t support the N7700&#8242;s SATA controller. Next I tried Openfiler but couldn&#8217;t get it to boot from USB (although this might be possible). Finally I decided to go with the freshly-released Ubuntu Server 11.10 Linux. I used <a href="http://unetbootin.sourceforge.net/">Unetbootin</a> to put its installer ISO onto my USB key, and sure enough it could see all my disks. Catch is, I wanted to install it to the USB key, but I was using that for the installer. The internal flash drive was too small to install to (128 MB). The Thecus N7700 only has two USB ports &#8211; if I had a second USB flash drive and a USB hub handy, I would&#8217;ve just installed directly onto the second USB key (I recommend trying this), but I didn&#8217;t, so instead I installed onto a small root partition on one of my RAID hard drives, sized to match the USB flash drive. It failed to install Grub to the MBR during install, but I ignored this. Afterwards, I attached both the flash drive and the disk to my PC, repartitioned the flash drive in Parted Magic, and then used Clonezilla to copy the installed partition from my hard disk to the flash drive. There was a small catch to this: I had to create a tiny 1 MB partition before my Ubuntu partition and mark it as a <a href="http://www.gnu.org/software/grub/manual/grub.html#BIOS-installation">BIOS boot partition</a> for Grub. Then, I used the Ubuntu 11.10 Desktop Live CD in live mode to chroot into the Ubuntu filesystem (see <a href="http://fermilinux.fnal.gov/documentation/tips/mount-bind-chroot">this guide to chrooting</a> involving mount -o bind) and run &#8220;install-grub /dev/sdb&#8221;, where /dev/sdb was my USB flash device, and &#8220;update-grub&#8221;. At this point the device was bootable.</p>
<p>Once I had booted up the device, I had to fix some annoyances. First of all, device names of disks can change between boots, particularly if you remove or add disks. To deal with this I created /etc/udev/rules.d/nas-disk.rules with the following contents:</p>
<pre>SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0000000000000000-lun-0", SYMLINK+="nasa"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0100000000000000-lun-0", SYMLINK+="nasb"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0200000000000000-lun-0", SYMLINK+="nasc"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0300000000000000-lun-0", SYMLINK+="nasd"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0000000000000000-lun-0", SYMLINK+="nase"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0100000000000000-lun-0", SYMLINK+="nasf"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0200000000000000-lun-0", SYMLINK+="nasg"</pre>
<p>Now, /dev/nasa thorugh /dev/nasg referred to my seven disks in order from the top down. Warning: if you mount any volumes in your /etc/fstab, make sure you include the &#8220;nobootwait&#8221; option. Otherwise, if a volume fails to mount for any reason during boot, it will just sit there waiting for you to press S, before even starting the SSH server.</p>
<p>Once I had done this I installed a number of useful packages:</p>
<ul>
<li>sshd: Already installed during installation, lets me administer the machine over the network with the box closed and no VGA cable attached.</li>
<li>mdadm: Needed for software RAID support.</li>
<li>xfsprogs reiserfsprogs btrfs-tools hfsprogs: Tool support for additional filesystems.</li>
<li>nfs-kernel-server: Lets me share files with other UNIX machines over NFS. (see <a href="https://help.ubuntu.com/community/SettingUpNFSHowTo">this guide</a> &#8211; I found it useful to set no_root_squash so my client had free access)</li>
<li>samba: Installed during installation, lets me share files with Windows clients.</li>
<li>webmin: Gives me a remote web administration interface on port 10000 that I can use to, among other things, create, modify, and destroy RAID partitions.</li>
<li>smartmontools: Allows me to regularly check the SMART data of my disks and run self-tests, and report any problems.</li>
<li>transmission-daemon: Provides a web interface for BitTorrent downloads. Requires some configuration, see <a href="https://forum.transmissionbt.com/viewtopic.php?f=8&amp;t=8361">this guide</a>.</li>
<li>sysstat: Includes iostat, which lets me view current disk activity.</li>
<li>open-iscsi open-iscsi-tools: iSCSI support (not currently using this but I used to use iSCSI exclusively and manage the volume as NTFS on Windows clients).</li>
</ul>
<p>At first I considered running btrfs on my NAS, which is a very promising up-and-coming competitor to ZFS, but there&#8217;s no official stable release quite yet and I&#8217;m uncertain about performance. ZFS itself is only available in alpha form on Linux, primarily due to licensing issues. I ended up running XFS because it&#8217;s mature and handles volumes with many large files well.</p>
<p>Some notes on RAID: I used software RAID 5 over 5 disks with mdadm. It starts in degraded state, then rebuilds, and will send mail to root about this, so don&#8217;t be alarmed. You can use it right away if you want (although this slows down rebuild), and you can monitor the rebuild process via SSH with <code>while true; do cat /proc/mdstat; sleep 5; done</code>.</p>
<p>Note that if you do modify the OS of your Thecus N7700, the disk LEDs and LCD display will no longer work. The LCD display will show &#8220;Running self tests&#8221; forever, and the blue and red LEDs will also remain on and not flashing indefinitely. I believe a sufficiently clever person could reverse engineer their interface and provide a command-line utility or daemon to control them, which would be quite handy, but I don&#8217;t need it. The power and network LEDs should still work fine.</p>
<p>Note that if you insert or remove drives, or boot without the USB flash drive attached, you may accidentally alter the disk boot priority order in BIOS, causing the internal flash drive to gain priority, or causing the flash drive to fall off the list. If this happens, you still need the VGA cable to get back into BIOS to fix it. To mitigate this problem, I recommend completely erasing the internal flash drive by filling it with zeros: <code>dd if=/dev/zero of=/dev/sda bs=128M</code> (make sure it&#8217;s /dev/sda on your machine though!)</p>
<p><strong>Warning: When you close back up the case, remember to plug back in the case fans. Seven disks generate a lot of heat and you will fry your machine if you don&#8217;t do this.</strong> Sadly I destroyed my Thecus this way only a single day after getting my RAID set up, so I can&#8217;t say much about long-term use.</p>
<p>Let me know if you have any problems with this, and please share your own experiences! To close this out, here is a bunch of data about the Thecus N7700 system that you may find useful if you&#8217;re trying to get another distro or OS running on it:</p>
<p><strong>lspci</strong>:</p>
<pre>00:00.0 Host bridge: Intel Corporation Mobile 945GME Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)
00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 02)
00:1c.2 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 3 (rev 02)
00:1c.3 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 4 (rev 02)
00:1c.4 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 5 (rev 02)
00:1c.5 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 6 (rev 02)
00:1d.0 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation 82801GHM (ICH7-M DH) LPC Interface Bridge (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA AHCI Controller (rev 02)
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02)
02:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
04:00.0 RAID bus controller: Marvell Technology Group Ltd. 88SE6440 SAS/SATA PCIe controller (rev 02)
05:00.0 RAID bus controller: Marvell Technology Group Ltd. 88SE6440 SAS/SATA PCIe controller (rev 02)</pre>
<p><strong>/proc/cpuinfo</strong></p>
<pre>processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 14
model name      : Intel(R) Celeron(R) M CPU        440  @ 1.86GHz
stepping        : 12
cpu MHz         : 1866.707
cache size      : 1024 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx constant_tsc up arch_perfmon bts aperfmperf pni monitor tm2 xtpr pdcm dts
bogomips        : 3733.41
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 32 bits virtual
power management:</pre>
<p><strong>/proc/meminfo</strong></p>
<pre>MemTotal:        1023884 kB</pre>
<p><strong>lsmod</strong></p>
<pre>Module                  Size  Used by
serio_raw              12990  0
i915                  505108  1
drm_kms_helper         32889  1 i915
drm                   192226  2 i915,drm_kms_helper
i2c_algo_bit           13199  1 i915
video                  18908  1 i915
lp                     17455  0
parport                40930  1 lp
raid10                 30270  0
usb_storage            44173  1
raid456                61518  1
async_raid6_recov      12906  1 raid456
async_pq               12959  2 raid456,async_raid6_recov
uas                    17699  0
ahci                   21634  0
libahci                25727  1 ahci
mvsas                  51615  8
libsas                 62786  1 mvsas
scsi_transport_sas     34482  2 mvsas,libsas
e1000e                139775  0
raid6_pq               88205  2 async_raid6_recov,async_pq
async_xor              12738  3 raid456,async_raid6_recov,async_pq
xor                    21860  1 async_xor
async_memcpy           12481  2 raid456,async_raid6_recov
async_tx               13123  5 raid456,async_raid6_recov,async_pq,async_xor,async_memcpy
raid1                  26291  0
raid0                  17067  0
multipath              12977  0
linear                 12792  0</pre>
<p><strong>smartctl -a /dev/hda</strong> (info about the internal flash drive)</p>
<pre>Device Model:     128MB ATA Flash Disk
Serial Number:    C191100004A12b39GGwP
Firmware Version: AD B512D
User Capacity:    128,057,344 bytes [128 MB]
Sector Size:      512 bytes logical/physical
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 3a
SMART support is: Available - device has SMART capability.
SMART support is: Enabled</pre>
<p><strong>/proc/ioports</strong></p>
<pre>0000-0cf7 : PCI Bus 0000:00
  0000-001f : dma1
  0020-0021 : pic1
  0040-0043 : timer0
  0050-0053 : timer1
  0060-0060 : keyboard
  0064-0064 : keyboard
  0070-0073 : rtc0
  0080-008f : dma page reg
  00a0-00a1 : pic2
  00c0-00df : dma2
  00f0-00ff : fpu
  0170-0177 : 0000:00:1f.1
    0170-0177 : ata_piix
  01f0-01f7 : 0000:00:1f.1
    01f0-01f7 : ata_piix
  02f8-02ff : serial
  0376-0376 : 0000:00:1f.1
    0376-0376 : ata_piix
  03f6-03f6 : 0000:00:1f.1
    03f6-03f6 : ata_piix
  03f8-03ff : serial
  0400-04bf : pnp 00:08
    0400-0403 : ACPI PM1a_EVT_BLK
    0404-0405 : ACPI PM1a_CNT_BLK
    0408-040b : ACPI PM_TMR
    0428-042f : ACPI GPE0_BLK
  04d0-04d1 : pnp 00:01
  0500-051f : 0000:00:1f.3
  0680-06ff : pnp 00:01
  0880-088f : pnp 00:01
0cf8-0cff : PCI conf1
0d00-ffff : PCI Bus 0000:00
  8000-8fff : PCI Bus 0000:04
    8f00-8f7f : 0000:04:00.0
      8f00-8f7f : mvsas
  9000-9fff : PCI Bus 0000:03
    9f00-9f1f : 0000:03:00.0
  a000-afff : PCI Bus 0000:02
    af00-af1f : 0000:02:00.0
  b000-bfff : PCI Bus 0000:01
  c000-cfff : PCI Bus 0000:05
    cf00-cf7f : 0000:05:00.0
      cf00-cf7f : mvsas
  d000-dfff : PCI Bus 0000:06
  f300-f30f : 0000:00:1f.2
    f300-f30f : ahci
  f400-f403 : 0000:00:1f.2
    f400-f403 : ahci
  f500-f507 : 0000:00:1f.2
    f500-f507 : ahci
  f600-f603 : 0000:00:1f.2
    f600-f603 : ahci
  f700-f707 : 0000:00:1f.2
    f700-f707 : ahci
  f800-f80f : 0000:00:1f.1
    f800-f80f : ata_piix
  fb00-fb1f : 0000:00:1d.3
    fb00-fb1f : uhci_hcd
  fc00-fc1f : 0000:00:1d.2
    fc00-fc1f : uhci_hcd
  fd00-fd1f : 0000:00:1d.1
    fd00-fd1f : uhci_hcd
  fe00-fe1f : 0000:00:1d.0
    fe00-fe1f : uhci_hcd
  ff00-ff07 : 0000:00:02.0</pre>
<p><strong>/proc/iomem</strong></p>
<pre>00000000-0000ffff : reserved
00010000-0009a7ff : System RAM
0009a800-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
  000a0000-000bffff : Video RAM area
000c0000-000dffff : PCI Bus 0000:00
  000c0000-000c7fff : Video ROM
000e0000-000effff : pnp 00:0b
000f0000-000fffff : reserved
  000f0000-000fffff : System ROM
00100000-3fddffff : System RAM
  01000000-01534783 : Kernel code
  01534784-017bbd7f : Kernel data
  01870000-01946fff : Kernel bss
3fde0000-3fde2fff : ACPI Non-volatile Storage
3fde3000-3fdeffff : ACPI Tables
3fdf0000-3fdfffff : reserved
3fe00000-febfffff : PCI Bus 0000:00
  d0000000-dfffffff : 0000:00:02.0
  e0000000-efffffff : PCI MMCONFIG 0000 [bus 00-ff]
    e0000000-efffffff : reserved
      e0000000-efffffff : pnp 00:0a
  fd300000-fd3fffff : PCI Bus 0000:02
  fd400000-fd4fffff : PCI Bus 0000:02
    fd4c0000-fd4dffff : 0000:02:00.0
      fd4c0000-fd4dffff : e1000e
    fd4fc000-fd4fffff : 0000:02:00.0
      fd4fc000-fd4fffff : e1000e
  fd500000-fd5fffff : PCI Bus 0000:01
  fd600000-fd6fffff : PCI Bus 0000:06
  fd700000-fd7fffff : PCI Bus 0000:06
  fd800000-fd8fffff : PCI Bus 0000:01
  fd900000-fd9fffff : PCI Bus 0000:05
    fd900000-fd93ffff : 0000:05:00.0
  fda00000-fdafffff : PCI Bus 0000:05
    fdaff000-fdafffff : 0000:05:00.0
      fdaff000-fdafffff : mvsas
  fdb00000-fdbfffff : PCI Bus 0000:04
    fdb00000-fdb3ffff : 0000:04:00.0
  fdc00000-fdcfffff : PCI Bus 0000:04
    fdcff000-fdcfffff : 0000:04:00.0
      fdcff000-fdcfffff : mvsas
  fdd00000-fddfffff : PCI Bus 0000:03
  fde00000-fdefffff : PCI Bus 0000:03
    fdec0000-fdedffff : 0000:03:00.0
      fdec0000-fdedffff : e1000e
    fdefc000-fdefffff : 0000:03:00.0
      fdefc000-fdefffff : e1000e
  fdf00000-fdf7ffff : 0000:00:02.0
  fdf80000-fdfbffff : 0000:00:02.0
  fdffc000-fdffc3ff : 0000:00:1f.2
    fdffc000-fdffc3ff : ahci
  fdfff000-fdfff3ff : 0000:00:1d.7
    fdfff000-fdfff3ff : ehci_hcd
fec00000-ffffffff : reserved
  fec00000-fec003ff : IOAPIC 0
  fed13000-fed1dfff : pnp 00:0b
  fed20000-fed8ffff : pnp 00:0b
  fee00000-fee00fff : Local APIC
    fee00000-fee00fff : pnp 00:0b
  ffb00000-ffb7ffff : pnp 00:0b
  fff00000-ffffffff : pnp 00:0b</pre>
<p><strong>/proc/interrupts</strong></p>
<pre>           CPU0
  0:        304   IO-APIC-edge      timer
  1:          4   IO-APIC-edge      i8042
  8:          1   IO-APIC-edge      rtc0
  9:          0   IO-APIC-fasteoi   acpi
 14:      23215   IO-APIC-edge      ata_piix
 15:          0   IO-APIC-edge      ata_piix
 16:   88518197   IO-APIC-fasteoi   uhci_hcd:usb5, mvsas, i915
 17:   92740547   IO-APIC-fasteoi   mvsas
 18:          0   IO-APIC-fasteoi   uhci_hcd:usb4
 19:          0   IO-APIC-fasteoi   uhci_hcd:usb3
 23:    1014224   IO-APIC-fasteoi   ehci_hcd:usb1, uhci_hcd:usb2
 48:          0   PCI-MSI-edge      ahci
 49:     745524   PCI-MSI-edge      eth1-rx-0
 50:     667535   PCI-MSI-edge      eth1-tx-0
 51:          3   PCI-MSI-edge      eth1
NMI:          0   Non-maskable interrupts
LOC:   19023450   Local timer interrupts
SPU:          0   Spurious interrupts
PMI:          0   Performance monitoring interrupts
IWI:          0   IRQ work interrupts
RES:          0   Rescheduling interrupts
CAL:          0   Function call interrupts
TLB:          0   TLB shootdowns
TRM:          0   Thermal event interrupts
THR:          0   Threshold APIC interrupts
MCE:          0   Machine check exceptions
MCP:        262   Machine check polls
ERR:          0
MIS:          0</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2011/10/17/running-ubuntu-server-11-10-linux-on-the-thecus-n7700-nas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What to do when there&#8217;s no MD5</title>
		<link>http://blog.moonflare.com/2011/10/09/what-to-do-when-theres-no-md5/</link>
		<comments>http://blog.moonflare.com/2011/10/09/what-to-do-when-theres-no-md5/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 21:31:26 +0000</pubDate>
		<dc:creator>dcoetzee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.moonflare.com/?p=38</guid>
		<description><![CDATA[I recent downloaded a large number of very large files (mostly Linux distribution ISOs), and wanted to verify that the downloads were successful. I also wanted to have a hash file on hand to re-verify the downloads later on, in case of disk corruption. Many distributions include MD5, SHA1, or SHA256 hash files with their [...]]]></description>
			<content:encoded><![CDATA[<p>I recent downloaded a large number of very large files (mostly Linux distribution ISOs), and wanted to verify that the downloads were successful. I also wanted to have a hash file on hand to re-verify the downloads later on, in case of disk corruption. Many distributions include MD5, SHA1, or SHA256 hash files with their distributions right on the download web page, but many others don&#8217;t. If you encounter a situation like this, there are several ways to work around the problem:</p>
<ol>
<li>Right-click on the download link for the large file and then strip components of the URL to view the directory it&#8217;s in. Often that same directory will contain either a hash file for that large file (e.g. blah.iso.md5 or blah.md5), or a hash file for all the files in the directory (MD5SUMS). Similarly, try taking the filename and adding &#8220;.md5&#8243; or replacing the extension with &#8220;.md5&#8243; (or the same with .sha1) and then Googling that to see if it&#8217;s hiding somewhere else.</li>
<li>If the file is hosted on SourceForge, SourceForge provides SHA1 and MD5 hashes for every file on their site. Just go to the &#8220;Files&#8221; section of the project, find the directory the file is in, and then click the &#8220;i&#8221; information bubble to the right of the filename.</li>
<li>If there is a Torrent for the file, either download using that in the first place, or just open the Torrent file and point it at your existing file for seeding. Not only will this verify your file, but any corruption will be detected and fixed at the block level, so you don&#8217;t have to re-download the whole file. Once you&#8217;ve verified the file with your Torrent client, you can safely use a hash tool like md5sum to compute your own hash file for it.</li>
<li>If the file is a compressed archive, such as a ZIP, .gz, .bz2, .xz, or .7z file, attempt to decompress it (when using gunzip/bunzip2/xz, make sure to pass &#8211;keep to keep the original input file around, because you might still need its hash later). A ISO may also contain hash files for files inside the image &#8211; check for these by using &#8220;mount -o loop&#8221; (or Daemon Tools/Virtual CloneDrive under Windows). There&#8217;s not an fsck for ISO 9660 that I know of, but you can scan through an ISO filesystem by using a command like &#8220;grep -r randomstring *&#8221; or &#8220;findstr /s randomstring *&#8221; in the root of the mounted ISO, where &#8220;randomstring&#8221; is a string that does not occur in any file. If any of these tests fail, the image is corrupt (but if they succeed, it does not necessarily prove that it is valid).</li>
<li>If none of the above apply, things get tricky. Compute the MD5 and SHA1 hashes of the file using md5sum and sha1sum, then type them into Google. If you get any search results, it is extremely likely that your file is valid and someone else who downloaded it has posted their hash on a forum or digest listing (any false positives would indicate a hash collision, which these hashes are designed to make very unlikely).</li>
<li>Finally, suppose you get no Google results. At this point, your only recourse is to re-download the file and compare the SHA1 of the two files. If they are identical, your file is good (provided of course the server&#8217;s copy is good &#8211; use an official server for at least one of the downloads). If they are different, redownload it again. Continue to redownload it until you get at least two files of the correct size with identical hashes. At this point you can be reasonably assured the file is valid (since two invalid versions are <em>usually</em> different from one another). If you get this far, be sure to post your MD5, SHA1, and SHA256 hashes, along with the original URL and a description of the file, on a public forum so that others can benefit. You might even create and publish a torrent for the file on a relevant torrent tracking website.</li>
</ol>
<div>At first I was quite surprised that downloads can have invalid hashes at all, since TCP is supposed to ensure reliable transport. Unfortunately, HTTP/FTP downloads have a bad habit of either truncating early due to timeout, so it really is important to verify &#8211; at least 10% of my non-Torrent downloads were bad. However, most of them were <em>merely truncated</em> and could be resumed safely using &#8220;wget -c&#8221;, so at least I didn&#8217;t have to start the downloads over.</div>
<div>What&#8217;s a good way to fix the problem of files having no hashes available? Re-downloading files repeatedly is no fun if you&#8217;re paying per megabyte. These problems could be solved in principle using a special custom download manager. Here&#8217;s my basic design:</div>
<div>
<ul>
<li>Whenever someone downloads a file, they would upload the URL and a hash tree for the file to a central server. If that hash is already on the server for that URL, it gets another vote. If it&#8217;s already on the server for another URL, those two URLs are marked as mirrors of one another.</li>
<li>If someone downloads a file others have downloaded before, and their hash does not match the hash with the most votes for that URL, it&#8217;s probably corrupt. They can use the hash tree uploaded by other successful downloaders together with download resume server features to selectively re-download just the corrupt parts.</li>
<li>Finally, even if no one else has downloaded the file, once it has been re-downloaded twice, any portions of the file which are byte-for-byte identical are probably both correct. Only portions which are different need to be re-downloaded.</li>
<li>Once at least two or three people have downloaded a file and both got the same hash, it makes sense to automatically set up a torrent for the file so that downloaders can begin to share bandwidth if they wish to, while still taking advantage of the main HTTP/FTP server (web seeding). A lot of distributions set up community torrents but don&#8217;t web seed them, leading to them becoming very slow (especially for less popular files).</li>
</ul>
<div>Just some ideas &#8211; I&#8217;m not sure if I&#8217;ll have time to work on this, and it would require a certain critical mass of users to be effective, but I think it&#8217;d be very useful.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.moonflare.com/2011/10/09/what-to-do-when-theres-no-md5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

