#!/bin/bash
#
# @(#)$Id: kernel-compile.sh,v 0.1 2014/11/01 $
#
# Compile and Install Linux Kernel on Centos 6
# - This should be run as \'root\' (not sudo)
# - This should be run immediately after the OS install
# - You should verify wget URLs work before running
# - Read the comments below about \'make menuconfig\'
#
# Script Variables were tested and work with:
# CentOS 6.5 x86_64 (Minimal)
# Linux 2.6.36.4
# unionfs 2.6_for_2.6.36.4
#
# Patch Notes:
# For UnionFS in Linux 2.6.36.4:
# http://www.fsl.cs.sunysb.edu/pipermail/unionfs/attachments/20101027/fdb6761a/attachment.bin
KERNEL_SOURCE="www.kernel.org/pub/linux/kernel/v2.6"
LINUX_KERNEL="2.6.36.4"
UNION_FS_URL="download.filesystems.org/unionfs/unionfs-2.x-latest"
UNION_FS="unionfs-2.6_for_2.6.36.4"
# Install dependency packages and update. ~50MB Download
yum install -y gcc ncurses ncurses-devel wget perl bc patch
# Download the Kernel 3.17 Source ~116MB Download
cd /tmp
wget http://$KERNEL_SOURCE/linux-$LINUX_KERNEL.tar.gz
# Extract
tar -C /usr/src -xvf linux-$LINUX_KERNEL.tar.gz
# Integration unionfs ~1MB
wget http://$UNION_FS_URL/$UNION_FS.diff.gz
gzip -d $UNION_FS.diff.gz
mv $UNION_FS.diff /usr/src/linux-$LINUX_KERNEL/
cd /usr/src/linux-$LINUX_KERNEL/
patch -p1 < $UNION_FS.diff
wget http://www.fsl.cs.sunysb.edu/pipermail/unionfs/attachments/20101027/fdb6761a/attachment.bin
patch -p1 < attachment.bin
# Run the make menuconfig command to configure the Linux kernel.
# Once you execute the below command a pop up window appears with
# all the menus. Here you can select your new kernel configuration.
# Enable UnionFS:
# Filesystems -> Miscellaneous -> unionfs [*] (Press Spacebar twice)
# -> unionfs (extended attributes) [*]
# Exit -> Exit -> Exit -> Exit -> Save
make menuconfig
# "Compire der Kerner!!!"
make -j 4
make modules_install install
# Update Grub and disable kernel updates
echo exclude=kernel* >> /etc/yum.conf
sed -i \'s/default=1/default=0/g\' /boot/grub/grub.conf