diff --git a/build_upload_debian_package.sh b/build_upload_debian_package.sh
index ed9b912..89eb520 100755
--- a/build_upload_debian_package.sh
+++ b/build_upload_debian_package.sh
@@ -1,12 +1,16 @@
 #!/bin/sh
 
+# date output wrong if not english 
+export LANG=C
+
 # figure version
 major=`grep CEPH_VERSION_MAJOR ceph_fs.h | awk '{print $3}' | head -1`
 minor=`grep CEPH_VERSION_MINOR ceph_fs.h | awk '{print $3}' | head -1`
 patch=`grep CEPH_VERSION_PATCH ceph_fs.h | awk '{print $3}' | head -1`
+fix=`grep CEPH_VERSION_FIX ceph_fs.h | awk '{print $3}' | head -1`
 
-vers="$major.$minor"
-[ "$patch" != "0" ] && vers="$vers.$patch"
+vers="$major.$minor.$patch"
+[ "$fix" != "0" ] && vers="$vers.$fix"
 
 echo "version $vers"
 
@@ -21,34 +25,38 @@ repo=$1
 
 if [ "$repo" = "unstable" ]; then
     versuffix=`date "+%Y%m%d%H%M%S"`
-    finalvers="${vers}git$versuffix"
-    debdate=`date "+%a, %d %b %Y %X %z"`
+    finalvers="${vers}-0git$versuffix"
 else
-    finalvers="$vers"
+    finalvers="$vers-1"
 fi
 
+debdate=`date "+%a, %d %b %Y %X %z"`
+
 echo "final version $finalvers"
 
 
-dir="ceph-kclient-$finalvers";
+dir="ceph-dkms-$finalvers";
+origtargz="ceph-dkms_$vers.orig.tar.gz";
 
-rm -r ceph-kclient-*
-rm *.deb
-rm *.changes
-rm *.dsc
-rm *.tar.gz
+rm -fr ceph-dkms-*
+rm -f *.deb
+rm -f *.changes
+rm -f *.dsc
+rm -f *.tar.gz
 
 mkdir $dir
 
+# poor man copy with excludes
+tar cf - --exclude=$dir ./ | (cd $dir; tar -xf - )
+
 cd $dir
