Building a custom kernel

From unRAID
Jump to: navigation, search




This page was created for unRAID v5 (32 bit), has NOT been updated for v6!!! If you wish to adapt it, you would need a current kernel to match your chosen unRAID release, 64 bit packages from Slackware 14.1 (I think!), and who knows what else!




There are times when you want to compile a custom kernel to add drivers or features not available in the unRAID environment. For example, CPU optimization, speed/frequency control, power control, network and/or disk controllers.

The following is a brief overview of the process. Previously it was suggested that you build a complete slackware build system to compile the kernel but it's easy enough to just compile a new kernel on your running unRAID instance.

This guide assumes you've downloaded the below packages and the unRAID zip file from the lime-technology website, to a packages directory on your USB stick (eg. when logged into your unRAID instance, the packages would be in /boot/packages.

Packages you will need are:

  • bc
  • binutils
  • gcc
  • glibc
  • infozip
  • kernel-headers
  • make
  • ncurses
  • perl

You can find a list of all packages, and download them, from http://packages.slackware.com/. For unRAID 5.0.5, use the Slackware 13.1 (non 64-bit) packages. Also check the patches directory for packages updated after the original release.

You will also need the unRAID zip file for the version of unRAID that you are using.

Get the kernel source for the version of unRAID you are running

Use uname command to find out what version of the linux kernel you are running, then download source from www.kernel.org - (Link to 3.x kernel sources)

(Replace 3.9.11 below with whatever version of the linux kernal that uname displays

uname -a
mkdir /boot/packages
cd /boot/packages
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.9.11.tar.gz

(xz is a smaller download than gzip or bzip2 compressed files)

  • extract tar and create a symbolic link
tar -C /usr/src/ -zxvf /boot/packages/linux-3.9.11.tar.gz
ln -sf /usr/src/linux-3.9.11 /usr/src/linux

Add unRAID mods to kernel source

installpkg /boot/packages/infozip-6.0-i486-1.txz
mkdir /mnt/dev
unzip /boot/packages/unRAIDServer-5.0.5-i386.zip -d /mnt/dev/
cp -rf /usr/src/linux-3.9.11p-unRAID/* /usr/src/linux/
cp -f /usr/src/linux-3.9.11p-unRAID/.config /usr/src/linux/

#Install kernel headers
installpkg /boot/packages/kernel-headers-2.6.33.4_smp-x86-1.txz

#Run make menuconfig after installing dependent packages
installpkg /boot/packages/make-3.81-i486-1.txz
installpkg /boot/packages/gcc-4.4.4-i486-1.txz
installpkg /boot/packages/glibc-2.11.1-i486-8_slack13.1.txz
installpkg /boot/packages/binutils-2.20.51.0.8-i486-1.txz
installpkg /boot/packages/ncurses-5.7-i486-1.txz

cd /usr/src/linux
make clean
make menuconfig

Include packages and any other kernel changes

I have onboard Realtek Gigabit Ethernet which isn't enabled in the default .config file supplied in the 5.0.5 kernel, so I've had to manually enable that whenever I re-compile the kernel. I've also enabled things like DVB_USB_V2 so that my unRAID box can record Digital TV, but for things like that you may also need to source your hardware's firmware and add that to /lib/firmware prior to the final generation of a bzroot file...

Build new bzimage, kernel and modules

installpkg /boot/packages/perl-5.10.1-i486-2_slack13.1.txz
installpkg /boot/packages/bc-1.06.95-i486-1.txz

make bzImage
make
make modules
make modules_install

Create new bzroot and copy both bzimage and bzroot to USB flash

mkdir /mnt/dev/bz-mod
cd /mnt/dev/bz-mod
installpkg /boot/packages/cpio-2.9-i486-2.txz
xzcat ../bzroot | cpio -m -i -d -H newc --no-absolute-filenames
rsync -av --delete /lib/modules/3.9.11p-unRAID/ lib/modules/3.9.11p-unRAID/

#Here's where I add firmware for my hardware
cp /boot/packages/dvb-usb-af9015.fw lib/firmware/

find . | cpio -o -H newc | xz --check=crc32 --x86 --lzma2=preset=9e > /boot/bzroot_new
#Copy bzimage_new
cp arch/x86/boot/bzImage /boot/bzimage_new

Lastly, you might like to update the syslinux.cfg file on your flash drive to either have the default option use these new bzimage_new and bzroot_new files, or create a new menu option and leave the existing one as is.


Links to related information