1

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 ?

3 Answers 3

3

CentOS

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 '*'.

So

make KERNEL_TREE=<put in the full path above>

Debian

<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

/usr/src/linux-source-3.2.0

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

So

make KERNEL_TREE=/usr/src/linux-source-3.2.0/linux-source-3.2.0
6
  • How should I know my kernel_source tree?
    – user4951
    Jan 25, 2013 at 3:56
  • I used centos how do I know where the kernel source is?
    – user4951
    Jan 25, 2013 at 3:57
  • What is the output of uname -a?
    – John Siu
    Jan 25, 2013 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
    – user4951
    Jan 25, 2013 at 4:01
  • ok, that look like standard kernel, wait.
    – John Siu
    Jan 25, 2013 at 4:04
2

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>.

2

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
1
  • This is good advice for 99% of kernel modules. Note that flashcache is in that other 1% - building it requires the full source tree.
    – Thaeli
    Mar 12, 2014 at 4:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .