[DRBD-user] howto build DRBD 7.0 kernel module on Red Hat with 2.4.X kernel

Lars Ellenberg Lars.Ellenberg at linbit.com
Sat Jul 17 12:17:12 CEST 2004

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


/ 2004-07-17 11:38:48 +0200
\ Lars Ellenberg:
> / 2004-07-17 09:42:47 +0300
> \ drbd-user at kenyaweb.com:
> > Thanks for response.
> > 
> > Unfortunately there are no rpms for redhat. I looked real hard without
> > much success.
> > 
> > I am trying to install version 0.7 DRBD.
> > 
> > Is there somekind of Redhat howto any where?
> 
> 
> 
> did you read "INSTALL" from the DRBD.tgz?
> 
> did you manage to just compile the RH kernel on its own?
>  (if now, read a howto about that, first)
> 
> did you just try "make" in the drbd directory?
>  (what error messages do you get?)
> did you look into linux/drbd_config.h?
>  (and adjusted the defines?)

> did you try the "make kernel-patch" route?
>  (and patched your kernel, and then just
>    "make menuconfig" in the kernel source tree?)

 oops.
 sorry, I only did it for 2.6. Kconfig style.
 won't work on a 2.4. kernel.

 
> did you set the right compiler?
>  --> export CC=gcc32
>  (you may need to install it)
> 
> there were some threads about DRBD and RH/Fedora in
> February and April, this year. But they only reiterate
> what already can be read in INSTALL, appart from small
> deviations (which made it into that file, later).

anyways.

assumed I don't know nothing about it, and I wanted to compile DRBD.
I unpack the tgz.

plan Z:
  ignore everything, close my eyes, just make.
  does not work.
  A1 --> ask the list. they tell me to read INSTALL.

plan A:
  there is a README and an INSTALL.
  so I read both.
  I follow the section about preparing the kernel source tree.
  ok, make linux/include/version.h fails, but I'll ignore that for now.
  (as lars told me so).
  
  then I follow the section about
   == Build DRBD kernel module (outside of the kernel source) ==
  I see the note about looking into drbd_config.h
  so I do it.  I see some notes about RH and general 2.4 vendor kernels,
  and follow them.
  
  then I do "make clean; make KDIR=$KERNEL_SRC"
  and it fails. I see the note about "On some systems ... CC=gcc32"
  I try again. it  works. Yes.


to prove that:

  this is what I did on my box (which is no RH)
  to compile DRBD-0.7 against RH kernel source
  linux-2.4.22-1.2135.nptl
  # if your kernel source is some different version,
  # you may need to define something different in drbd_config.h

tar -xvzf drbd-0.7.0.tgz
cd drbd-0.7.0/drbd

DRBD_SRC=$PWD
KERNEL_SRC=/some/where/linux-2.4.22-1.2135.nptl

cd $KERNEL_SRC

make menuconfig CC=gcc HOST_CC=gcc
  # note that on RH you probably leave off that "CC=gcc HOST_CC=gcc" part,
  # or use "CC=gcc32 HOST_CC=gcc32" instead...
  # this is just because for some reason RH thinks it is cool to compile
  # the kernel with something different than everything else.
  toggle everything.
  you may want to replace this step with the
   cp some-config .config;
   yes "" | make oldconfig ; yes "" | make oldconfig
  step mentioned in INSTALL

make dep

cd $DRBD_SRC

patch -p0 << ___END_OF_PATCH___
--- linux/drbd_config.h	(revision 1440)
+++ linux/drbd_config.h	(working copy)
@@ -33,11 +33,11 @@
 //#define DUMP_MD 3       // Dump even all meta data access
                           // (don't! unless we track down a bug...)
 
-//#define SIGHAND_HACK           // Needed for RH 2.4.20 and later kernels.
+#define SIGHAND_HACK           // Needed for RH 2.4.20 and later kernels.
 //#define REDHAT_HLIST_BACKPORT  // Makes DRBD work on RH9 kernels
 
 //Your 2.4 verndor kernel already defines find_next_bit()
-//#define HAVE_FIND_NEXT_BIT
+#define HAVE_FIND_NEXT_BIT
 
 //Your 2.4 kernel does not define find_next_bit(),
 //and you are too lazy to "backport" it from 2.6 for your arch:
___END_OF_PATCH___
  
  maybe you rather use your favorite editor :)
  and maybe you must leave off SIGHAND_HACK,
  or define that REDHAT_HLIST_BACKPORT ...
  
make KDIR=$KERNEL_SRC CC=gcc
  # again: on RH you probably leave off that "CC=gcc HOST_CC=gcc" part,
  # or use "CC=gcc32 HOST_CC=gcc32" instead...


Thats it, there it is.
ls -l drbd.o
-rw-r--r--    1 lars     users      160480 2004-07-17 11:49 drbd.o


It is really not THAT difficult, is it.

 :)

	Lars Ellenberg



More information about the drbd-user mailing list