Thursday, January 21, 2016

Cable TV

Approximately 9 years ago I did something I never thought I would do - I cancelled my cable TV subscription. No, I wasn't switching to satellite TV, I was cutting the cord completely. This marked a big turn in my life. Up until that point I always had cable TV, from a child through high school and college, and into adulthood. This marked the first time I'd ever been without cable. This post is my reflection back on that past 9 years, what's changed, would I go back, etc.

First let's talk about the biggest benefit - the savings. My best guess estimate is I've saved $11,000 in those 9 years! That's a lot of money! Before cutting cable my bill was approaching $100/month. Checking current rates they appear to be about $110/month. So an average of $100/month times 9 years equals a lot of saved money.

Another benefit I've noticed is how much more time I have. When you have cable TV it's far too easy to sit down and watch TV. But without cable when your TV only gets 9 local broadcast channels you watch a lot less TV.

A big question is - would I ever switch back to cable TV? The answer is yes, but not in its current form. There are two main things I dislike about cable TV providers in their current form, neither of which is the cost of their service.

Set-top Boxes
I hate set-top boxes.  Modern TV are cable of decoding both analog and multiple forms of digital video streams, so why would I want a set-top box?  Why add another device and another remote control?  Yes, their remote controls usually work the TV too, but this usually never works just right forcing you to keep multiple remotes on hand.  Cable companies try and convince you that the set-top box is a benefit to you.  But they are deceiving you, they want the set-top box for one main reason - they make more money!  A recent government study found the average American family spends $19.32/month renting set-top boxes.  Even if you didn't have to rent the set-top box, they still make money.  A set-top box is the cable company's gateway into the world of pay-per-view and on-demand TV watching, which is yet another revenue stream for them.

There is another reason cable companies like set-top boxes.  It allows them to control both ends of the encryption.  Digital TV signals are encrypted to prevent people from stealing cable TV.  The set-top box is what decrypts this signal.  Going back 20 years, the "cable card" technology was supposed to solve that by allowing your TV to do the decryption.  But cable card was never widely adopted by the industry.

What I would love to see is TV manufacturers and cable broadcast get together and create a standard protocol.  That way the TV you buy at the store can decrypt and view broadcasts from your cable provider without the need for a set-top box.  Of course, this will never happen (unless congress passes a law forcing it to happen), simply because set-top boxes make the cable company money.  Why would they eliminate a source of revenue?

Channel Selection
The other big issue that's preventing me from going back to cable TV is channel selection.  Cable companies are out of touch with their customers.  A recent study by Nielsen TV ratings found that between 2008 and 2013 the average number of channels a cable provider offered increased from 130 to 190.  That's an average of 12 new channels per year.  However, Nielsen discovered number of channels people actually watch stayed the same at 17.  So cable companies are offering more channels which costs more money, but people aren't watching more channels.  What's more, people are watching less than 10% of the channels they are paying for.

So I would consider going back to cable if the cable companies offered the ability to pick which channels you want, or at least have more tiers so I can have finer control of what I'm paying for.  Of course this will never happen.  Broadcasters, like Discovery channel, lock cable broadcasters into contracts.  If they want to distribute their top-tier popular channels they must also offer their bottom-of-the-barrel unpopular channels as well.


The whole industry is messed up.  I can only hope that as more and more people cut cable in favor of things like Internet streaming options that cable companies will be forced to change their ways.  In the meantime I'll enjoy an extra $100 in my wallet each month that is not going to my cable company!

Tuesday, January 5, 2016

Water savings - update

Several months ago I posted about my water bill and how my water usage had gone down by installing low-flow shower heads and dual-flush toilet conversion.  That post was only 3 months in so I wanted to do a followup now that it's almost a year since I made the changes.


The above graph is taken directly from my account on my water company's website.  It shows all months usage for 2014 and 2015.  The part shaded in red is before I made any changes in my water usage.  The part in green is after installing the water saving devices in my house.  The 2 month window between the two is a transition period.  I installed one shower head and dual-flush converter to try the products out and see if we liked them before ordering more and installing them everywhere in my house.

There are 3 months before making the switch that are deceptively low; January 2014, September 2014, and January 2015.  In all 3 cases they correspond to vacations of more than a week in length, so obviously if we're not home we're using less water.  If you ignore those 3 months, than my before usage averaged exactly 5.5 units per month (a unit being 100 cubic feet of water or 748 gallons).  After the switch that average dropped to exactly 4 units.  So we're saving approximately 1.5 units per month, or 1,122 gallons per month, 37 gallons per day, or close to 14,000 gallons in a year.

From a money-savings point of view, water in my area costs $7.90 per unit, so we're saving an average of $11.85 per month, or $142 per year.  Considering the hardware for this change cost about $120 I've recouped my investment already and each month will be savings from here on out.

Again, I did not make this switch to save money.  I made this switch to save water.  Even though it's winter and it's raining outside right now, California is still in a drought and our reservoirs are at an all-time low.  Saving water is not only the right thing to do, it's extremely important.  Saving money is just an added bonus.

Wednesday, September 9, 2015

Is Amazon Delaying Shipments?

I have been ordering things from Amazon for many years, but within the last year I've noticed a change.  I firmly believe that Amazon is intentionally delaying shipment of goods.

As I said I buy a lot of things from Amazon, but I've never had an Amazon Prime account.  Honestly I'm too cheap to pay the $100 a year for Prime when there are such easy ways around it.  Whenever there is something I want to buy I add it to my Amazon cart.  Then when my cart reaches the minimum amount for free shipping (currently $35) I place the order.  This works out nicely and it averages out to probably 12 or 15 Amazon orders per year, so I don't have to wait that long for my cart to fill up.  But I save on that $100 a year.

But as I said, within the last year something has changed.  It used to be items shipped for free arrived to my house in 3 or 4 days.  But lately Amazon orders have been arriving in about 12 days.  That's a significant change!  What's more, after I place an order I don't get the email from Amazon saying it has shipped for about a week.

I think the problem is Amazon's free shipping was too good.  If you can get free shipping that will arrive in 3 - 4 days, why would you pay a lot of money for 2-day shipping?  So it makes sense that Amazon would want to slow down the free option in an effort to encourage people to spend more for faster shipping.

However; if this is true then Amazon's plan may backfire on them.  Now anytime I order something online I check competitors like newegg.com, target.com, bestbuy.com, etc.  All of these retailers offer free shipping or free shipping to retail stores.  If I find the same item for the same or even slightly higher in price, I won't order from Amazon.  Why buy from Amazon when they won't get it to me for 2 weeks what I can order elsewhere for the same price and have it in a few days?

So Amazon, if you listening, you are losing business because you're trying to encourage people to pay for faster shipping and/or buy Amazon Prime.

Monday, August 10, 2015

Raspberry Pi as a Seafile server

My latest Raspberry Pi project is to create a personal Seafile server.  If you've never heard of Seafile before you're probably not alone.  There are a lot of "cloud" based file backup and synchronization services like Dropbox, Google Drive, and Microsoft OneDrive.  These services are great and have many uses, but they have drawbacks as well.  They all offer free accounts so long as you stay under a certain size (usually around 5GB).  There's also the issue of security.  My data is being sent from my computer over the Internet to their servers, and then back.  But how secure is this?  Is the communication between my computer and their servers secure?  Once my data is on their servers, how secure is it?  If someone hacks in can they access my data?  Can the company hosting my data access it?  And what about government agencies, do they have a backdoor into these companies servers?

There are two free open-source alternatives; Seafile and Owncloud.  Owncloud is more well-known than Seafile, but every review I read online says that Owncloud is buggy whereas Seafile is rock solid.  I also really like Seafile's security model.  My data is encrypted on my computer using a password of my choosing and strong AES-256 encryption before the data is transmitted to Seafile.  What's more, the data is only decrypted on my device after downloading from Seafile.  In otherwords my password is never transmitted to Seafile which means hackers, Seafile themselves, and the NSA cannot access my data.

