Upgrading Cisco Wireless Firmware

I’m always forgetting the exact string to enter at the CLI for updating the IOS on a wireless Cisco AP, so I’ll just put it here to end my future searches:

Chimp# archive download-sw /force-reload /overwrite tftp://192.168.83.150/c1100-k9w7-tar.123-8.JEC1.tar

192.168.83.150 obviously being your tftp server, and the .tar file sitting in the root of the tftp server.

I suppose if you wanted to backup your IOS you could do something along the lines of:

Chimp# archive upload-sw tftp://192.168.83.150/someimage.tar

But I haven’t tried it…

Backup OpenFiler to S3

Backing up your Openfiler box to S3

While I don’t think most pople would expect to backup their entire NAS/SAN to Amazon’s S3, there might be a few very crucial things you need to backup.

I’ve seen an implementation using Ruby and s3sync – something that I do on my server – but I’m trying to migrate everything to Python. Although there are a lot of great tools out there for S3, many of them Python-based, I wanted to do one thing and do it well: have one complete full backup available, and using as little bandwidth as possible. In these regards Duplicity would work well, except I wanted the ability to browse the S3 store using any other tool.

I’ve digged deeper into s3cmd, which I had noticed a long time ago, but I failed to notice it has a sync option. I have tested it out, and it appears to work very, very well. Here’s how to use it with OF.

First, download s3cmd. You’ll need to use subversion, so I first checked it out to my laptop, then uploaded it via SSH to OF. I put my s3cmd folder in /opt.

  
[root@files opt]# ls  
openfiler  s3cmd  
[root@files opt]#   

If you don’t have elementtree installed, now is a good time to install it.

  
conary update elementtree:python  

We need to next configure s3cmd with our AWS creds.

  
[root@files s3cmd]# ./s3cmd --configure  

In the end I didn’t configure encryption for my files (so just hit enter), but you may choose to do so. I have configured the transfer to use HTTPS, however.

  
Save settings? [y/N] y  
Configuration saved to '/root/.s3cfg'  

Cool. Now create a bucket on S3 for your NAS, e.g. blah2134accesskey.openfiler, using whatever method you choose (I typically use Cockpit). Now that you have a bucket, configure a really simple script to drop in cron:

  
#!/bin/bash  
  
/opt/s3cmd/s3cmd sync /mnt/openfiler/data/profiles/bunny s3://blah2134accesskey.openfiler/mnt/openfiler/data/profiles/bunny  
/opt/s3cmd/s3cmd sync /mnt/openfiler/data/profiles/kelvin-pc s3://blah2134accesskey.openfiler/mnt/openfiler/data/profiles/knicholson/kelvin-pc  

Sweet! I like this approach quite a bit: I get file-level access to anything on the NAS, you don’t have to actually install anything, and it ‘just works.’

Configure Timevault to Remote Server

Using TimeVault with a shared drive as a backend is actually quite easy, but it does require a few special things setup. Note: this is gonna be a brief summary.

Install samba-tools, smbfs…

sudo apt-get install samba-tools smbfs

A lot more other stuff may install as well.

Create a script that mounts your samba share. You could also do this in fstab, but I tend to suspend my laptop when I come home, and I like clicking buttons.

#!/bin/bash

mount -t cifs //192.168.44.2/kelvin /mnt/backups -o netbiosname=KELVIN-PC,iocharset=utf8,credentials=/home/kelvin/Apps/.smb-details.txt

smb-details.txt includes:

username=DOMAIN\\kelvin
password=mypassword

Finally, create a folder called ’timevault’ or something inside your mapped share, then launch TimeVault and configure it to use the above mentioned /mnt/backups/timevault folder. Configure Timevault as normal.

PyGTK + py2exe for Windows

I’m writing down these quick notes so I can remember the steps for getting py2exe to work with GTK.

  • Download the GTK+ runtime
  • Download py2exe
  • Copy over your project into the windows box
  • Create a setup.py file (see below)
  • Run “c:\Python25\python.exe setup.py py2exe”
  • Copy over the lib, etc, and share folder from C:\Program Files\GTK2-Runtime into the dist folder
  • Run app!

setup.py:

from distutils.core import setup
import py2exe

setup(
    name = 'ploteq',
    description = 'Bunnys Plotting Tool',
    version = '1.0',

    windows = [
        {
        'script': 'ploteq.py',
        }
    ],

    options = {
        'py2exe': {
        'packages':'encodings',
        'includes': 'cairo, pango, pangocairo, atk, gobject', 
        }
    },

    data_files=[
        'ploteq.glade',
    ]
)

Capped Internet

