Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Apr 02, 2009 2:58 pm 
Offline
Senior Newbie

Joined: Tue Mar 31, 2009 9:39 pm
Posts: 8
This how-to is the culmination of discussion at http://www.linode.com/forums/viewtopic.php?p=19873#19873. Lots of credit to irgeek and condate for their help!

Installing drbd as a kernel module should (and sometimes does) go smoothly. However, when I tried to get it running on Debian 5.0 (Lenny) using the current Latest 2.6 series kernel (2.6.18-linode16), I ran into considerable difficulty, mostly based on my inexperience with Linux and kernel/module work. We finally identified the issue as a mismatch between the version of gcc (gcc-4.2) when building the linode16 kernel and the version of gcc (gcc-4.3) installed in Debian 5.0.

Standard instructions
(provided by irgeek, and reproduced - hopefully without error - by me.)

First we grab the necessary tools:

Code:
apt-get install build-essential flex bison wget unifdef


Then retrieve the kernel sources and build the kernel. Note that at the time of writing, Linode's latest 2.6 kernel is 2.6.18-linode16, but this should match the kernel selected in your configuration profile in the Linode Manager.

Code:
cd /usr/src 
wget http://www.linode.com/src/2.6.18.8-linode16.tar.bz2
tar -jxf 2.6.18.8-linode16.tar.bz2
cd 2.6.18.8-linode16
make -j4


If all went well, we get a final output like this:

Code:
Kernel: arch/i386/boot/vmlinuz is ready  (#2)


Next, we need headers and a symlink to /usr/src/linux. Again, make sure you're referencing the kernel source directory you're actually using.

Code:
make headers_install 
cd ..
ln -s 2.6.18.8-linode16 linux


Now we can get the latest drbd sources (8.3.1 as of this writing, but check for yourself) and build our module:

Code:
wget http://oss.linbit.com/drbd/8.3/drbd-8.3.1.tar.gz 
tar -zxf drbd-8.3.1.tar.gz
cd drbd-8.3.1
make KDIR=/usr/src/linux/


Assuming that went well, we can install the module, insert the module, and verify it's there.

Code:
make install 
modprobe drbd
lsmod
Module                  Size  Used by
drbd                  257688  0


If everything worked, bravo! But if you end up with this message after your modprobe...

Code:
modprobe drbd 
FATAL: Error inserting drbd (/lib/modules/2.6.18.8-linode16/kernel/drivers/block/drbd.ko): Invalid module format


... then clearly we need to do something differently. This is where I was when trying this procedure on Debian 5.0 (Lenny) using the 2.6.18-linode16 kernel. The linode16 kernel I was running was compiled with gcc-4.2, and Debian 5.0 has gcc-4.3 installed. Fail.

First, verify the problem by looking at the tail end of your dmesg:

Code:
dmesg | tail 
(clipped)
drbd: version magic '2.6.18.8-linode16 SMP mod_unload Xen PENTIUM4 REGPARM gcc-4.3' should be '2.6.18.8-linode16 SMP mod_unload Xen PENTIUM4 REGPARM gcc-4.2'


I checked my installed version of gcc (although the dmesg pretty much tells me that it's gcc-4.3):

Code:
gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)


Install gcc-4.2, and change over to it so you can recompile:

Code:
apt-get install gcc-4.2 
rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.2 /usr/bin/gcc


Go back to the procedure above, and recompile drbd:

Code:
cd /usr/src/drbd-8.3.1 
make KDIR=/usr/src/linux/
make install


Test to see if it worked. If so, modprobe won't return anything, and lsmod will return the module and size:

Code:
modprobe drbd 
lsmod
Module                  Size  Used by
drbd                  257688  0


Return to the correct version of gcc:

Code:
rm /usr/bin/gcc 
ln -s /usr/bin/gcc-4.3 /usr/bin/gcc


I'm sure there are other interesting problems one can encounter when trying to install drbd, and I've only covered one here. Fortunately, it's the only one I've encountered.


Top
   
 Post subject:
PostPosted: Sat Jun 27, 2009 7:22 am 
Offline

Joined: Sat Jun 27, 2009 7:18 am
Posts: 1
Website: http://www.softsea.com/review/LimeWire-for-Linux.html
Amazing code, lsmod return the module and size, it is great, Thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group