Because of this, years ago I signed up for a free Seafile account and I have grown to love it!  Unfortunately Seafile has a very low limit, only 1 GB at the time I signed up.  This isn't enough to effectively backup to, but I have used it for years as a sync point.  I have two computers at home and one at work and this makes a great place to put documents and files I want synchronized across all machines.  But I wanted more storage so I decided to create my own Seafile server at home.

Before I start my guide a few points:
  • I will be setting up a Seafile server with nginx as the web server, HTTPS for the communications, and SQLite as the back-end database.  This arrangement is a great combo for a single user or a small number of users.
  • There are a number of existing guides on how to do this.  Here's a great guide, this one is in German, and the official Seafile manual has generic Linux instructions.  But I found problems with each of these guides, things like missing steps.  So I combined all these into a single end-to-end guide to get this working.
  • I assume you know at least some Linux.  I'm not going to explain how to use tools like nano.  If you've never used Linux before then this entire process is probably over your head.  But if you know at least a little bit about Linux you should be good to go.
  • You should know how to SSH into a Linux system.  Most of the following is done while connected to the Raspberry Pi via an SSH connection.
  • I will be setting up my Seafile server for access both inside and outside my home network.  For this to work you'll need a DDNS account.  There are a number of both free and paid DDNS services.



Hardware:
For this project obviously you'll need a Raspberry Pi.  I used a Raspberry Pi B+.  But this would work with any Raspberry Pi.  In fact, this would be a perfect use for a model A since you won't need a lot of USB and the extra power savings means less electricty.  For the power supply I went with this one which I've used on previous Pi projects.  The 2amp supply will be overkill for this project, but it's a known good supply.  I decided to try a new case and went with this one.  I got the Edimax EW-7811Un wifi dongle.  I would have preferred to hard wire it, but my wireless router is out of empty ports so I went wireless.  And since this will be low-bandwidth it won't matter.  To complete the hardware I went with a 32GB Samsung EVO micro SD card.  This card will hold both the OS and the Seafile data.



Software:
On the software side of things I used Raspbian (version 2015-05-05).  You will also need Seafile itself.  I used version 4.2.3 which was the latest version at the time I did this.  You'll need a DDNS service, which I use the free service offered by my Synology NAS.


Guide:
Buckle in and get ready, this is going to be a long bumpy ride.

1.  Download Raspbian and use Win32 Disk Imager to copy into the SD card.
2.  Boot the Pi for the first time.  When the Raspbian config screen comes up, make the following changes:

  2a.  Select "Internationalization Options" and then "Change locale."  Place a check by "en_US.UTF-8 UTF-8."
  2b.  Select "Internationalization Options" and then "Change time zone."  Linux handles time zones differently than Windows.  Instead of selecting your time zone by name or UTC offset, you instead select a region and a city near you.  So for me I select Americas and Los Angeles.
  2c.  Select "Internationalization Options" and then "Change keyboard layout."  For me I selected "Generic 104 key" and "English US."  This step is important as the default keyboard layout is English UK with things like the pound sterling symbol.
  2d.  Select "Advanced Options" and then "Overscan."  Set this option to disabled.  Older analog TVs have overscan where the image is smaller than what the TV can display.  If I do not disable overscan then on my computer monitor I have half an inch of black all the way around the outside edge.  Disabling overscan corrects this.

  2e.  Select the option to resize the image then let the Pi reboot and resize.

The next step is to configure WiFi.  There is no doubt a terminal way to do this.  But I'm lazy and don't know how to do that in Linux, so I use the GUI to make it easy.



3.  Run "startx" then bring up a Terminal window from the start menu.  Run "wpa_gui" and connect to your wifi.

Now let's update the system and install Samba which makes networking much easier:

