Browse files

Updated to support building (using DKMS!) on RHEL/CentOS 5.

  • Loading branch information...
Graeme Humphries
Graeme Humphries committed Sep 20, 2011
1 parent e6c43fc commit d6e4d6586e1d289d270315daaf54f04b9ee30ec4
Showing with 57 additions and 71 deletions.
  1. +7 −1 Makefile
  2. +1 −1 Makefile.dkms
  3. +16 −0 README-CentOS5
  4. +0 −58 README-CentOS5.4
  5. +12 −9 README-DKMS
  6. +21 −2 src/Makefile
@@ -1,8 +1,14 @@
COMMIT_REV := $(shell git describe --always --abbrev=12)
KERNEL_TREE ?= /lib/modules/$(shell uname -r)/build
+# Check for RHEL/CentOS
+RHEL5_VER ?= $(shell grep 5.[0-9] /etc/redhat-release)
+ifneq "$(RHEL5_VER)" ""
+ RHEL5_TREE := /usr/src/redhat/BUILD/kernel-2.6.18/linux-$(shell uname -r).$(shell uname -i)
$(MAKE) -C src KERNEL_TREE=$(KERNEL_TREE) PWD=$(shell pwd)/src all
@@ -10,7 +10,7 @@ UTILS := /sbin/flashcache_load /sbin/flashcache_create /sbin/flashcache_destroy
all: install
.PHONY: install
-install: build $(UTILS)
+install: build utils
dkms install -m flashcache -v $(COMMIT_REV)
.PHONY: build
@@ -0,0 +1,16 @@
+Vadim T (Percona) wrote an initial guide on getting flashcache building on CentOS, which was extremely helpful.
+Based on that, I've modified the Makefiles to make building on CentOS as easy as possible. Here's the steps you'll
+need to follow to build on CentOS:
+ - Make sure you have the CentOS EPEL repo. (
+ - Make sure you have the CentOS source repo. ($releasever/updates/SRPMS/)
+ - Install prerequisite build packages:
+ yum install dkms gcc make yum-utils kernel-devel
+ - CentOS kernel-headers/devel packages don't include internal headers, we've got to configure the full source:
+ yumdownloader --source kernel-`uname -r`
+ sudo rpm -ivh kernel-`uname -r`.src.rpm
+Now the updated Makefiles should work correctly.
+Graeme Humphries <>
@@ -1,58 +0,0 @@
-Vadim T (Percona) wrote this doc on building Flashcache for CentOS5.4.
-It took some efforts for make binary on plain CentOS 5.4 with kernel
-so I want to share my notes (If you do not mind I'd like to add it to
-INSTALL.CentOS54 or like that)
-CentOS 5.4 x86_64
-base document is:
-1. we need to get full source code of kernel.
-* as root:
-yum install rpm-build redhat-rpm-config unifdef
-As an ordinary user, not root, create a directory tree based on ~/
-[user@host]$ cd
-[user@host]$ mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-[user@host]$ echo '%_topdir %(echo $HOME)/rpmbuild' > .rpmmacros
-* install kernel src.rpm
-rpm -i
-2>&1 | grep -v mockb
-cd ~/rpmbuild/SPECS
-rpmbuild -bp --target=`uname -m` kernel-2.6.spec 2> prep-err.log | tee prep-out.log
-The kernel source tree will now be found in the directory ~/rpmbuild/
-next commands to prepare kernel:
-cd ~/rpmbuild/BUILD/kernel-2.6.18/linux-2.6.18.x86_64
-make oldconfig
-make prepare
-make modules_prepare
-Now kernel source code which can be used to build flashcache is there:
-to build flashcache you use:
-make KERNEL_TREE=/home/vadim/rpmbuild/BUILD/kernel-2.6.18/
-but you also need to make next changes to
-file: src/Makefile
-replace EXTRA_CFLAGS line by:
-EXTRA_CFLAGS=-I$(KERNEL_TREE)/drivers/md -I$(KERNEL_TREE)/include/
-linux -I./
@@ -8,21 +8,25 @@
I've added some simple DKMS configs for flashcache to make building and managing it a little less painful.
This has been updated with a Makefile.dkms, which should hopefully do a sensible DKMS install without
-intervention. It's only been tested on Ubuntu 11.04, and right now requires initramfs-tools for boot support,
-so it probably won't work on CentOS 5 just yet. I plan to test and update things for CentOS 5 and 6
-in the near future.
+intervention. Right now requires initramfs-tools for boot support, so it probably won't work on CentOS 5
+just yet.
+Ubuntu (and probably Debian):
+ - Install prerequisite build packages:
+ apt-get install dkms build-essential linux-headers-`uname -r`
+CentOS/RHEL 5:
+ - Follow the steps in README-CentOS5 to prep for building on CentOS.
Run "make -f Makefile.dkms", and it should build and install correctly for your kernel.
Boot from Flashcache
If you have initramfs-tools, then flashcache utils and modules can be installed into the initramfs.
- - Install flashcache modules and utilities using instructions from "Installation" section above.
+ - Follow Installation section above.
- Install flashcache boot support:
make -f Makefile.dkms boot_conf
- Edit your /etc/fstab and /boot/grub/grub.cfg to change the root device to the flashcache device you intend to use.
@@ -35,11 +39,10 @@ Ubuntu:
flashcache_create -p back fc-root /dev/ssd_device /dev/disk/by-uuid/root_device_uuid
- Reboot!
- - Instructions forthcoming once I've tested it. ;)
Known Issues:
- Right now grub-probe fails to detect the underlying root device when booting off flashcache,
so you'll have to edit /boot/grub/grub.cfg manually.
+ - Because of previous point, update-grub will likely fail.
Graeme Humphries <>
@@ -5,14 +5,25 @@ KERNEL_TREE ?= /lib/modules/$(KERNEL_SOURCE_VERSION)/build
EXTRA_CFLAGS += -I$(KERNEL_TREE)/include/ -I$(KERNEL_TREE)/include/linux
+# Check for RHEL/CentOS
+RHEL5_VER ?= $(shell grep 5.[0-9] /etc/redhat-release)
+ifneq "$(RHEL5_VER)" ""
+ RHEL5_SETUP := rhel5-setup
+ RHEL5_SPEC := /usr/src/redhat/SPECS/kernel.spec
+ RHEL5_TREE := /usr/src/redhat/BUILD/kernel-2.6.18/linux-$(shell uname -r).$(shell uname -i)
+ RHEL5_SRC := /usr/src/kernels/$(shell uname -r)-$(shell uname -i)
obj-m += flashcache.o
flashcache-objs := flashcache_conf.o flashcache_main.o flashcache_subr.o flashcache_ioctl.o flashcache_procfs.o
.PHONY: all
all: modules utils
.PHONY: modules
+modules: $(RHEL5_SETUP)
make -C $(KERNEL_TREE) M=$(PWD) modules V=0
.PHONY: utils
@@ -33,7 +44,15 @@ utils_install: utils
install: modules_install utils_install
.PHONY: clean
make -C $(KERNEL_TREE) M=$(PWD) clean
make -C utils clean
+.PHONY: rhel5-setup
+rhel5-setup: $(RHEL5_TREE)
+ make -C $(RHEL5_TREE) oldconfig ; \
+ make -C $(RHEL5_TREE) prepare modules_prepare
+ ln -s -f $(RHEL5_SRC)/Module.symvers $(RHEL5_TREE)/Module.symvers
+ rpmbuild -bp --target=`uname -m` $(RHEL5_SPEC) 2>&1 | tee `dirname $(RHEL5_SPEC)`/prep.log

0 comments on commit d6e4d65

Please sign in to comment.