Thanks, Digital Ocean

$5 per month for a VPS? What could possibly go wrong? Well lots actually. As the saying goes you get what you pay for, so when I decided to create my first droplet with Digital Ocean I wasn’t expecting a whole lot. Some users on HackerNews had rave reviews about them and me being frugal was always looking for a cheaper VPS host. So I created a droplet and copied this site over from AWS to them.

Things were working swell for a very a while, then my internet at home went on the fritz. While using a hotspot to make my last post I also decided to login to my droplet and do an apt update. And that’s when the problems arose.

See, I wanted to configure a proxy that I could use from any hotspot in Paris, since I don’t trust hotspots and I need the internet for banking and accounts (see DNS spoofing) I wanted a connection I could trust. So I installed some proxy onto my droplet. For $5 more I should have bought another. And then the connection died. No http, ssh, nor ping. I could no longer reach my droplet, my website was gone, and I was trying to fix this over a wireless hotspot that jumped APs every few minutes. No problem, I told myself I’ll log into the web console and fix it. The web console never worked on my Mac. So I did the same from a PC running Firefox and that just showed me a black screen.

Rebooting the server showed the server was stuck at init-bottom. This is the point in the boot sequence where grub should exit and the kernel is supposed to take over, and it wasn’t happening. Back at the droplet control panel I tried a few different kernels and stopped at the same point. I sent a ticket to Digital Ocean and the support team suggested I boot using the DO-Recovery kernel. That recovery kernel dropped me into a busybox shell but it didn’t have the tools I needed to access a borked LVM volume and it didn’t have network drivers. So not only could I not access the partition, but even if I did I wouldn’t be able to do a whole lot.

I opened another ticket to get a LiveCD boot (any distro). The support team came through again and got me into a Ubuntu LiveCD shell where I was able to open the volume with this site. Then I realized I had no network access and raised it with DO who straightened it out almost immediately.

With my volume mounted and reachable from the network I created another droplet with the same configuration as the broken server then using SCP I copied over my files, databases, and configurations to the new droplet. Some file permissions had to be edited but everything is right where I left it. And that is where we are today.

So I’d like to thank Digital Ocean and their invaluable support team for helping me get things back on track!

Raspberry Pi and SDR, Getting started

Due to the limited availability of free time I’ve had the raspberry pi has been sitting in a box unused, and unloved for a very long time. Looking for a project that was inexpensive and didn’t require a lot of loose wires hanging around I got involved in using SDR. SDR stands for Software Defined Radio and is where traditional radio components (tuners, clocks, modulators) are handled in software. Most popular SDR uses are USB TV Sticks such as this one.

After thinking long and hard about this (okay, 2 minutes) I put in an order for this USB DVB-T stick. It was even cheaper than the previous link and the reseller was a Prime reseller so it would get here quick. I should have done more research, according to the SDR wiki what I really wanted was a chipset that used the E4000 or R820T tuner chip. The RTL software lists mine as a Fitipower FC0013 which has half the range of the E4000. No worries, you learn and you learn.

So now that I’ve got the USB stick I needed to get the software that would interface with it. With the Raspberry Pi plugged in and fully booted I proceeded to install all the necessary files.

Here are the steps I used:
Step 0. Update and upgrade your system.
# sudo apt-get update; sudo apt-get upgrade

Step 1. Install the build tools
# sudo apt-get install git cmake build-essential libusb-1.0-dev

Step 2. Download the SDR files
# cd /tmp
# git clone git://git.osmocom.org/rtl-sdr.git

Step 3. Compile and install
# cd rtl-sdr
# mkdir build; cd build
# cmake ../ -DINSTALL_UDEV_RULES=ON
# make
# sudo make install
# sudo ldconfig

Step 4. Test
# rtl_test -t
Found 1 device(s):
0: Sweex DVB-T USB

Using device 0: Sweex DVB-T USB
usb_open error -3
Please fix the device permissions, e.g. by installing the udev rules file rtl-sdr.rules
Failed to open rtlsdr device #0.

Hmm, okay appears to be a problem. Let’s test with root permissions