I’ve lived in several different parts of the world, and they all do internet differently. Back in the US I had 8Mb/sec cable (leaving just before Fios was really an option, darn!) In New Zealand, for instance, I was paying for “high speed ADSL” rated at 1.5Mb/256k. Vrooom. Up in Taiwan I was paying 1/2 what I paid in New Zealand, but for 12Mb/1Mb. Down to Sydney and we have a rated 24Mb/1Mb.

But there’s a catch with the plans in New Zealand and Australia: they are ‘capped’. This means you only get XGB/month – and it isn’t like Comcast capping at 250GB/month, I’m talking about 1GB/5GB/10GB and so forth. And there’s more – just like mobile phones, you get on-peak and off-peak times.

This all does make a bit of sense to me – there are only X amount of tubes going in and out of NZ and AU, and I would imagine they get pretty clogged.

Either way, last month was pretty painful. Two weeks into our plan I checked out usage: 14GB of 18GB! We had only 4GB left to use for 15 days. This sounds like a lot, but for the two of us, and my 10 virtual servers, it isn’t. The first thing I did was looking at a way to do WSUS with Linux – I ended up using apt-cacher (I’m using only Ubuntu at home). BitTorrent, out; downloading any new ISOs, out; streaming music, totally out. For a while I has to VPN to home, and then VPN to a client, as our router at work didn’t seem to like letting us access one of our clients. I even disconnected from the VPN if I wouldn’t be doing work for 20m!

We eventually made it, and used only 2GB in two weeks. What an accomplishment!

Revised mod_tile Install HOWTO

This is the laundry list of things I did while creating a mod_tile VMware appliance based on Ubuntu Server 8.04. I’ve kept descriptions limited but left all the commands in. Let’s start installing things…

Useful goodies for compiling source

sudo apt-get build-essential

More goodies for Mapnik + Friends

sudo apt-get install libboost-dev libboost-filesystem-dev libboost-filesystem1.34.1 libboost-iostreams-dev libboost-iostreams1.34.1 libboost-program-options-dev libboost-program-options1.34.1 libboost-python-dev libboost-python1.34.1 libboost-regex-dev libboost-regex1.34.1 libboost-serialization-dev libboost-serialization1.34.1 libboost-thread-dev libboost-thread1.34.1 libicu-dev libicu38 libstdc++5 libstdc++5-3.3-dev python2.5-dev
sudo aptitude install libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libltdl3 libltdl3-dev libpng12-0 libpng12-dev libtiff4 libtiff4-dev libtiffxx0c2 python-imaging python-imaging-dbg proj
sudo aptitude install libcairo2 libcairo2-dev python-cairo python-cairo-dev libcairomm-1.0-1 libcairomm-1.0-dev libglib2.0-0 libpixman-1-0 libpixman-1-dev libpthread-stubs0 libpthread-stubs0-dev ttf-dejavu ttf-dejavu-core ttf-dejavu-extra
sudo aptitude install libgdal-dev python2.5-gdal postgresql-8.3-postgis postgresql-8.3 postgresql-server-dev-8.3 postgresql-contrib-8.3
sudo aptitude install libxslt1.1 libxslt1-dev libxml2-dev libxml2 gdal-bin libgeos-dev libbz2-dev
sudo aptitude install apache2 apache2-threaded-dev apache2-mpm-prefork apache2-utils
sudo aptitude install subversion

This checks out the mapnik source:

svn co svn://svn.mapnik.org/trunk mapnik-src

Let’s build mapnik with several specific locations included.

cd mapnik-src
python scons/scons.py PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/include/postgresql PGSQL_LIBS=/usr/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib
sudo python scons/scons.py install PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/include/postgresql PGSQL_LIBS=/usr/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib

And prepare a few things for the mapnik rendering…

svn co http://svn.openstreetmap.org/applications/rendering/mapnik/
cd ~/mapnik
wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz
tar -xpjf world_boundaries-spherical.tgz
unzip processed_p.zip
cp coastlines/* world_boundaries/
rmdir coastlines

Time to setup postgres. I have the intentions of running renderd (the mod_tile rendering engine) under whatever user Apache is running as, so I’ll setup postgres to allow the OSM user to authenticate via password. I’m not a postgres expert, so if you see me doing something totally foolish, let me know.

sudo vi /etc/postgresql/8.3/main/pg_hba.conf

And edit the authentication part as so:

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
local   all         osm                               password sameuser

And now to actually configure postgres for the OSM data

sudo su postgres
createuser osm
createdb -E UTF8 -O osm gis
createlang plpgsql gis
psql -d gis -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
echo "ALTER TABLE geometry_columns OWNER TO osm; ALTER TABLE spatial_ref_sys OWNER TO osm;"  | psql -d gis
echo "alter user osm with password 'columbia';" | psql
sudo /etc/init.d/postgresql-8.3 restart

Now, let’s render a sample image. Edit set-mapnik-env by changing the DB to ‘gis’, the username to ‘osm’, and the password to ‘columbia’

cd mapnik
source ./set-mapnik-env
./customize-mapnik-map >osm.xml
./generate_image.py

If you get an error about it not finding a lib, make sure to do a…

sudo ldconfig

You should have an image called ‘image.png’ in the mapnik directory, and it should look distinctly like the UK.

svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql
cd osm2pgsql
make

Ok, that was easy. Let’s load some data. I’ve used a sample snippit from Sydney in /home/osm to illustrate this.

./osm2pgsql -W -d gis ../sydney.osm

Type in the password used for postgres (‘columbia’)

I’ll now check that the data is accessible by editing generate_image.py with the correct coords for Sydney.

ll = (150.29, -34.04, 151.25, -33.36)

Time to get mod_tile up and running.

sudo apt-get install libagg-dev
svn co http://svn.openstreetmap.org/applications/utils/mod_tile
cd mod_tile

Depending on the revision of mod_tile you are using, you are going to have to edit the source before compiling. The two files you need to read through are the Makefile and render_config.h. I change the apxs and apachectl locations to the correct place (lines 2, 13 and 14). Since I did it on a x86 image, I took out any references to lib54 (line 33). In render_config.h, I made the following changes:

Line 8

#define WWW_ROOT "/var/www"

Line 23

#define OSM_XML "/home/osm/mapnik/osm.xml"

Removed references to lib64 on lines 26 and 29.

make && make install

Set it up as a module for apache by creating a file in /etc/apache/conf.d called ‘mod_tile’ and putting in there:

LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so

Created a folder called ‘osm_tiles2’ and ‘direct’ in /var/www, and make sure they are writable by whatever apache runs as (likely www-data). Restart apache.

From here, I created a file that automatically zooms in on the map I just created – you can check it out here. Start the renderd process as www-data, and browse to the sample file.

cd ~/mod_tile
sudo su www-data
./renderd

By now you should have a working mod_tile/OSM setup. After a change and tune a few things on the Ubuntu image I’ll make the VMware image available for download. I can’t wait to do some OSM projects!

Using Raw Disks with VMware Server 2

For various reasons I had the need to open a raw disk inside VMware Server 2. The reports from the field say that this just isn’t supported. Although I don’t need to actually run a raw disk, I needed to get some data off it – 400GB worth. It turns out ’not supported’ really means ’not in the UI.’ I don’t know the reason why it isn’t in the UI, maybe marketing wants people to use ESX, or maybe the UI guys fell behind with their workload.

Alas, it is possible. And here’s how.

  1. Take out your ‘raw disk’ and put it into another machine.
  2. Fire up Server 1.0.x or Workstation and open a virtual machine (or create a new one). Edit the preferences and add a new hard disk. Select ‘use a physical disk’, and select the disk you put in above. Select use entire disk. You may want to change the SCSI LUN to SCSI1:0 (depending how many disks are in your ‘proper’ server).
  3. Save it as something like 500GB.vmdk
    3b. Copy out the relevant bit from the vmx file, e.g.
# Test VM.vmx
scsi1.present = "TRUE"
scsi1:0.present = "TRUE"
scsi1:0.fileName = "500GB.vmdk"
scsi1:0.deviceType = "rawDisk"

And of course, the entire 500GB.vmdk file

# 500GB.vmdk
# Disk DescriptorFile
version=1
CID=7e245252
parentCID=ffffffff
createType="fullDevice"

# Extent description
RW 976773168 FLAT "/dev/sdb" 0

# The Disk Data Base 
#DDB

ddb.virtualHWVersion = "6"
ddb.geometry.cylinders = "60801"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.geometry.biosCylinders = "60801"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.adapterType = "buslogic"

Note: If your guest OS is 64-bit, you won’t be able to use buslogic. Switch the last entry above to ’lsilogic’.

While you could likely create the vmdk file by hand, the only number I’m not certain about is the part after the RW. (UPDATE: Note added to page). The Disk Data Base you can just see by typing in ‘fdisk /dev/sdb’

  1. Move the disk back to the ‘server’ and turn the server back on.
  2. Edit the vmx file of whatever virtual machine you want to use and put in the part copied from the vmx file of your other machine. Alternatively, if you did an upgrade, you could just copy it across now. Create a new 500GB.vmdk file in the same directory, paste in the bit you copied out from the test virtual machine. Double check that the ‘raw disk’ comes up as the same node in /dev.
  3. Boot up the virtual machine. You will notice in the WebUI that a new scsi controller is inserted. You should also noticed a new disk accessible inside your virtual machine, e.g.
[root@files dev]# ls sd*
sda  sda1  sda2  sda3  sdb  sdb1
[root@files dev]# ls /mnt
cdrom  floppy
[root@files dev]# mkdir /mnt/disk
[root@files dev]# mount /dev/sdb1 /mnt/disk
[root@files dev]# ls /mnt/disk
Files  lost+found  Movies  Music  Personal  VMWare
[root@files dev]#

Update: Peter Jonsson kindly sent in the answer to “I don’t know what to put after the RW.” Below is the description of how to find the correct number. Thanks Peter!

The magic formula is:

ThePartAfterTheRW  =  TOTAL AMMOUNT OF DISKBYTES   /   512


This is my Western Digital 500 GB drive: 

fdisk -l

Disk /dev/sdc: 500.1 GB, 500107862016 bytes

256 heads, 63 sectors/track, 60563 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Disk identifier: 0x00000000

And using the formula I got the "RW" stuff:

500107862016 / 512  = 976773168

VM Automatic Startup in Server 2

I think possibly one of the most practical upgrades in VMware Server 2 appears to be the ability to automatically turn on virtual machines in a stagnated order. I have fond memories of turning on a server with 10 virtual machines, and when they all turn on at once, the hard disk grinds to a halt. This forced me to turn on the machines manually afterwards.

+1 VMware in my books.

Ubuntu 8.04 64-Bit and VMware Server 2

I now have successful installation of VMware Server 2 (Beta RC1) on top of Ubuntu 8.04 64-bit. I have been using various virtualization technologies for years, and VMware is usually the easiest to install and configure. So far, VMware Server 2 RC1, has proven to be the exception to the rule.

That said, I am very excited by the direction VMware is taking – this new server version looks to have great potential.

The ‘server’ this is on is a mATX motherboard from Gigabyte (GA-G33M-DS2R), with 4GB (2x2GB) of Transcend DDR2-800 memory, topped off with the E8200. I have been nothing but impressed with this combination of hardware.

However, although I was thinking VMware Server 2 would install seamlessly over Ubuntu, I was wrong. There were a few things I had to tweak to get everything working correctly.

The first thing I had major issues with was VMware choking on the parallel port. Normally the parport is the first thing I would turn off, but in this instance, I guess excitement overtook me. My tip is to first remove the lp module from inside /etc/modules, and then disable the parallel port inside the BIOS. The symptoms I was having involved VMware halting/freezing on either startup or shutdown. This occurred for both RC1 as well as 1.0.6.

My second tip, if VMware freezes half way through starting up or shutting down, is to go through the vmware startup script, /etc/init.d/vmware, and comment out anything refering to the parport_pc. In particular, I looked for this line and made sure to comment it out:

/sbin/modprobe -r parport_pc >/dev/null 2>&1

I commented out lines 974 and 1076. After doing this, VMware loaded perfectly.

The second major issue I had occurred after actually installing VMware. I opened Firefox and went to the IP of my virtual server, logged in just fine, and loaded up my first virtual machine. However, after booting the virtual machine, I was unable to open up the remote console. It turns out I had just upgraded to Firefox 3.0.1, and the Remote Console is set to fail on anything above 3.0.0.1. The fix is quite easy.

First click where it says “click anywhere to open the virtual machine”. Copy the address of the XPI and use something like wget to download the file. This is an example:

wget --no-check-certificate https://192.168.50.10/ui/plugin/vmware-vmrc-linux-x86.xpi

If you are using Gnome, right click the file you just downloaded and say Open With then Archive Manager. Do the same for the ‘install.rdf’ file inside, specifying gedit as the application if need be. Next, edit line 20 so it reads as follows:

3.0.*

Save the file, open the XPI with Firefox, and you should be good to go.

I’ve seen a lot of other suggestions on the ’net on how to fix VMware RC1 when booting – including disabling ipv6, checking the hosts file, and running the any-any patches. None of these approaches helped me at all, but maybe it is exactly what you need. My biggest tip is that if VMware isn’t starting up or stopping correctly, open up /etc/init.d/vmware and find out exactly where it is faulting (add things like ’echo “fail”’ inside the IF statements).

VMware Tools in VMware Server 2

Installing the tools in VMware Server 2 is a little different than Workstation or the previous versions of VMware Server. Under the Summary tab of your Virtual Machine, look for a link that says “Install VMware Tools” – click it.

Wait for ‘Success’ to show up on the bottom, and jump into your virtual machine. Mount the tools as so:

mount /dev/cdrom /media/cdrom

And install as normal (copy the .tar.gz to /usr/src, extract it, install it). Easy peasy.