-cp -a ../* .
 make clean
 
 if [ "$vers" != "$finalvers" ]; then
     echo fixing up changelog
     mv debian/changelog debian/changelog.tmp
     cat <<EOF > debian/changelog
-ceph-kclient ($finalvers) unstable; urgency=low
+ceph-dkms ($finalvers) unstable; urgency=low
 
    * snapshot from git at $versuffix
 
@@ -58,23 +66,29 @@ EOF
     cat debian/changelog.tmp >> debian/changelog
 fi
 
+cd ..
+
+tar -czf $origtargz $dir
+
+cd $dir
+
 # build
 dpkg-buildpackage -rfakeroot
 
 cd ..
 
 # hrm!
-mv ceph-kclient_${finalvers}-1_*.changes ceph-kclient_${finalvers}-1_all.changes
+mv ceph-dkms_${finalvers}-1_*.changes ceph-dkms_${finalvers}-1_all.changes
 
-#exit 0
+exit 0
 
 # upload
 rsync -v --progress *deb sage@ceph.newdream.net:debian/dists/$repo/main/binary-all
-rsync -v --progress ceph-kclient_* sage@ceph.newdream.net:debian/dists/$repo/main/source
+rsync -v --progress ceph-dkms_* sage@ceph.newdream.net:debian/dists/$repo/main/source
 
 if [ "$vers" == "$finalvers" ]; then
     echo build tarball, too.
-    mydir="ceph-kclient-source-$finalvers"
+    mydir="ceph-dkms-source-$finalvers"
     cp -a $dir $mydir
     tar zcf $mydir.tar.gz $dir/*.[ch] $dir/Makefile $dir/Kconfig $dir/crush/*.[ch] $dir/debian
     scp $mydir.tar.gz sage@ceph.newdream.net:ceph.newdream.net/download
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..b7340d9
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,4 @@
+ceph dkms
+-----------------
+
+build log: /var/lib/dkms/ceph/<modversion>/<kernelrelease>/<arch>/log/make.log
diff --git a/debian/ceph-dkms.install b/debian/ceph-dkms.install
new file mode 100644
index 0000000..73752c9
--- /dev/null
+++ b/debian/ceph-dkms.install
@@ -0,0 +1 @@
+usr
diff --git a/debian/ceph-dkms.postinst b/debian/ceph-dkms.postinst
new file mode 100644
index 0000000..d0dd1c1
--- /dev/null
+++ b/debian/ceph-dkms.postinst
@@ -0,0 +1,39 @@
+#!/bin/sh
+set -e
+
+NAME=ceph
+PACKAGE_NAME=$NAME-dkms
+DEBVERS=$(dpkg-query -W -f='${Version}' $PACKAGE_NAME | awk -F- '{print $1}')
+VERSION=$(echo $DEBVERS |sed -e 's/[+-].*//' -e 's/~//g')
+
+ARCH=$(dpkg --print-architecture)
+case $ARCH in
+        amd64)
+                ARCH="x86_64"
+                ;;
+        i386)
+                ARCH="i686"
+                ;;
+        *)
+                echo "WARNING: unsupported arch: $ARCH"
+                ARCH="$ARCH"
+                ;;
+esac
+
+case "$1" in
+        configure)
+		/usr/lib/dkms/common.postinst $NAME $VERSION
+		exit $?
+        ;;
+
+        abort-upgrade|abort-remove|abort-deconfigure)
+        ;;
+
+        *)
+                echo "postinst called with unknown argument \`$1'" >&2
+                exit 1
+        ;;
+esac
+
+#DEBHELPER#
+
diff --git a/debian/ceph-dkms.prerm b/debian/ceph-dkms.prerm
new file mode 100644
index 0000000..1e7f83c
--- /dev/null
+++ b/debian/ceph-dkms.prerm
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -e
+
+NAME=ceph
+PACKAGE_NAME=$NAME-dkms
+DEBVERS=$(dpkg-query -W -f='${Version}' $PACKAGE_NAME | awk -F- '{print $1}')
+VERSION=$(echo $DEBVERS |sed -e 's/[+-].*//' -e 's/~//g')
+
+case "$1" in
+    remove|upgrade)
+		echo "Removing all DKMS Modules"
+		dkms remove -m $NAME -v $VERSION --all > /dev/null
+		echo "Done."
+        ;;
+esac
+
+#DEBHELPER#
+
diff --git a/debian/ceph-kclient-source.dirs b/debian/ceph-kclient-source.dirs
deleted file mode 100644
index 8de417f..0000000
--- a/debian/ceph-kclient-source.dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/src/modules
diff --git a/debian/ceph-kclient-source.install b/debian/ceph-kclient-source.install
deleted file mode 100644
index 132681b..0000000
--- a/debian/ceph-kclient-source.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/src/*
diff --git a/debian/changelog b/debian/changelog
index 5b9dea8..af905bd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,61 +1,5 @@
-ceph-kclient (0.19-1) unstable; urgency=low
+ceph-dkms (0.1) unstable; urgency=low
 
-  * asdf 
+  * Initial release (Closes: #xxxxx)
 
- -- Sage Weil <sage@fatty.ops.newdream.net>  Thu, 18 Feb 2010 09:31:05 -0800
-
-ceph-kclient (0.17) unstable; urgency=low
-
-  * kclient: fix multiple mds mdsmap decoding
-  * kclient: fix mon subscription renewal
-  * crush: fix map creation with empty buckets (larger clusters)
-  * fix osdmap crash on bad encoding
-
- -- sage <sage@newdream.net>  Mon, 19 Oct 2009 15:20:00 -0800
-
-ceph-kclient (0.16.1-1) unstable; urgency=low
-
-  * missing buffer.c
-  * rgw build problem on i386
-
- -- sage <sage@newdream.net>  Tue, 06 Oct 2009 10:29:00 -0800
-
-ceph-kclient (0.16-1) unstable; urgency=low
-
-  * disk format, wire changes
-  * use sockaddr_storage throughout
-  * kclient: fix msgr bug
-  * kclient: uninline strings, use pr_fmt, prefix frag_ macros
-  * kclient: lots of inline cleanups
-  * kclient: misc akpm review cleanups
-
- -- sage <sage@newdream.net>  Mon, 05 Oct 2009 14:54:00 -0800
-
-ceph-kclient (0.15-1) unstable; urgency=low
-
-  * kclient: checkpatch fixes, cleanups.
-  * kclient: msg revoke, clean up interface
-  * kclient: GET_DATALOC ioctl
-  * kclient: osdc bug fix
-  * kclient: clean up debugfs layout
-
- -- sage <sage@newdream.net>  Tue, 22 Sep 2009 10:15:00 -0800
-
-ceph-kclient (0.14-1) unstable; urgency=low
-
-  * kclient: cleanups, new msgr.  no msgpools (for now)
-
- -- sage <sage@newdream.net>  Mon, 8 Sep 2009 14:48:00 -0800
-
-ceph-kclient (0.13-1) unstable; urgency=low
-
-  * kclient: some improvements in kmalloc, memory preallocation
-  * [ku]lcient: fix sync read vs eof, lseek(..., SEEK_END)
-
- -- sage <sage@newdream.net>  Mon, 24 Aug 2009 10:43:00 -0800
-
-ceph-kclient (0.12-1) unstable; urgency=low
-
-  * kclient: mapping_set_error in writepage, layout ioctl, writeback mempools, cap writeback, fsync
-
- -- sage <sage@newdream.net>  Wed, 5 Aug 2009 13:58:00 -0800
+ -- Thomas Mueller <thomas@chaschperli.ch>  Sun, 06 Jul 2010 15:07:09 +0100
diff --git a/debian/compat b/debian/compat
index 7ed6ff8..7f8f011 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-5
+7
diff --git a/debian/control b/debian/control
index af56d37..1583318 100644
--- a/debian/control
+++ b/debian/control
@@ -1,19 +1,18 @@
-Source: ceph-kclient
-Section: admin
-Priority: optional
-Maintainer: Sage Weil <sage@newdream.net>
-Standards-Version: 3.7.2
-Architecture: all
+Source: ceph-dkms
+Section: net
+Priority: extra
+Maintainer: Thomas Mueller <thomas@chaschperli.ch>
+Build-Depends: debhelper (>= 7.4.2~)
+Standards-Version: 3.8.4
+Vcs-Git: http://ceph.newdream.net/git/ceph-client-standalone.git
+Vcs-Browser: http://ceph.newdream.net/git/?p=ceph-client-standalone.git;a=summary
+Homepage: http://ceph.newdream.net
 
-Package: ceph-kclient-source
+Package: ceph-dkms
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, make
-Description: source for client kernel module for the Ceph distributed file system
- Ceph is a distributed network file system designed to provide
- excellent performance, reliability, and scalability.  This is the
- Ceph client source package for building the client kernel module.
+Replaces: ceph-kclient-source
+Depends: ${shlibs:Depends}, ${misc:Depends}, dkms
+Description: ceph fs kernel driver [DKMS driver source]
  .
- This native kernel client is faster and is more robust than the 
- FUSE-based client (ceph-fuse).  However, you need to compile the
- module against your running kernel and will need root privileges
- to load it.
+ This package provides the Linux kernel module source which has been
+ prepared for use with DKMS.
diff --git a/debian/copyright b/debian/copyright
index 6d916ba..ab6ae45 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,3 +1,6 @@
+The package was rewritten to dkms by Thomas Mueller <thomas@chaschperli.ch>
+Wed, 07 Jul 2010 11:00:17 +0200
+
 This package was debianized by Sage Weil <sage@newdream.net> on
 Mon, 28 Jan 2008 14:58:17 -0800.
 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..e69de29
diff --git a/debian/rules b/debian/rules
index b5abd69..6b292a5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,79 +1,23 @@
 #!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-# Uncomment this to turn on verbose mode.
-export DH_VERBOSE=1
-configure: configure-stamp
-configure-stamp:
-	dh_testdir
-	touch configure-stamp
-build: build-stamp
-build-stamp: configure-stamp  
-	dh_testdir
-	touch $@
-clean: 
-	dh_testdir
-	dh_testroot
-	rm -f build-stamp configure-stamp
+# -*- mode: makefile; coding: utf-8 -*-
+# Copyright © 2010 Paul McEnery <pmcenery@gmail.com>
 
-	dh_clean 
-install: build
-	dh_testdir
-	dh_testroot
-	dh_clean -k 
-	dh_installdirs
+# Variables
+DEBVERS  := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 \
+		| cut -d- -f1)
+VERSION  := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')
 
-	# kernel module source
-	mkdir -p usr/src/modules/ceph
-	mkdir usr/src/modules/ceph/crush
+%:
+	dh $@
 
-	cp Makefile *.[ch] usr/src/modules/ceph
-	cp crush/*.[ch] usr/src/modules/ceph/crush
-	touch usr/src/modules/ceph/NEWS
-	touch usr/src/modules/ceph/README
-	mkdir -p usr/src/modules/ceph/debian
-	-cp debian/* usr/src/modules/ceph/debian
-	mv usr/src/modules/ceph/debian/rules.modules.in usr/src/modules/ceph/debian/rules
-	chmod +x usr/src/modules/ceph/debian/rules
+# Build ipeth-pair binary only
+override_dh_auto_build:
 
+override_dh_clean:
 
-# Add here commands to install the package into debian/testpack.
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-	dh_installchangelogs 
-	dh_installdocs
-	dh_installexamples
-	dh_install
-#	dh_installmenu
-#	dh_installdebconf	
-#	dh_installlogrotate
-#	dh_installemacsen
-#	dh_installpam
-#	dh_installmime
-#	dh_python
-#	dh_installinit
-#	dh_installcron
-#	dh_installinfo
-#	dh_installman
-	dh_link
-#	dh_strip
-	dh_compress
-	dh_fixperms
-#	dh_perl
-#	dh_makeshlibs
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+
+# Remove the dh_auto_install step
+override_dh_auto_install:
+	install -d $(CURDIR)/debian/tmp/usr/src/ceph-$(VERSION)
+
+	tar cvf - --exclude=debian ./ | (cd $(CURDIR)/debian/tmp/usr/src/ceph-$(VERSION); tar -xvf - )
diff --git a/debian/rules.modules.in b/debian/rules.modules.in
deleted file mode 100644
index 4e22a3f..0000000
--- a/debian/rules.modules.in
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/make -f
-
-PACKAGE=ceph-modules
-### KERNEL SETUP
-### Setup the stuff needed for making kernel module packages
-### taken from /usr/share/kernel-package/sample.module.rules
-
-# prefix of the target package name
-# PACKAGE=pvfs-modules
-# modifieable for experiments or debugging m-a
-MA_DIR ?= /usr/share/modass
-# load generic variable handling
--include $(MA_DIR)/include/generic.make
-# load default rules, including kdist, kdist_image, ...
--include $(MA_DIR)/include/common-rules.make
-
-# module assistant calculates all needed things for us and sets
-# following variables:
-# KSRC (kernel source directory), KVERS (kernel version string), KDREV
-# (revision of the Debian kernel-image package), CC (the correct
-# compiler), VERSION (the final package version string), PKGNAME (full
-# package name with KVERS included), DEB_DESTDIR (path to store DEBs)
-
-# The kdist_configure target is called by make-kpkg modules_config and
-# by kdist* rules by dependency. It should configure the module so it is
-# ready for compilation (mostly useful for calling configure).
-# prep-deb-files from module-assistant creates the neccessary debian/ files 
-kdist_configure: prep-deb-files
-
-# the kdist_clean target is called by make-kpkg modules_clean and from
-# kdist* rules. It is responsible for cleaning up any changes that have
-# been made by the other kdist_commands (except for the .deb files created)
-kdist_clean:
-	@$(MAKE) $(MFLAGS) KERNELDIR=$(KSRC) clean
-
-### end  KERNEL SETUP
-
-# the binary-modules rule is invoked by module-assistant while processing the
-# kdist* targets. It is called by module-assistant or make-kpkg and *not*
-# during a normal build
-
-binary-modules: prep-deb-files
-	dh_testroot
-	dh_clean -k
-	$(MAKE) KERNELDIR=$(KSRC) all
-	mkdir -p ./debian/$(PACKAGE)-$(KVERS)/lib/modules/$(KVERS)/kernel/fs/ceph
-	cp ceph.ko ./debian/$(PACKAGE)-$(KVERS)/lib/modules/$(KVERS)/kernel/fs/ceph/
-	dh_installdocs
-	dh_installchangelogs
-	dh_compress
-	dh_fixperms
-	dh_strip
-	dh_installmodules
-	dh_install
-	dh_installdeb
-	dh_gencontrol -- -v$(VERSION)
-	dh_md5sums
-	dh_builddeb --destdir=$(DEB_DESTDIR)
-	dh_clean -k
-
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/dkms.conf b/dkms.conf
new file mode 100644
index 0000000..bb05fa0
--- /dev/null
+++ b/dkms.conf
@@ -0,0 +1,8 @@
+PACKAGE_NAME="ceph"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_LOCATION[0]=""
+DEST_MODULE_LOCATION[0]="/updates/ceph"
+BUILT_MODULE_NAME[0]="ceph"
+AUTOINSTALL="yes"
+PRE_BUILD="dkms/prebuild.sh ${kernelver}"
+POST_REMOVE="dkms/postremove.sh ${kernelver}"
diff --git a/dkms/postremove.sh b/dkms/postremove.sh
new file mode 100644
index 0000000..8693fcf
--- /dev/null
+++ b/dkms/postremove.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+
+if [ "$1" = "" ]
+then
+        echo "Usage: $0 <kernelver>"
+        exit
+fi
+
+MODROOT="/lib/modules/$1"
+
+if ! [ -f /etc/debian_version ]
+then
+        echo "Info: runs only on Debian and derivates"
+        exit
+fi
+
+
+
+if [ -d "$MODROOT" ]
+then
+        if [ -f "$MODROOT/kernel/fs/ceph/ceph.ko.dpkg-divert-by-ceph-dkms" ]
+        then
+                if  ! [ -f "$MODROOT/kernel/fs/ceph/ceph.ko" ]
+                then
+                        dpkg-divert --rename --remove "$MODROOT/kernel/fs/ceph/ceph.ko"
+                else
+                        echo "Warning: $MODROOT/kernel/fs/ceph/ceph.ko  and diverted $MODROOT/kernel/fs/ceph/ceph.ko.dpkg-divert-by-ceph-dkms exist both!"
+                fi
+        fi
+else
+        echo "Warning: $MODROOT is not a directory"
+fi
+
diff --git a/dkms/prebuild.sh b/dkms/prebuild.sh
new file mode 100644
index 0000000..1aee069
--- /dev/null
+++ b/dkms/prebuild.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+
+if [ "$1" = "" ]
+then
+	echo "Usage: $0 <kernelver>"
+	exit
+fi
+
+MODROOT="/lib/modules/$1"
+
+if ! [ -f /etc/debian_version ]
+then
+	echo "Info: runs only on Debian and derivates"
+	exit
+fi
+
+
+if [ -d "$MODROOT" ]
+then
+	if [ -f "$MODROOT/kernel/fs/ceph/ceph.ko" ] 
+	then
+		if  ! [ -f "$MODROOT/kernel/fs/ceph/ceph.ko.dpkg-divert-by-ceph-dkms" ]
+		then
+			dpkg-divert --rename --package ceph-dkms --divert "$MODROOT/kernel/fs/ceph/ceph.ko.dpkg-divert-by-ceph-dkms" --add "$MODROOT/kernel/fs/ceph/ceph.ko"
+		else
+			echo "Warning: $MODROOT/kernel/fs/ceph/ceph.ko  and diverted $MODROOT/kernel/fs/ceph/ceph.ko.dpkg-divert-by-ceph-dkms exist both!"
+		fi
+	fi
+else 
+	echo "Warning: $MODROOT is not a directory"
+fi