4.  sudo apt-get update
5.  sudo apt-get dist-upgrade
6.  sudo apt-get install samba samba-common-bin

Now let's change the computer's name.  I choose "seafilepi" as my computer name.

7.  Run "sudo nano /etc/hosts" and change raspberrypi to your new computer name.
8.  Run "sudo nano /etc/hostname" and change raspberrypi to your new computer name.
9.  Shut the system down with the command "sudo shutdown -h now"

The Raspberry Pi doesn't have much memory to begin with.  Since this is a headless unit let's make some changes to maximize memory usage.

10.  Put the SD card back into a Windows PC and edit the file config.txt.  Add the line "gpu_mem_512=16"  Note: this setting will disable the HDMI output.  If you still want HDMI then user 32 as the memory setting.
11.  Put the SD card back into the Pi and boot up.  Run "sudo nano /etc/inittab" then scroll down and use a '#' to comment out all "getty" lines.

Again, this will be a headless unit, so let's remove the unnecessary bits of Linux, like the graphical desktop X.  There's probably a better way to do this but this is what worked for me.  Note the first line actually removes too much, the second line adds some modules back in without which the Raspberry Pi would not have network access.

12.  sudo apt-get autoremove --purge libx11-.* fonts-.* desktop-.* lxde-.* epiphany-.* lightdm-.* alsa-.* gnome-.* raspberrypi-artwork xkb-data omxplayer penguinspuzzle sgml-base xml-core minecraft-pi sonic-pi wolfram-engine
13.  sudo apt-get install raspberrypi-net-mods
14.  sudo apt-get install deborphan
15.  sudo apt-get autoremove --purge $(deborphan)
16.  sudo apt-get autoremove --purge deborphan dialog
17.  sudo apt-get autoremove --purge
18.  sudo apt-get autoclean

When all is said and done this will take away about 1 - 1.5 GB of files.  So that 32GB SD card will have about 30 -31 GB of free space for Seafile.

Now we're ready to install Seafile itself.  First create a new user account under which Seafile will run.

19.  Run "sudo adduser seafile --disabled-password"  Enter the name as "seafile" and all other fields blank.

20.  sudo apt-get install python2.7 python-setuptools python-imaging sqlite3
21.  sudo su seafile
22.  cd ~
23.  mkdir cloud
24.  cd cloud
25.  wget https://github.com/haiwen/seafile-rpi/releases/download/v4.2.3/seafile-server_4.2.3_pi.tar.gz
26.  tar -xvzf seafile-server_4.2.3_x86-64.tar.gz
27.  mkdir installed
28.  mv seafile-server_* installed

The following commands will configure Seafile.  For the name choose the name of this server, something short like your name.  For IP address enter the computer name from steps 7 and 8.  All other fields use the default values.

29.  cd seafile-server_4.2.3
30.  ./setup-seafile.sh

We're now ready to start Seafile for the first time.  When you start the Seahub you'll be prompted for the administrator username and password.

31.  ./seafile.sh start
32.  ./seahub.sh start

33.  exit

At this point if you open a web browser and navigate to "http://seafilepi:8000" you should see the Seafile login screen.  If not you did something wrong so double-check your work to this point.  You could stop at this point and use Seafile.  But I want to go further and configure HTTPS for greater security, which requires nginx.

34.  sudo apt-get install nginx python-flup

nginx is not designed for the low resources found on the Pi, so let's make some changes to improve things.

35.  sudo nano /etc/nginx/nginx.conf


Change "worker_processes" from 4 to 1 (or 2 for Pi model 2).  Also change "worker_connections" from 768 to 128.  Save the changes and exit.

36.  sudo /etc/init.d/nginx start

37.  sudo su seafile
38.  cd ~/cloud
39.  Run "nano ccnet/ccnet.conf"  Change it to read SERVICE_URL = https://seafilepi:8001

40.  Run "nano seahub_settings.py"  Append the line  FILE_SERVER_ROOT = 'https://seafilepi:8001/seafhttp'

