Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In https://github.com/facebook/flashcache/ there is a saying

make KERNEL_TREE=<root of the kernel source tree>

This builds both the flashcache.ko and 3 utilities.

flascache-sa-guide.txt has details on how to create and load flashcache volumes.

Mohan Srinivasan Paul Saab

What should I wrote to replace ?

share|improve this question
up vote 3 down vote accepted


Reference: Tutorial Link

Quick quote from tutorial:

Step 1: As normal user

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

Step 2: As root

[root@host]# yum install rpm-build redhat-rpm-config asciidoc hmaccalc
[root@host]# yum install binutils-devel elfutils-libelf-devel newt-devel zlib-devel

Step 3: As normal user

[user@host]$ rpm -i http://vault.centos.org/6.3/updates/Source/SPackages/kernel-2.6.32-279.19.1.el6.src.rpm 2>&1 | grep -v mock

kernel source tree: /home/user/rpmbuild/BUILD/kernel*/linux*/ <-- cd into it to confirm those '*'.


make KERNEL_TREE=<put in the full path above>


<root of the kernel source tree> is where the kernel source is.

On Ubuntut/Debain, download kernel source

apt-get install linux-source-3.2.0

That will put the kernel source tree in


However the actual source tree need to be de-compressed

# cd /usr/src/linux-source-3.2.0
# ls -lh
total 77M
drwxr-xr-x 10 root root 4.0K Jan 24 22:40 debian
drwxr-xr-x  8 root root 4.0K Jan 24 22:40 debian.master
-rw-r--r--  1 root root  77M Jan  8 17:46 linux-source-3.2.0.tar.bz2

# tar xf linux-source-3.2.0.tar.bz2
# ls -lh
total 77M
drwxr-xr-x 10 root root 4.0K Jan 24 22:40 debian
drwxr-xr-x  8 root root 4.0K Jan 24 22:40 debian.master
drwxrwxr-x 24 root root 4.0K Jan  8 17:45 linux-source-3.2.0
-rw-r--r--  1 root root  77M Jan  8 17:46 linux-source-3.2.0.tar.bz2

The source tree is /usr/src/linux-source-3.2.0/linux-source-3.2.0


make KERNEL_TREE=/usr/src/linux-source-3.2.0/linux-source-3.2.0
share|improve this answer
How should I know my kernel_source tree? – Jim Thio Jan 25 '13 at 3:56
I used centos how do I know where the kernel source is? – Jim Thio Jan 25 '13 at 3:57
What is the output of uname -a? – John Siu Jan 25 '13 at 3:58
root@host [/]# uname -a Linux host.hostgreatsite.com 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux – Jim Thio Jan 25 '13 at 4:01
ok, that look like standard kernel, wait. – John Siu Jan 25 '13 at 4:04

The Red Hat, CentOS, and Fedora systems have the kernel-devel package, containing the machinery required to build modules against the kernel (not the full source, mind you). The source's root is then at /usr/src/kernels/<version>.

share|improve this answer

To compile extra kernel modules, you usually need to install the package with the header files for your kernel called

  • kernel-devel on RedHat-based distros (Fedora,CentOS,...)
  • linux-headers-$(uname -r) on Debian-based distros (Ubuntu, ...).

In /lib/modules/$(uname -r)/, there should be then a symlink build which should point to the right directory.

So install the kernel header package and then use

make KERNEL_TREE=/lib/modules/$(uname -r)/build
share|improve this answer
This is good advice for 99% of kernel modules. Note that flashcache is in that other 1% - building it requires the full source tree. – Ian Mar 12 '14 at 4:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.