Thursday, December 24, 2015

Copying Images from Disk to SD Cards

I've been using the dd command to copy images to SD cards for my Raspberry Pi's. I've found a faster way that takes 2+ minutes versus 11+ minutes.

Old way

dd bs=4M if=2015-05-05-raspbian-wheezy.img | pv --size=3276800000 | dd of=/dev/sdX && sync

3.05GB 0:11:25 [4.56MB/s]

New way

pv --size=3276800000 2015-05-05-raspbian-wheezy.img > /dev/sdX && sync

3.05GB 0:02:30 [20.8MB/s]

NOTES: I prep the SD card before the copy with these steps:

  • Become root sudo su
  • Un-mount the SD card. umount /media/SOMEUSER/SOMEMOUNT
  • Find the drive letter for the SD card. I use the command lsblk and/or the GUI gnome-disks. Make sure you double-check your drive letter. dd will destroy anything in its path. I've used sdX in my examples.
  • Wipe the SD card: dd if=/dev/zero of=/dev/sdX bs=512 count=1 conv=notrunc
Tests performed with Ubuntu 14.04, SanDisk SDHC I 32GB, Lexar USB 3.0 adapter.

Wednesday, June 10, 2015

Map IP Connections

Display IP connections from and to your Linux box on a map. Alternatively works with Cisco ASA syslog records. Outgoing connections are green markers and incoming connections are red markers. Uses iptables, tailf, websocketd, indexedDB, Javascript, Google Maps and Telize geoip api. Tested on Ubuntu 14.04 and 15.04. In the animated GIF below I go to a website in the US, Russia, and Japan. Let me know if you find it useful. Source code on Github.

Friday, April 10, 2015

Bash Script to View HDHomerun Channel Version 2

I rewrote my tv Bash script to utilize the HDHomeRun JSON feed of the channel line up. The source code can be found on Github at

The previous version was written before the JSON feed was available. This new version is simpler and doesn't have the hdhomerun_config requirement.

Friday, April 3, 2015

Raspberry Pi Remote Desktop Client with Kiosk

In an earlier post I talked about using Raspberry Pi as a remote desktop client. That set-up was pointing towards a single server. This variation allows the user to choose their terminal server. This is useful where desks are shared by users with different terminal servers.

This version displays a locally stored html file in a Chromium Kiosk. When the user selects their terminal server netcat is waiting for the HTML form post, greps the terminal server value and runs the rdesktop command. This is done in a never ending loop. The matchbox-window-manager is used to get the kiosk full-screen and with a nice looking mouse pointer.

Remote Desktop Kiosk Screenshot


#!/bin/sh -e
su -s /bin/bash -c startx pi&
exit 0




logger "$0 Start"
xset s off
xset -dpms
/usr/bin/matchbox-window-manager &
while true
  /usr/bin/chromium --incognito --kiosk /home/pi/remoteDesktop.html &
  response=$(echo -e 'HTTP/1.1 200 OK\r\n' | /bin/nc -4 -l 8080)
  logger "$0 After netcat: $response"
  terminalServer=$(echo "$response" | grep 'terminalServer=' | cut -d '=' -f2)
  /usr/bin/rdesktop -r sound:local -u "" -f "$terminalServer"


<title>Remote Desktop</title>
function postIt() {
  setTimeout(function() {close();},1000);
body, p, h1, h2, h3 {
h1 {
h2 {
.radioLine {
input {
button {
.bodyContainer {
  width: 800px;
  margin: 0 auto;
<div class="bodyContainer">
<h2>Choose your terminal server</h2>
<form action="http://localhost:8080" method="post">
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts0-vm">ts0-vm</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts2">ts2</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts4">ts4</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="">Ubuntu</label></div>

Sunday, March 29, 2015

Play on Kodi - Ubuntu Touch app

I installed Ubuntu Touch on my Nexus 7 and developed an app to find media and play it on my Kodi entertainment system.

Here is a video demo:

Source code on Github

Thursday, March 12, 2015

Raspberry Pi 2 as a Remote Desktop Client


The Raspberry Pi makes a good remote desktop client. I use them to remote to Windows terminal servers. I Velcro the Pi to the back of a 1920x1080 monitor. The Pi is powered by the monitor's USB port.

To boot right in to a remote desktop session, create a Bash script /home/pi/

while true
  logger "$0 Executing /usr/bin/rdesktop"
  /usr/bin/rdesktop -r sound:local -f -d DOMAINNAME WinPC

Add your new Bash script to the end of the /etc/xdg/lxsession/LXDE-pi/autostart file. Mine looks like this:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi

The Pi will boot up in to the remote desktop session of your WinPC. If the user logs out of Windows or tries to escape, the script will run the rdesktop command again. This is not hacker proof or anything like that. The user can hit Ctrl-Alt-Enter to exit out of full-screen and kill the Bash script.

Component list with Amazon links