PDA

View Full Version : Build DRBD 8.4.2 on Fedora 17



nutznboltz
1st December 2012, 09:29 PM
1. fetch sources

http://www.drbd.org/users-guide/ch-build-install-from-source.html#s-downloading-drbd-sources

says to use

wget http://oss.linbit.com/drbd/8.4/drbd-latest.tar.gz

but you get a 404 and you really need

wget http://oss.linbit.com/drbd/8.4/drbd-8.4.2.tar.gz

2. setup system build environment


yum install rpm-build redhat-rpm-config flex git autoheader autoconf kernel-devel

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

3. generate spec files


tar xfz drbd-8.4.2.tar.gz
cd drbd-8.4.2
/autogen.sh
./configure --with-km
./configure --enable-spec --with-km
cp ../drbd-8.4.2.tar.gz ~/rpmbuild/SOURCES/
cp drbd*.spec ~/rpmbuild/SPECS/
cd ~/rpmbuild/SPECS/

4. Hack /usr/lib/rpm/redhat/macros

Sad but true

https://bugzilla.redhat.com/show_bug.cgi?id=819747



--- /root/macros.orig 2012-12-01 12:38:05.101671058 -0500
+++ /usr/lib/rpm/redhat/macros 2012-12-01 12:44:55.011215451 -0500
@@ -238,7 +238,7 @@
done \
fi \
echo "%%global flavors_to_build ${flavors_to_build:-%%nil}" \
- echo "%%global kernel_source() /usr/src/kernels/%kverrel-\\\$([ %%%%{1} = default ] || echo "%%%%{1}-")%_target_cpu" \
+ echo "%%global kernel_source() /usr/src/kernels/%kverrel.\\\$([ %%%%{1} = default ] || echo "%%%%{1}.")%_target_cpu" \
if [ ! -z "%{-f*}" ] \
then \
filelist="%{-f*}" \

Two "-" should be "."

5. Hack the drbd-kernel.spec file too.

Admittedly I'm not proud about this hack job. If you have improvements please post them.



$ diff -u drbd-kernel.spec.orig drbd-kernel.spec
--- drbd-kernel.spec.orig 2012-12-01 11:58:40.668370638 -0500
+++ drbd-kernel.spec 2012-12-01 18:55:39.117136636 -0500
@@ -89,10 +89,27 @@
rm -f drbd.conf
%else
mkdir -p $RPM_BUILD_ROOT/etc/depmod.d
-echo "override drbd * weak-updates" \
+echo "override drbd * extra" \
> $RPM_BUILD_ROOT/etc/depmod.d/drbd.conf
%endif

+# Somehow depmod gets run and the files it produces are not in any
+# packages so rpmbuild fails to produce the desired rpm.
+# Remove the output of depmod
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.alias
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.alias.bin
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.dep
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.dep.bin
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.devname
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.softdep
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.symbols
+rm $RPM_BUILD_ROOT/lib/modules/%{kernel_version}.%{_target_cpu}/modules.symbols.bin
+
+%files
+%defattr(-,root,root)
+/etc/depmod.d/drbd.conf
+/lib/modules/%{kernel_version}.%{_target_cpu}/extra/drbd/drbd.ko
+
%clean
rm -rf %{buildroot}


6. Build and install the RPMs



cd ~/rpmbuild/SPECS
rpmbuild -ba drbd.spec
rpmbuild -ba drbd-kernel.spec
cd ../RPMS/x86_64
yum install heartbeat pacemaker xen
rpm -i drdb*


7. Cry about the fact that depmod doesn't find the 8.4.2 version of drbd.ko but it's easy to work around by using insmod instead of modprobe.


insmod /lib/modules/3.6.7-4.fc17.x86_64/extra/drbd/drbd.ko

PabloTwo
1st December 2012, 10:07 PM
If you install the rpmdevtools package, this:

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
can be replaced with this (just be in your user home top directory):

rpmdev-setuptree

nutznboltz
2nd December 2012, 01:06 AM
@PabloTwo Thanks!

drbd-kernel.spec is trying to rely on %kernel_module_package but either it is calling it wrong or there are (more) bugs in /usr/lib/rpm/redhat/* (or both.)

rackerhacker
23rd March 2013, 06:49 PM
I'm the package maintainer for DRBD in Fedora and I've just pushed drbd 8.4.2 for Fedora 17 since I had a bugzilla ticket for it. The package is in testing now if you'd rather use that than compile from source.

https://admin.fedoraproject.org/updates/drbd

nutznboltz
24th March 2013, 01:28 PM
@rackerhacker Thanks.

I have moved on to Fedora 18 since starting this thread.

I needed a test lab for configuring RHEL6 multipathing so I threw together
http://sourceforge.net/apps/mediawiki/scst/index.php?title=SCST,_DRBD_and_Dual_Primary_Mode

The lab all been repurposed and the production environment has been configured dual-pathing against an iSCSI appliance.

It was way faster and cheaper than getting a test appliance.