Device Mapper installation
==========================

1) Generate custom makefiles.

   Run the 'configure' script from the top directory.

   Example:
   ./configure

   If your 2.4 kernel does NOT yet contain the device-mapper source
   AND you want to try patching it automatically (described 
   in step 2) then you need to tell 'configure' where your kernel 
   source directory is using --with-kernel-dir.  Otherwise, don't
   supply this parameter or you may get compilation failures.

   Example:  
   ./configure --with-kernel-dir=/usr/src/linux-2.4.26-rc1

   2.6 kernels now already contain basic device-mapper patches
   BUT they do not support snapshots and pvmove yet.

   The same userspace library and tools work with both 2.4 and 2.6 kernels
   because they share the same device-mapper interface (version 4).
   If you also still need backwards-compatibility with the obsolete
   version 1 interface, then you must compile against 2.4 kernel 
   headers (not 2.6 ones) and:

   ./configure --enable-compat

   Other parameters let you change the installation & working directories.


2) If your kernel does not already contain device-mapper, patch,
   configure and build a new kernel with it.

   If there is a patch for your kernel included in this package and you
   gave 'configure' appropriate parameters in step 1, you can run 
   'make apply-patches' from the top directory to apply the patches.  
   (This also attempts to apply the VFS lock patch, which will fail if 
   you've already applied it.  For 2.4.21 there's a choice of two VFS lock
   patches: the experimental one is destined to replace the old-style one.
   The VFS lock patch is designed to suspend the filesystem whenever
   snapshots are created so that they contain a consistent filsystem.)
   
   Configure, build and install your kernel in the normal way, selecting
   'Device mapper support' from the 'Multiple devices driver support' menu.
   If you wish to use 'pvmove' you also need to select 
   'Mirror (RAID-1) support'.

   If you are patching by hand, the patches are stored in the
   'patches' subdirectory.  The name of each patch contains the kernel
   version it was generated against and whether it is for the 'fs' or
   'ioctl' interface.  Current development effort is concentrated
   on the 'ioctl' interface.  (Use CVS to get the older 'fs' patches if
   you want - see note at end.)

   patches/common holds the constituent patches.
   You may need to use these if some of the patches (e.g. mempool)
   have already been applied to your kernel.  See patches/common/README.
   You should also apply the VFS lock patch (but not required if you're only
   using ext2).

   Running 'make symlinks' from the 'kernel' subdirectory will put symbolic 
   links into your kernel tree pointing back at the device-mapper source files.
   If you do this, you'll probably also need to apply the VFS patch and all
   the constituent patches in patches/common except for the devmapper one.
   

3) Build and install the shared library (libdevmapper.so) that
   provides the API.

   Run 'make' from the top directory.

      Example:  make install

   The DESTDIR environment variable is supported (e.g. for packaging).


4) If you are not using devfs then install scripts/devmap_mknod.sh to run
   either:

      Each time the kernel boots 
        e.g. add to /etc/rc*

      Or whenever the device-mapper is loaded (if you built it as a module)
        e.g. add the following line to /etc/modules.conf and run depmod -a
	     and use modprobe dm-mod to load the module
	post-install dm-mod /etc/init.d/devmap_mknod.sh
	
   The script creates the /dev/mapper/control device for the ioctl
   interface using the major and minor numbers that have been allocated
   dynamically.  It prints a message if it works or else it fails silently 
   with a non-zero status code (which you probably want to test for).

   To clean up the /dev/mapper directory (e.g. to remove invalid entries
   left behind after a crash) run:

      dmsetup mknodes


5) You can now boot your new kernel and use 'dmsetup' to test the API.
   Read the dmsetup man page for more information.
   Or proceed to install the new LVM2 tools.


Note if you are upgrading from an old release
=============================================
   /dev/mapper was called /dev/device-mapper prior to 0.96.04.
   Consequently scripts/devmap_mknod.sh has been updated.

Notes about the alternative filesystem interface
================================================
The original 2.4 filesystem interface has not been updated for many
months, requires an old kernel, and is missing lots of features.

A new filesystem interface was developed which mapped device-mapper
operations into filesystem operations, but work on this has stopped.
Look for "dmfs" patches at:
   http://people.sistina.com/~thornber/patches/

