January 24, 2013

Dynamic DNS on Raspberry Pi

With Ni-IP.org and inadyn

  1. Register for an account at no-ip.org.
  2. Install inadyn "apt-get install inadyn"
  3. create a config file in etc called inadyn.conf:
--username xxxx 
--password xxxx
update_period 60000
alias carpi.no-ip.org
dyndns_system default@no-ip.com

Raspberry Pi with 3G and WiFi

Aim: To have a Wireless hotspot in the truck with 3G internet and vehicle tracking
  • Raspberry Pi running Raspbian
  • Powered USB Hub
  • Huawei E170 3G Dongle
  • TP-Link TL-WN722N
After several false starts and 10's of hours trying to get various hardware working I settled on the above.

Wireless Setup

apt-get install hostapd dhcpd
nano /etc/hostapd/hostapd.conf

nano /etc/dhcp3/dhcpd.conf

subnet netmask {
        option domain-name-servers,;
        option routers;}
nano /etc/network/interfaces

auto lo

iface lo inet loopback

iface eth0 inet dhcp
 post-up iptables-restore </etc/network/iptables

allow-hotplug wlan0

iface wlan0 inet static 

  post-up /etc/init.d/hostapd start ; /etc/init.d/isc-dhcp-server start 
  down /etc/init.d/hostapd stop ; /etc/init.d/isc-dhcp-server stop
Permanently enable IP forwarding in /etc/sysctl.conf:
nano /etc/network/iptables
:INPUT DROP [2:208]
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -i wlan0 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 12 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A OUTPUT -o ppp0 -j ACCEPT

Managed to get 2MB/s running through it using Plex on the iPad

Setting up 3G

wget "http://www.sakis3g.org/versions/latest/$ARCH/sakis3g.gz" # where $ARCH is either i386 or amd64
gunzip sakis3g.gz
chmod +x sakis3g
./sakis3g --interactive

I have had to make alot of changes to this since I added the GPS as the GPS module moves all the serial ports around. Here is the working config:

# Bus 001 Device 006: ID 12d1:140c Huawei Technologies Co., Ltd.

January 02, 2013

VMWare Server vmdk to ESX

vmkfstools -i <src> <dst>



ipv6ip / 6in4 tunnels Ubuntu

Add the following to your /etc/network/interfaces file
auto tun0
iface tun0 inet6 v4tunnel
    address <Tunnel IPv6 Address>
    netmask <IPv6 Subnet Mask>
    endpoint <IPv4 Address of Tunnel Server>
    ttl 255
    up ip link set mtu 1480 dev tun0
    up ip route add ::/0 dev tun0
The local tunnel endpoint will be the IPv4 address of the interface facing the Tunnel Server. You may need to reduce the MTU although PMTU happens automatically. You can use tracepath6 ipv6.google.com to find the lowest MTU in your path.
Also make sure you add the following to your IPv4 IPtables rules:
-A INPUT -s <IPv4 Address of Tunnel Server> -i <WAN interface> -j ACCEPT

VMWare Tools Install CLI

In vSphere Client, Install/Upgrade VMWare Tools
mkdir /media/cdrom if not exist
mount /dev/cdrom /media/cdrom
cd /tmp
tar xvf /media/cdrom/VM*
cd vmware-tools-distrib
If the above fails, which it will if you don’t have precompiled kernel modules, make suer to install build-essential first.

Upgrade ESXi 4.0 to 4.1

1. At the console, pressALT-F1.

2. Enter unsupported in the console and then press Enter.

3. Enter the password for the root login.

4. In Vsphere, Put the host in Maintenance mode

5. Download the 4.1 update from VMWare and unzip it to a folder called upgrade and upload it to the host.

6. Connect to the console and change to the directory that the upgrade folder has been uploaded.

7. Run the upgrade command. esxupdate update –m metadata.zip

8. At the console, pressALT-F2. Then reboot

Vehicle Fluid Capacities


80 Series Stuff

Speedo Correction

Kill Multiple processes by name

ps ax | grep “$PROCESS_NAME” | awk ‘{print $1}’ | xargs -i kill {} 2&>/dev/null

MySQL 5 Cluster reference

I will explain how to set up 3 servers, with the following roles:

