Kernel Rebuild

HowTo rebuild Kernel for Raspberri-Pi
to add aufs support

aufs description:
this guide can be used to rebuild raspberry-pi kernel to add any module to base rpi kernel.
Official Raspberry-Pi kernel repository:
Official Raspberry-Pi firmware repository:
Starting from i have use Linux Mint 13, we crosscompilie the kernel to add aufs support to our RPI
prerequisite: Linux Ubuntu or Mint or whatever you want with an sdcard reader, a bit of shell knowledge.

start installing compiler:
sudo apt-get install gcc-4.6-arm-linux-gnueabi
in some system you need also to link gcc-4.6 to gcc:
sudo ln -s  /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-gcc
now clone the Raspberry-Pi kernel source in local disk:
cd /home/gibbio/
sudo git clone
it’s take a while...
after finish we apply the aufs patch to our kernel source as described in aufs manual:
cd linux
git clone git://
cd aufs3-standalone
git checkout origin/aufs3.1 (checkout for kernel 3.1, when RPI team switch to 3.2 we have to change it!)
cp -rp *.patch ../
cp -rp fs ../
cp -rp Documentation/ ../
cp -rp include/ ../
cd ..
patch -p1 < aufs3-kbuild.patch
patch -p1 < aufs3-base.patch
patch -p1 < aufs3-proc_map.patch
patch -p1 < aufs3-standalone.patch

Now we have a full kernel source patched by RaspberryPi team and added aufs, now we have to modify the kernel configuration, we do it by using the menuconfig. For first we need ncurses installed on our linux:
sudo apt-get install ncurses
then run menuconfig:
cp arch/arm/configs/bcmrpi_cutdown_defconfig .config (we have to copy the default config made by RPI team)
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
now browse the menu and add as a module aufs (screenshot needed!)
exit menuconfig and save the new configuration. Now compile the kernel:
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j 3 ( If you have a dual core machine you can use "-j 3", for a quad core machine you can use "-j 6", and so on. )
After finish we have to build the modules:
mkdir /tmp/modules
make ARCH=arm modules_install INSTALL_MOD_PATH=/tmp/modules

now put your SDCard on pc, you will find 2 new partition, for example:
gibbio # fdisk -l
       Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1      100351       50175+   c  W95 FAT32 (LBA)
/dev/mmcblk0p2          100352    15642367     7771008   83  Linux
/dev/mmcblk0p1 is the partition thats contain the kernel.img, firmware, elf etc
/dev/mmcblk0p2 is the partition thats contain the debian linux for raspberry
When you put the sdcard on the pc linux automatically mount this 2 partition, in my case /dev/mmcblk0p1 is mounted on /media/E707-D055/ and /dev/mmcblk0p2 is mounted on /media/d6bc000a-5b5e-494e-bc87-4f0fe1854ab2/

Now we update with our new kernel and new modules our RPI:
mv /media/E707-D055/kernel.img /media/E707-D055/kernel_old.img
cp arch/arm/boot/Image /media/E707-D055/kernel.img
cp -r /tmp/modules/lib/ /media/d6bc000a-5b5e-494e-bc87-4f0fe1854ab2/
rm /media/d6bc000a-5b5e-494e-bc87-4f0fe1854ab2/lib/modules/3.1.9+/build
rm /media/d6bc000a-5b5e-494e-bc87-4f0fe1854ab2/lib/modules/3.1.9+/source
umount /media/d6bc000a-5b5e-494e-bc87-4f0fe1854ab2/

Now we can update *start.elf, bootcode.bin and loader.bin (GPU firmware and bootloaders):
cd /home/gibbio/
git clone
cp firmware/boot/arm224_start.elf /media/E707-D055/start.elf (used 224 version for 224Mb of RAM)
cp firmware/boot/bootcode.bin /media/E707-D055/
cp firmware/boot/loader.bin /media/E707-D055/
umount /media/E707-D055/

unplug the sdcard from the pc and plug into RPI
Power on the RPI!


  1. Hey ! :)

    I have problem, when patching kernel version 3.2, the result: (i get aufs3.2 also)
    patch -p1 < aufs3-kbuild.patch
    patching file fs/Kconfig
    patching file fs/Makefile
    patching file include/linux/Kbuild
    Hunk #1 FAILED at 65.
    1 out of 1 hunk FAILED -- saving rejects to file include/linux/Kbuild.rej

    Do you have meybe any clue how to get on with it ?

    1. The copy command for the "include" is too broad and overwrites some files.

      cp -rp include/ ../
      cp include/linux/aufs_type.h ../include/linux/

  2. where is possible find screenshot for menuconfig?


Note: Only a member of this blog may post a comment.