Let's stop and restart Seafile.

41.  cd seafile-server-latest
42.  ./seahub.sh stop
43.  ./seafile.sh stop
44.  ./seafile.sh start
45.  ./seahub.sh start-fastcgi
46.  exit

Now we need to create a self-signed digital certificate for nginx.  The second to the last command will prompt for a country code ("US" for United States), and your state.  For organization enter "None" and all other fields can be left blank.

47.  sudo mkdir /etc/nginx/ssl
48.  cd /etc/nginx/ssl

49.  sudo openssl genrsa -out seahub.key 4096
50.  sudo openssl req -new -key seahub.key -out seahub.csr

51.  sudo openssl x509 -req -days 3650 -in seahub.csr -signkey seahub.key -out seahub.crt
  Enter the following into the file /etc/nginx/sites-available/seahub and save it.

52.  sudo nano /etc/nginx/sites-available/seahub
server {
    listen 8001;
    ssl on;
    ssl_certificate /etc/nginx/ssl/seahub.crt;
    ssl_certificate_key /etc/nginx/ssl/seahub.key;
    server_name seafilepi;
    error_page 497 https://$host:$server_port$request_uri;

    client_max_body_size 0;

    location / {
        fastcgi_pass 127.0.0.1:8000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param SERVER_ADDR $server_addr;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param HTTPS on;
        fastcgi_param HTTP_SCHEME https;

        access_log /var/log/nginx/seahub.access.log;
        error_log /var/log/nginx/seahub.error.log;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
    }

    location /media {
        root /home/seafile/cloud/seafile-server-latest/seahub;
        # include /etc/nginx/mime.types; # <--- UNCOMMENT THIS IF CSS FILES AREN'T LOADED
    }
}
53.  sudo ln -s /etc/nginx/sites-available/seahub /etc/nginx/sites-enabled/seahub
Now we can configure Seafile to autostart every time the Raspberry Pi is booted.  Enter the following into the file /etc/init.d/seafile-server and save it.

54.  sudo nano /etc/init.d/seafile-server
#!/bin/sh

### BEGIN INIT INFO
# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server
### END INIT INFO

# Change the value of "user" to your linux user name
user=seafile

# Change the value of "script_path" to your path of seafile installation
seafile_dir=/home/seafile/cloud
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=true

# Write a log message with date and time
echo -e "About to perform $1 for seafile at `date -Iseconds`" >> ${seafile_init_log}
echo -e "About to perform $1 for seahub at `date -Iseconds`" >> ${seahub_init_log}

case "$1" in
    start)
        sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
        if [ $fastcgi = true ];
        then
            sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi >> ${seahub_init_log}
        else
            sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
        fi
    ;;
    restart)
        sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
        if [ $fastcgi = true ];
        then
            sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi >> ${seahub_init_log}
        else
            sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
        fi
    ;;
    stop)
        sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
        sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
    ;;
    *)
        echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
        exit 1
    ;;
esac

55.  sudo chmod +x /etc/init.d/seafile-server
56.  sudo update-rc.d seafile-server defaults
57.  sudo reboot

If you've done everything correctly, when the Rapberry Pi reboots you should be able to login using the URL https://seafilepi:8001  You'll get a warning about an untrusted certificate.  You can ignore this, it's because you used a self-signed certificate which is unknown to your web browser.

Next download and install the Seafile client for your device(s).  When you run Seafile you'll be prompted for a server address.  If the device will ever only access Seafile from inside your home network, you can enter the address of "https://seafilepi:8001"  However, if the device will access Seafile from outside your home network, then enter the address of "https://myddns.com:8001" where "myddns.com" is the DDNS for your home network.

As this point you're almost done.  The last step is to connect to your wireless router and enable port forwarding.  You must forward TCP port 8001 to the Raspberry Pi.  I can't tell you how to do this because every router is different.  But once you complete these step you should be able to sync to/from your personal Seafile server both inside and outside your home network.  Enjoy and good luck!