# sudo rtl_test -t
Found 1 device(s):
0: Sweex DVB-T USB

Using device 0: Sweex DVB-T USB
Found Fitipower FC0013 tuner
Supported gain values (23): -9.9 -7.3 -6.5 -6.3 -6.0 -5.8 -5.4 5.8 6.1 6.3 6.5 6.7 6.8 7.0 7.1 17.9 18.1 18.2 18.4 18.6 18.8 19.1 19.7
No E4000 tuner found, aborting.

Yes, definitely permissions. I did everything correct in /etc/udev/rules.d so not sure why this doesn’t work with a normal account.

The radio is on and working with Raspberry Pi. Now I can try some other tests
# sudo rtl_adsb
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 000000041

Using device 0: Sweex DVB-T USB
Found Fitipower FC0013 tuner
Tuner gain set to automatic.
Tuned to 1090000000 Hz.
Sampling at 2000000 Hz.
Exact sample rate is: 2000000.052982 Hz
*9497464c0fd9e15ec13ac63495b4;

This pipes all ADS-B traffic to the screen. And if you have the right software you can decode the string to get position, aircraft.

Now that rtl_sdr is installed we have some alternatives that can use the USB stick now.

# git clone git://github.com/MalcolmRobb/dump1090.git
# cd dump1090
# make

Then start dump1090 to get a formatted ADS-B table
# ./dump1090 –interactive –enable-agc
Hex Flight Altitude Speed Lat Lon Track Messages Seen .
——————————————————————————–

The RTL library includes a basic server that can be accessed over telnet. Now you can stick your Pi and USB stick in a remote location and process the results elsewhere.
# sudo rtl_tcp
Found 1 device(s).
Found Fitipower FC0013 tuner
Using Sweex DVB-T USB
Tuned to 100000000 Hz.
listening...
Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).

For many other tutorials and information visit the project wiki

Amazon EC2 and surprises

I’ve been running this blog on the micro instance of amazon EC2 for a few months now and I’m still trying my best to optimize it. The first month wasn’t so bad; I moved all the content, reattached the databases and redirected the domain name. I was in for about 7€ that month. The second month was more but I assumed a private instance should cost about 20€. There were a ton of problems. MySQL and apache were being stopped due to not enough memory or not enough swap. And sometimes the site would be completely unresponsive. This month, now that the site is getting more traffic, the bill was $30. Almost twice what I expected to pay for micro instance.

I’ve converted this server to a reserve instance. It should have been more clear when I signed up that this would be a smarter option I’d it was going to be running 24-7. But c’est la vie.

AWS EC2 Micro servers and performance

Recently I’ve been having a problem where this blog would go down because WordPress could no longer connect to the database. The EC2 instance I’m using is the smallest configuration they have, the Micro server, running on AMI Linux (it uses yum so I guess it’s Redhat-based). In the past I’ve ran this blog on servers that had even smaller configurations, some as VPS and other times shared hosting. At no time before have I experienced a problem like the one I was having. I isolated it to the Google indexing servers hammering the server. Although I wouldn’t really call it hammering as anyone opening more than 3-4 concurrent connections basically brought the server to its knees.

The solution was to add a swap file. Normally, the EC2 micro server instance doesn’t have one configured by default so I’ve written a little tutorial to get you started.

First SSH into your EC2 instance and then switch to root:
user:$ ssh -i ec2-server-keyring.pem [email protected]
$ sudo -s

Now create a swapfile (I created a 1gigabyte swapfile):
# dd if=/dev/zero of=/swapfile  bs=1m count=1024

Format the swapfile and set the kernel to use it:
# mkswap /swapfile
# swapon /swapfile

Now, if you want the swapfile to always be enabled at boot add it to the fstab:
# nano /etc/fstab

/swapfile      swap      swap      defaults      0      0

ifdown; ifup

Sorry for the unavailability the last few weeks. The server was compromised and I had to do rebuild the OS and migrate the blog to a new place. But now we’re back in business. Tomorrow I’ll write a post on how to extract data from a VMWare vmdk disk image.

Updating redmine and changing from mongrel to passenger

The support server at the office has been using redmine for a few years. When I set it up way back in the days it was configured to use a mongrel cluster behind an apache server. This setup has been great, lately it has started to show it’s age. Sometimes a mongrel would get stuck, eventually the others would suffer the same fate, and the server wouldn’t process anymore requests. So now that the holiday season is in effect I’m taking advantage of the lighter traffic to update the server.
Since this isn’t a brand new install I’m taking a different track than most other redmine installs. And I’ve found upgrading to be more fraught with problems than a clean install. This is a production machine so in addition to normal backups I have to be cautious of breaking shit irreparably.
So let’s get to work:
After logging in the update your gems

gem update --system

Depending on the version of redmine you are using you will need to update your rails accordingly.

bash#: rails --version
Rails 2.2.2

According to the redmine News page 0.9 uses Rails 2.3.5 so now is a good time to update the rest of your gems

gems update

Then download the redmine updates

cd /var/redmine/
svn update

In my case I’ve made some customization to the code and this sometimes conflicts with the update. You can monitor this by looking for ‘C’ in the left column while svn update is running.
If it isn’t done so you should install passenger

gem install passenger

As I mentioned before, redmine was running through a rails mongrel cluster. Now I’m moving it to passenger and apache. After passenger is installed it is time to build it into apache

bash: redmine# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module insaller, v2.2.8.
This installer will guide you through the entire installation process. It shouldn't take
more than 3 minutes in total.
...

At the end it will ask you to add the module to the apache configuration file. We won’t be doing that. Instead we will make a module file and use the a2enmod.

bash:redmine# nano /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.8
PassengerRuby /usr/bin/ruby1.8

Ctrl-O and Ctrl-X to save and quite. Then

bash: redmine# a2enmod passenger
Module passenger installed; run /etc/init.d/apache force-reload to enable.

Finally, update your redmine database:

bash: redmine# RAILS_ENV=production rake db:migrate
bash: redmine# RAILS_ENV=production rake db:migrate_plugins

Modify your vhost.conf file to point the DocumentRoot to the redmine/public folder (mine was just pointing to the redmine root) and then run the apache force-reload command.
If you have anything like webrick or mongrels running it is alright to terminate them now. Point your browser to your redmine site and bask in your awesomeness 🙂

Fedora Core 8…A week later

The great thing about using Linux is it’s free and the rules are really basic. The bad thing about Linux is it’s free and getting support can be a bit of a nightmare. It’s been a week since I successfully installed Fedora Core 8. After using a variety of help guides I can say that it truly rocks. Whether or not I can use it productively is another question. You see I’m a .Net developer. which means I’m closely bound to the Windows side of doing things. On my ancient and underpowered laptop getting Windows to run on VMWare can be a virtual nightmare. While it’s great as a server the GUI is pretty sluggish. But since connectivity is the safe word I can get around that by RDPing into a real windows machine.
I am a pragmatic and polyglot so I did install the Java IDE and Netbeans. Now seems like the perfect time to learn Java programming and compare it to C#.

Fedora Core 8 install, testing and testing

My ageing Acer laptop was behaving strangely since lastweek. Windows would have nearly 100% kernel usage making it completely unusable for anything. It got so bad I couldn’t get past the login screen without it locking up. System restore nor uninstalling new apps would fix this problem. Since I thought everything was lost I booted into safe mode and was able to work on the computer from there. But safe mode is not a longterm solution. Fearing the hard drive failing I ran every test I could think of to make sure. And nothing was reported out of the ordinary. As a last resort I did a reinstall of XP and after installing all the necessary drivers (sound, wifi, m/b, and graphics) the problem persisted. I tried this twice and would still end up with the same 100% kernel lockup. That’s when I decided to take another look at linux.
I previously had experience with it in university when a neighbor (yay newman hall) gave me a Redhat CD. I’ve used it on and off since then but exclusively for servers. I tried Ubuntu but found the default interface to be really garish (okay, yucky background and the buttons are cartoonish) and the screenshots of fedora looked really slick. So I popped in the installer DVD and bang nothing happens. It hangs at the /usr/sbin load and just sits there. After 30 minutes the installer resumes but fails after writing the files to the hard drive. Not one to give up I use the live installer CD. Boots up right away and no problems this time. The wifi works and besides the lag of the CD drive spooling up everytime I use the menu it looks really put together. So using this guide I was able to get it working right away.
One thing I can say about Fedora is it doesn’t have the ease of Ubuntu. I had to massage the system a little to get it working smoothly. But this can be expected on a laptop where a lot of the hardware is custom designed and poorly documented. I had to tighten down the font size and install the Webcore package from Microsoft. The default fonts are really ugly on my laptop for some reason. I’m still erked about the button arrangements. Some applications use huge icon sets for no reason. I’m sure the icons were designed by computer users who have vision problems. But on a laptop, where real estate is a premium it would be nice if the proportions were better. I like the well designed iTunes interface, Rhythmbox and Banshee are no iTunes is my conclusion. As a developer of web applications, some of the UI “features” are quirky. Gnome doesn’t test to see if it has a good connection to a windows share until after you click on the icon. Shouldn’t there be some testing done before it commits an object to the desktop. When I see “Joe’s Work share” I assume the connection went through.
It’s been installed for 4 days and I’m getting the hang of it. It brings back a lot of old memories of hacking an old alpha to run NetBSD (a server this weblog was hosted on ages ago, and a really useful foot warmer for those cold Virginia winters). It will be interesting to see how this side of the world lives.

Edgy Eft

Okay it’s done. Loaded up VMWare and did the duty of upgrading to Edgy Eft. Everything was looking great until I restarted the virtual machine. I haven’t needed to restart the VM since I upgraded the kernel last time. Imagine my surprise when my screen shrinks down to a quarter of its normal self, and the colors look really horrible. That knocked the wind out of my sails.
So what have I gotten out of this upgrade? A useless VM for the time being. But I’m an intrepid geek so this problem is going to be licked one way or another. For once in my life I would like for a milestone release to just work. Seems the proper answer is to carpet bomb the drive and start a new installation at major point release. I don’t think this is a practical solution. Especially for a developer who has installed tons of stuff in all the recesses of a running linux system. Only to have it come crashing down because part of the toolchain can’t figure out how to compile a new X library.

Detecting X.org version 7.1.
Problem extracting version of X.org
Execution aborted.

Thank you, please play again.

Linux Hell

I’ve just had the pleasure of installing Kubuntu Linux as the alternate OS on my desktop. It looks great, excellent hardware support, and seems to have all the software I want on the default installation. After using it continuously for a few days I notices a few things that really bothered me.

  • Konqueror wasn’t integrated into the OS.
    You would think the browser and window manager could launch a little faster. Like it as there the entire time. No when I want to go to my home folder I have to wait for a stupid bouncing ball before I get there. I’ve used Linux and other Unix OSs for a long time. It was not like this before. And really, I don’t need all the bells and whistles it provides, I just want access to my files.
  • KBluetooth
    Something is wrong with my bluetooth. It detects my dongle. It doesn’t see any of my bluetooth toys (namely mobile phone and headset). I’m still monkeying around with it.
  • KTorrent
    The two bittorrent clients I have installed are absolute leaches on the system. I’ve used azereus, bittornado and ktorrent. the results are all the same 25%+ CPU usage. At extremely modest sharing levels. My windows client runs quietly unless it gets a hyperactive torrent. Then the HDD whirs. But I’m still able to watch my shows. With this, no go.
  • Video on Linux
    I remember a time when the requirements to run a linux workstation were less than for windows. Now the answer seems to be to get faster hardware. I don’t seem to have this problem in bloated, 1 year installed XP on the same damn hardware. Even my G4 with half the MHz and a Mach kernel from God could play a video, download torrents, and have other programs running without a sneeze.

I’ll figure it out eventually. I would like a snazzy interface thats friendly. But MS will just have to do. I seem less and less inclined to reboot into linux.
Really, I just want my Mac back 🙁