server-a = management node (IP
server-b = storage and sql node (IP
server-c = storage and sql node (IP

It is easy to have storage and sql nodes on separate servers, but to make this guide easier to follow (and so we don’t need 5 machines), I’ll use 3 servers.

All servers will need to have mysql-server installed. If you need help doing this, have a look at this guide.

Setting up the management node (

Default debian/ubuntu installs look for /etc/mysql/ndb_mgmd.cnf for the management node, so we need to create this file, with the following contents:

DataDir= /var/lib/mysql-cluster

# Management Node

# Storage Nodes (one for each node)

# SQL Nodes (one for each node)

The line beginning NoOfReplicas tells the cluster how many copies of data should be kept.

Now we start the management node, and it will sit waiting for connections from the storage and SQL nodes:
/etc/init.d/mysql-ndb-mgm start

Setting up SQL and data nodes

All we need to do here is make a few changes to /etc/mysql/my.cnf (the mysql config file)

First, add the following 2 lines (using the IP of your management node) inside the [mysqld] section of the config file:

And near the bottom of the file there will be a section for [MYSQL_CLUSTER] which you will need to uncomment, and change the ndb-connectstring line to your management nodes IP.

If you are using separate data and sql nodes, the [mysqld] part is relevant to the sql nodes only, and the [MYSQL_CLUSTER] part is relevant to the data nodes only.

Before we start the services, we have to create the /var/lib/mysql-cluster directory and set it to be owned by the mysql user:
mkdir /var/lib/mysql-cluster
chown mysql:mysql /var/lib/mysql-cluster

Now we need to start the node services:
/etc/init.d/mysql restart
(which starts the sql node)
/etc/init.d/mysql-ndb restart
(which starts the data node)

By now, everything should be running, so we connect to the management node (by running ndb_mgm from the command line) and check that the other nodes have connected properly (using the show command):
ndb_mgm> show;
Cluster Configuration
[ndbd(NDB)] 2 node(s)
id=2    @  (Version: 5.0.51, Nodegroup: 0)
id=3    @  (Version: 5.0.51, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @  (Version: 5.0.51)

[mysqld(API)]   2 node(s)
id=4    @  (Version: 5.0.51)
id=5    @  (Version: 5.0.51)

This shows that everything has connected properly. If connections are missing, then it’s worth checking /var/log/syslog on the affected server to see if there are any error messages.

Using the cluster

It’s worth noting that any databases already on the servers will continue to work as before. Tables only become part of the cluster when their engine type is changed to ‘MyISAM’ by issuing this command (from a mysql prompt):
alter table tablename engine=MyISAM;

But for now we will create a new database and clustered table, and test that the data is clustered. The cluster setup applies to tables only, not databases, so we first need to create the database on both sql nodes:
create database cluster;

Now, when we create a table inside the cluster database, as long as the engine is MyISAM, the data will be synced across data nodes, which we can test by doing the following (from a mysql prompt on either sql node):
create table clustertest (i int) engine=MyISAM;
insert into clustertest () values (1);
select i from clustertest;

Which should return the single row with the value of 1. Now connect to the other SQL node and try…
insert into clustertest () values (2);
select i from clustertest;

Which should return both rows, which will happen whichever SQL node you connect to as the table is now stored in the cluster.

If you receive an error like:
ERROR 1015 (HY000): Can’t lock file (errno: 4009)

Then it is likely that some of your cluster nodes haven’t started correctly, so its worth checking the management interface again.

Shutting down and restarting the cluster

To shutdown the data nodes and management node, all you need to do is enter the command ‘shutdown’ in the management interface.

To restart, simply run
/etc/init.d/mysql-ndb-mgm start

On the management node, and
/etc/init.d/mysql-ndb start

On the data nodes. The SQL nodes continue running, and can be stopped/started using the standard mysql init script.

That’s it, you’ve now should have a working MySQL cluster. As you have NoOfReplicas=2 in the management config, you should be able to unplug either data node at any time and still have access to all of the clustered tables.

PureFTPD User add/del scripts

echo Adding FTP user $1
pure-pw useradd $1 -u virftp -g virftp -D /home/virftpusers/$1
mkdir /home/virftpusers/$1
mkdir /home/virftpusers/$1/media
chown virftp:virftp /home/virftpusers/$1/ -R
mount –bind /mnt/500SATA/media/ /home/virftpusers/$1/media
pure-pw mkdb

echo Removing FTP user $1
pure-pw userdel $1
umount /home/virftpusers/$1/media
rm -r /home/virftpusers/$1
pure-pw mkdb

ESXi Power on VM from Console

Get the VM id:
vim-cmd vmsvc/getallvms
Then power on the vm:
vim-cmd vmsvc/power.on 80

PureFTP config with Virtual Users

PassivePortRange:4500 4600

Vmware Tools install ESX4.1 / Ubuntu Maverick

wget http://packages.vmware.com/tools/VMWARE-PACKAGING-GPG-KEY.pub
nano /etc/apt/sources.list.d/vmware-tools.list
  • Add “deb http://packages.vmware.com/tools/esx/<esx-version>/ubuntu <dist> main restricted”
  • in my case “deb http://packages.vmware.com/tools/esx/4.1u1/ubuntu karmic main restricted”
“The configuration syntax is specific to each operating system version. Replace <dist> with maverick
for Ubuntu 10.10, lucid for Ubuntu 10.04, karmic for Ubuntu 9.10, jaunty for Ubuntu 9.04, intrepid
for Ubuntu 8.10, and hardy for Ubuntu 8.04.
Replace <esx-version> with 3.5u2, 3.5u3, 3.5u4, 3.5u5, 4.0, 4.0u1, 4.0u2, or 4.1, depending on the
ESX/ESXi version.”
apt-get install vmware-open-vm-tools-kmod-generic

IPv6 on Cisco with Snap

DHCPCLIENT#show running-config

version 12.4
ipv6 unicast-routing
interface Serial0/0
no ip address
ipv6 address autoconfig default

!--- The autoconfig default adds a static ipv6 
!--- default route pointing to upstream DHCP server.

ipv6 enable
ipv6 dhcp client pd prefix-from-provider

!--- The DHCP client prefix delegation is 
!--- given the name prefix-from-provider.

clock rate 2000000
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address prefix-from-provider ::1:0:0:0:1/64

!--- The first 48 bits are imported from the delegated
!--- prefix (2001:db8:1200) and the ::/64 is the client
!--- identifier that gives the interface Fa0/1 the
!--- global IPv6 address 2001:DB8:1200:1::1/64.

ipv6 enable
interface FastEthernet0/1
no ip address
duplex auto
speed auto
ipv6 enable
ipv6 address prefix-from-provider ::1/64

!--- Similarly, the global IPv6 address 
!--- for fa0/1 is 2001:DB8:1200::1.


Performance Tuning 80 series Diesel Engine

crazy clark here is a useful write up for you- http://lcool.org/technical/80_series/1h … p_adj.html
This info applies for a 1hdt also. Is your old mans truck a 12 or 24 valve. My 12 valve auto I used to own was exactly like what you explain, could hardly even break into a roundabout it was so sluggish. Its the offboost characteristics that do this. I took it to wopass and he transformed it very quickly into a completey differant truck, it would launch off the line even with a big trailer. Take note of the bit in the link talking about turning the wheel under the offboost comp. We turned mine 5 clicks but its totally up to you and depends where your starting point is also. This is the adustment that makes the big differance. Its quite fine and hard to feel so be carefull and take your time remembering what you have done. Take small adjustments and then drive. You will know when you have it because all of a sudden it will be a very differant truck. I also bought a 4wd bits intercooler and upped boost to 16 psi and gave the mainset a little bit more fuel. I have found on my 24 valve that I now have, that simply removing the emmisions stuff and installing an intercooler it has had much the same affect, as the 24 valve model comes with emmision gear that the 12 valve doesnt. The emission gear controls to some extent the offboost, therefore removing it makes a very noticable gain, easiest way to get rid of it is contact warren and buy a top mount. Either way I recommend intercooling. If you have the 24 valve model remove the emmision gear before you adjust anything, you may not need to. Its good he has a 3 inch exhaust that will help with egts. The aim of tuning is to get a puff of black smoke offboost, but it should clear once its making full boost. Lots of black smoke at full throttle is not what you want. Remember that high egts are bad, having said that small offboost adjustments are pretty safe on these engines and have run mine hard for years, dont be too gready on the main set adjustment screw only give it a little, and if you up boost you will want a 1/4 to 1/2 turn on that. Here is another link just look at the photos shows what to look for http://www.tlocuk.co.uk/forums/viewtopi … a75d7e12e5


Tubing Coping Calculator


LSI MEgaRaid Driver

wget http://www.58support.nec.co.jp/global/download/421351-B01/vmware-esx-provider-lsiprovider.zip

Truck related

Pi Power Control Notes

A Raspberry Pi Remote Mains Switcher, to switch these
with one of these
using the awesome reverse engineering detailed here


Requires WiringPi-Python
git clone https://github.com/WiringPi/WiringPi-Python.git cd WiringPi-Python/ git submodule update --init sudo apt-get install python2.7-dev sudo apt-get install python-setuptools sudo python setup.py install 


Needs to be run as root -
sudo python raspwitch.py --channel 1 --button 3 --gpio 8 on 
When compiling today’s code form git repository gcc has problem finding wiringPi.h on my Raspbian wheezy:
WiringPi/wiringPi/piNes.c:25:22: fatal error: wiringPi.h: No such file or directory
You just need to edit piNes.c and change first include line into:
#include "wiringPi.h"
That fixes the problem.