Wednesday, August 5, 2015

Water saving - the results

I recently posted about California's latest drought and water usage.  In that series I mentioned two simple changes I made at home to save water, I installed High Sierra low-flow shower heads and the HydroRight dual-flush toilet conversion kit.  It has been several months since I installed those products so I wanted to report back on how much water we are saving.

  • In the 6 months before installing these products, my family used an average of 173 gallons of water per day.
  • In the 3 months after installing these products, my family used an average of 115 gallons of water per day.
  • That's an average savings of 58 gallons of water per day.

Saving 58 gallons of water per day may not sound like a lot, but it adds up quickly.  Over a year we'll save approximately 21,000 gallons of water.  That's more water than an average-sized backyard swimming pool.

Here is a graph showing our water usage over the past 9 months.  As you can see the first 6 months are clearly higher than the last 3 months.

As far as cost savings, we saved an average of $11.85 on our monthly water bill.  The new shower heads and toilet products cost about $160 to install them in my house.  At that rate it will take 13 months to break even, and after that we'll save about $140 a year.


There were a couple of details about my water bill and usage that are worth mentioning.  Anyone who knows about water usage knows that 115 gallons of water per day for 4 people is extremely low.  That's an average of less than 30 gallons per person per day, but most places use between 100 and 200 gallons of water per person per day.  So how is ours so low?  There are two reasons.
  1. The biggest reason is the fact we don't have to water our landscaping which is the single largest use of water for a typical home.  In our neighborhood our landscaping and yards are watered by the HOA, so that watering goes on their water meter and not mine.  On the plus side, our neighborhood uses reclaimed water for landscaping so we're not wasting good water just to have a green lawn.
  2. My family has always been good about saving water, even before installing these products.  For example, we never took long showers and we didn't always flush the toilet for just liquids (as the saying goes - "If it's yellow, let it mellow. If it's brown, flush it down").

When I started this endeavor I wasn't sure how much water we would save.  I knew we were frugal with our water to begin with so I wasn't expecting much.  But to save almost 60 gallons of water per day definitely exceeded my expectations.  I hope that seeing our results has encouraged you to try water saving in your house.

Thursday, July 23, 2015

Costco and Pepsi

I'm doing my happy dance right now!  I just got back from the Costco food court and they now serve Pepsi!  I can't tell you how pleased I am.  Literally there is no Coke product I like.  I can tolerate Sprite, but that's it.  But Pepsi, I like most every Pepsi product.

As a life-long Pepsi fan, it's nice to see a large establishment serving Pepsi.  Most stadiums, events, restaurants, etc. all serve Coke.  So this is a win for Pepsi, which is a win for me too.

Reading online, I guess this is a change that has been in the works for years.  Going back to 2013 Costco signed a new deal with Pepsi, ending a 27 year agreement with Coke.  But it was a gradual phase-out taking several years.  My local Costco made the switch recently.

Monday, July 20, 2015

Emulating a Raspberry Pi using Qemu on Windows

The Raspberry Pi is a fun little computer great for small projects or just tinkering.  Sometimes you might want to try something "virtually" before doing it on a real Raspberry Pi.  That's where Qemu comes in.  Qemu is a small, free, and open-source emulator that can run Raspberry Pi software such as Raspbian.  There are multiple guides on the Internet on how to do this (e.g. here and here), but unfortunately I had a lot of problems getting these to work.  I was getting a lot of errors following these guides.  But with a lot of trial and error I was able to figure out the exact steps necessary to successfully emulate a Raspberry Pi. using Qemu running on Windows.  This guide should work on pretty much any version of Windows.  Also, this guide assumes you have at least some Linux knowledge.  For example, I'm going to assume you know how to run the Linux utility 'nano.'

First step is to download the necessary files.
  • Download the 64-bit version of Qemu for Windows, or the 32-bit version of Qemu for Windows.  Please note, and this is very important, I'm using Qemu version 2.3.0 dated April 24th 2015.  There are newer versions of Qemu available; however, in my experience the newer versions don't work because they are missing necessary files.  The version I'm using is known to work, try a newer version at your own risk.
  • Download the latest version of the Raspbian image.  At the time of writing this the latest version is May 5th 2015.  Newer versions (once released) should work the same.
  • Download the Qemu Raspberry Pi kernel.

Next, install Qemu on your system (or use a tool like 7Zip to "extract" the EXE contents into a folder of your choosing).  Unzip the Raspbian image into the same folder as Qemu.  I renamed the file from "2015-05-05-raspbian-wheezy.img" to just "raspbian.img."  From the Raspberry Pi kernel unzip "kernel-qemu" and place it into the Qemu folder.

Now you're ready to run Qemu for the first time.  Unfortunately getting the Raspberry Pi emulation to work properly is a process that requires multiple initial reboots and configuring.  But once you complete this process, the emulation works correctly from then on.

Begin the emulation with the command:
qemu-system-arm.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda raspbian.img
This will start in a maintenance mode.  We need to make some changes to the image before we can start it up normally.
nano /etc/ld.so.preload
There's a single line in the file, comment it out by placing a '#' at the beginning.  Save the file, then create a new file as follows:
nano /etc/udev/rules.d/90-qemu.rules
Type the following into this file:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"

Save the file and exit nano.  Then type "exit" to end the emulation.

Now is a good time to expand the Raspbian image.  By default the image is 3GB in size.  In this tutorial we'll expand it by adding 5GB for a total size of 8GB.
qemu-img.exe resize raspbian.img +5G

This command will generate some ominous warnings, but as long as the command ends with "Image resized" then it was successful.  Now it's time to start Raspbian normally.
qemu-system-arm.exe -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda raspbian.img

During the boot, fsck will generate an error and the boot process will stop at a terminal prompt.  Here's the key step which I found missing from all other online tutorials, you need to rerun the above 90-qemu.rules step.
nano /etc/udev/rules.d/90-qemu.rules
Type the following into this file:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"

Note that during this part the keyboard is in English UK configuration.  If you try and type doublequotes (") it won't work.  To type doublequotes press shift+2.

Save the file and exit nano.  Then type "exit" and the boot process will resume.  When the Raspbian configuration screen comes up, select Finish to exit.  Type "sudo reboot" to restart Raspbian.  Note that Qemu does not support rebooting a VM, instead it just powers down.  So after Qemu closes, use the above command to rerun Raspbian.


Login using the standard pi / raspberry as the username and password.  Then run:
sudo ln -snf mmcblk0p2 /dev/root

Now we can run the Raspbian configuration utility. by running "sudo raspi-config"  Select "Internationalization Options" and then "Change locale."  Place a check by "en_US.UTF-8 UTF-8."  Again, select "Internationalization Options" and then "Change time zone."  Linux handles time zones differently than Windows.  Instead of selecting your time zone by name or UTC offset, you instead select a region and a city near you.  So for me I select Americas and Los Angeles.  Finally select "Internationalization Options" one more time and then "Change keyboard layout."  For me I selected "Generic 104 key" and "English US."  This step is important as the default keyboard layout is English UK with things like the pound sterling symbol.  Lastly, select "Expand Filesystem."  Reboot to expand

After this Raspbian will be configured and ready to go.  It's a good idea to run "sudo apt-get update" and "sudo apt-get dist-upgrade" to update your image.  From my experience X (the graphical desktop) is very slow and hard to use.  But if all you want to do is terminal stuff this is a great way to emulate a Raspberry Pi.  Also, don't expect to be blown away by speed, even on a fast desktop computer.  The emulator runs about the same speed as a real Raspberry Pi, maybe even a little slower than.

As I said, I figured all this out through a lot of trial and error.  So hopefully someone else finds this useful.  Enjoy, and happy emulating!