Skip to content

Instantly share code, notes, and snippets.

@HugoGuiroux
Last active October 26, 2016 11:05
Show Gist options
  • Select an option

  • Save HugoGuiroux/095dfc0285a614bd794d to your computer and use it in GitHub Desktop.

Select an option

Save HugoGuiroux/095dfc0285a614bd794d to your computer and use it in GitHub Desktop.
Building kernel
#!/bin/bash
# Script to build a kernel
# Author: Hugo Guiroux <hugo.guiroux@gmail.com>
# Version from command line. Ex: 4.4
VERSION="$1"
echo "Installing dependencies"
apt-get install -y git-core kernel-package fakeroot build-essential libncurses5-dev python-pip wget xz-utils
echo "Downloading $VERSION kernel"
wget --continue http://kernel.org/pub/linux/kernel/v4.x/linux-$VERSION.tar.xz
echo "Uncompressing & cleaning"
tar -xvf linux-$VERSION.tar.xz
cd linux-$VERSION
make distclean
make mrproper
echo "Copying and modifying config"
cp /boot/config-$(uname -r) .config
make olddefconfig
J=$(grep processor /proc/cpuinfo | wc -l)
echo "Building packages with $J tasks"
make-kpkg clean
# Need sudo, see https://bugs.launchpad.net/ubuntu/+source/kernel-package/+bug/1308183
sudo fakeroot make-kpkg -j$J --initrd kernel_image kernel_headers kernel_debug kernel_source
echo "To install packages, run sudo dpkg -i ../linux-*-$VERSION.deb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment