Friday, May 20, 2011

Land Rover - A borrowed car from the shop

Standard
A borrowed set of wheels..
I recently had my brakes done at the Land Rover dealer. After getting my car back I noticed a disturbing use of brake fluid, and I subsequently had to take the car back to have the brakes fixed for both front wheels.



Apparently the dealer got a faulty set of refurbished calipers, and after a short while they started leaking heavily. In fact so much that the car had complete brake failure.

The issue was fixed on the guarantee, so aside from some driving back and forth and time spent on this little was lost.

As a small bonus I got to drive a tricked up Defender for a day.

The car was a 90" soft top van with the new 2.5 TD5 power plant. Additionally the car was equipped with a bull bar, snorkel, lift kit and large wheels with BF Goodrich T/A Mud Terrain.

It was very windy the day I had it and I have to say this car is by far the noisiest thing i have EVER tried. Not even my own Discovery 3.9 EFI v8 with its exhaust broken right after the manifold comes even close.

In fact I think it is about the same amount of db in the cabin at 100 km / h as my dads old Massey Ferguson 165 at 2500 rpm at plowing.

The diesel is quite noisy in itself. But if you add to this that the tires are very noisy on road and that the soft top makes an extreme amount of flapping noise - especially on the highway of cause - It really put me off considering a soft top Defender. It is really only usable on the African savanna.

My suggestion is to buy a hard top or a pickup version.

Aside from that the car has a good engine. It was the first try of the Defender 2.4 for me.

And I have to admit it does look quite nice on my driveway. I really like this car in white.

Thursday, April 21, 2011

Sunday, May 16, 2010

NFS version 3 on FreeBSD using unfsd

Standard
Introduction


I have had some problems reading files larger than 2 gb through nfs2. It is afaik a limitation of the standard it self. Therefore it is necessary to look at some of the later versions of this protocol for file operations on larger files.

I am not sure what the current standard in FreeBSD is (version 7.x.x) since I am still using the version 6 of FreeBSD. However this setup should also work with later versions of the OS.

Software installation

You should add the unfsd daemon using the ports collection or add it via a precompiled package. If you follow the attached link to this blog entry, it links to the installation page on freshports.org.

Subsequent configuration

The installation package does not include a rc script to start and stop the daemon, so i modified the system one in /etc/rc.d/nfsd to fit unfsd in /usr/local/etc/rc.d.

This is the rc file

# PROVIDE: unfsd
# REQUIRE: mountd
# KEYWORD: nojail

. /etc/rc.subr

name="unfsd"
rcvar=`set_rcvar unfs_server`
command="/usr/local/sbin/${name}"

load_rc_config $name
command_args="${unfs_server_flags}"
exports="${unfs_server_exports}"
pidfile=/var/run/${name}.pid
start_precmd="unfsd_precmd"
stop_cmd="unfsd_stop_cmd"
start_cmd="unfsd_start_cmd"
sig_stop="USR1"

unfsd_precmd()
{
    if ! sysctl vfs.nfsrv >/dev/null 2>&1; then
        force_depend nfsserver || return 1
    fi

    if ! checkyesno rpcbind_enable  && \
        ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
    then
        force_depend rpcbind || return 1
    fi

    if ! checkyesno mountd_enable  && \
        ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1
    then
        force_depend mountd || return 1
    fi

    if checkyesno nfs_reserved_port_only; then
        echo 'NFS on reserved port only=YES'
        sysctl vfs.nfsrv.nfs_privport=1 > /dev/null
    fi
    return 0
}

unfsd_start_cmd()
{
    $command -e $exports -i $pidfile $command_args
}

unfsd_stop_cmd()
{
    if [ -f "$pidfile" ] ; then
        kill `cat ${pidfile}`
    fi
}

run_rc_command "$1"

This is the entries needed in /etc/rc.conf

unfs_server_enable="YES"
unfs_server_exports="/etc/uexports"

You should then add a /etc/uexports file to fit the format of unfsd. It is different from the system supplied nfsd from FreeBSD, so I suggest using a seperate file for this. In that way a rollback to the old version is a matter of re enabling it in rc.conf.

If you do not specify a named export file the unfsd will parse /etc/exports, and that will not work unless you edit it to fit the unfsd format.

Man unfsd will give you some examples of the format.

Conclusion

This will make it possible for you to use 2 gig plus files with nfs. In addition you will be able to use larger read and write sizes if you so choose.

Wednesday, March 3, 2010

ACPI brightness on Ubuntu with Nvidia cards and Intel Vpro chipset

Standard
Introduction
I have long had no response on my laptop, a HP 8510w on the brightness buttons. That is the fn+F9 and fn+f10.

It has been a source of irritation, and I decided to fix it.

Here is  how:
  1. Install nvclock
  2. Create nvclock wrapper scripts
  3. Create the necessary acpi config event mappers for acpid. 
Installation of nvclock

sudo apt-get install nvclock

Create nvclock wrapper scripts
Create file /etc/acpi/hp-brightness-up.sh:

#!/bin/sh
/usr/bin/nvclock -S +10


Create file /etc/acpi/hp-brightness-down.sh:

#!/bin/sh
/usr/bin/nvclock -S -10


 Create ACPID config files
Create file /etc/acpi/events/hp-brightness-up:

event=video C160 00000086 00000000
action=/etc/acpi/hp-brightness-up.sh
 

Create file /etc/acpi/events/hp-brightness-down:

event=video C160 00000087 00000000
action=/etc/acpi/hp-brightness-down.sh
 

 Restart ACPID subsystem
The acpid system is restarted like this:

sudo /etc/init.d/acpid restart


Final notes
If you have problems with this check to see if the event codes written above match the ones actually returned by the acpi subsystem of your laptop. The tools acpi_listen and acpital will both tell you more info. Start one of these programs in a terminal and to pressing the buttons you wish to configure.

Thursday, September 10, 2009

Python inheritance using object and class variables

Standard
Introduction:
When you have been working with Java for many years, it is sometimes fun to delve into other languages to get some new inspiration. For the past few days I have been meddeling around with Python / Django and Google App engine.

A discussion over MSN with a friend resulted in me coding this small example of how Python class and object variables differ greatly from what is normal in Java. Also this example illustrates very simple interitance from object->Vehicle->Car and Truck.

Code:
Package for vehicles:

'''
Created on Sep 10, 2009

@author: nikolaj
'''

class Vehicle(object):
'''
classdocs
'''
number_of_vehicles = 0

def __init__(self, color, number, weight):
self.number = number
self.weight = weight
self.color = color
Vehicle.number_of_vehicles += 1
print '(Initializing Vehicle %s which is of type %s)' % (self.number, type(self))


def __del__(self):
Vehicle.number_of_vehicles -= 1

if Vehicle.number_of_vehicles == 0:
print 'Vehicle: I am the last one on the streets now ...'
else:
print 'Vehicle: There are still %d of us left.' % Vehicle.number_of_vehicles

class Car (Vehicle):
'''
classdocs
'''
number_of_cars = 0

def __init__(self, color, number, passengers, weight):
Vehicle.__init__(self, color, number, weight)
self.passengers = passengers
Car.number_of_cars += 1

def __del__(self):
print 'Car: %s says bye. I am off to the scrap heap' % self.number
Car.number_of_cars -= 1

if Car.number_of_cars == 0:
print 'Car: I am the last Car on the streets now ...'
else:
print 'Car: There are still %d Cars left.' % Car.number_of_cars

def howmany (self):
print "Car: %d cars and %d vehicles in total" % (Car.number_of_cars, Car.number_of_vehicles)

class Truck (Vehicle):
'''
classdocs
'''
number_of_trucks = 0

def __init__(self, color, number, tonnage, weight):
Vehicle.__init__(self, color, number, weight)
self.tonnage = tonnage
Truck.number_of_trucks += 1

def __del__(self):
print 'Truck: %s says bye. I am off to the scrap heap' % self.number
Truck.number_of_trucks -= 1

if Truck.number_of_trucks == 0:
print 'Truck: I am the last Truck on the streets now ...'
else:
print 'Truck: There are still %d Trucks left.' % Truck.number_of_trucks

def howmany (self):
print "Truck: %d trucks and %d vehicles in total" % (Truck.number_of_trucks, Truck.number_of_vehicles)


Executable pyton main

from dk.hsys.model.vehicle import Car
from dk.hsys.model.vehicle import Truck

'''
Created on Sep 10, 2009

@author: nikolaj
'''

def main():

car = Car('Blue', 'RH20358', 4, 725)
car2 = Car('Yellow', 'DC79929', 2, 800)
car2.howmany()

truck = Truck('Red', 'CV34254', 22, 32)
truck2 = Truck('Green', 'BD7638', 2, 4)
truck3 = Truck('Black', 'HG76543', 30, 40)
truck.howmany()

if __name__ == '__main__':
main()



Output:


(Initializing Vehicle RH20358 which is of type )
(Initializing Vehicle DC79929 which is of type )
Car: 2 cars and 2 vehicles in total
(Initializing Vehicle CV34254 which is of type )
(Initializing Vehicle BD7638 which is of type )
(Initializing Vehicle HG76543 which is of type )
Truck: 3 trucks and 5 vehicles in total
Car: RH20358 says bye. I am off to the scrap heap
Car: There are still 1 Cars left.
Car: DC79929 says bye. I am off to the scrap heap
Car: I am the last Car on the streets now ...
Truck: CV34254 says bye. I am off to the scrap heap
Truck: There are still 2 Trucks left.
Truck: BD7638 says bye. I am off to the scrap heap
Truck: There are still 1 Trucks left.
Truck: HG76543 says bye. I am off to the scrap heap
Truck: I am the last Truck on the streets now ...

Tuesday, August 25, 2009

Automount with ssh and nfs

Standard
Introduction

I have for a long time mounted and unmounted network file systems by hand when ever I had a need for them. It is not a big thing, but you have to open a terminal in order to do this every time. I experimented a little with automount and autofs and found, that you can dynamically do things in the mount specification files.

Autofs dynamically executes mount commands triggered when you access a defined folder in your system. This folder then becomes the mount point for a given network or local file system. Another use for autofs is access of cd's, floppies and other removable block devices.

This is especially usefull from a Laptop computer, that sometimes are connected to network file systems behind a firewall, sometimes connected to ssh/sftp systems when you are on the road.

The goal is to be able to dynamically let the laptop figure out, what protocol to use: NFS or SSH/SFTP depending on the location of your connection.

Preparing the software

You will need to add the autofs system to your distribution of choice, this is for Debian / Ubuntu:

$ sudo apt-get install autofs

This will add the autofs system to the list of installed packages on your laptop PC.

You will now need to add netcat and sshfs to your system - it is used to check if a ssh server is accessible and mount the nfs share via SSH if it is:


$ sudo apt-get install netcat sshfs

Autofs will add a daemon to your system for monitoring your configured mount points. The deamon needs to be told to reload configurations whenever you change your configuration:



$ sudo /etc/init.d/autofs reload
Reloading automounter: checking for changes ...
Reloading automounter map for: /misc
Reloading automounter map for: /mnt/media


The configuration for the autofs system is held in files in /etc/auto.* where you can add you mount points as you need them. There is several good examples in the ones already added by default. However I produced a new named auto.media and added it to /etc/auto.master in order to access my media drive. This is the contents:



#!/bin/sh
# check to see if this host has a working internet connection and a IP address
MYIP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
ping -c 1 ${MYIP} >> /dev/null 2>&1
if [ "$?" -ne "0" ]
then
exit 1;
fi

# check to see if HOSTNAME can be pinged directly - if yes echo the mount lines for nfs
ping -c 1 HOSTNAME >> /dev/null 2>&1
if [ "$?" -eq "0" ]
then
echo "root -fstype=nfs,rw,sync,soft,intr,rsize=8012,wsize=8129 HOSTNAME:/foo/bar/&"
echo "data2 -fstype=nfs,rw,sync,soft,intr,rsize=8012,wsize=8129 HOSTNAME:/foo/bar/&"
echo "download -fstype=nfs,rw,sync,soft,intr,rsize=8012,wsize=8129 HOSTNAME:/foo/bar/&"
exit 0;
fi

# check to see if SSHHOST can be contacted - if yes use the ssh/nfs to mount using fuse
nc -z SSHHOSTNAME 22 > /dev/null 2>&1
if [ "$?" -eq "0" ]
then
echo "-fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#USER\@SSHHOST:/foo/bar/&"
exit 0;
exit 0;
fi


The file /etc/auto.media listed above should be made executable with permissions 755. When executed it will dynamically produce the contents of the auto.media file depending on the script execution. As a consequence the mount points will not be visible in /mnt until execution of the script has completed. So you will have to cd to a non existing folder like /mnt/media before you actually see it created in /mnt :-)


Conclusion and caveat

The above works fine for me. There could be a problem, if you are on a foreign network, where another server called HOSTNAME exists. You may need to add more intelligent identification check of the HOSTNAME server in order to make this work correctly in all networks.

Tuesday, June 9, 2009

Land Rovers with Perkins diesel?

Standard
In the old days I believe that I read somewhere that Land Rover actually considered using one of the Perkins diesel engines in the Defender models.

It never happened as far as I know.

Never the less: Nothing that can be done to a Defender will be left un done.

Here is a Defender pick up with a Perkins inline 6. The P6.



He must blow those half shafts as quick as he can exchange them ...

Or perhaps even with the great Cummins Turbo diesel also used in the Dodge Rams?