Created
August 18, 2018 12:16
-
-
Save patrickshan/732a34129c7928200717dc0561535d2f to your computer and use it in GitHub Desktop.
Use ramdisk to build latest kernel deb package for debian
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $EUID -ne 0 ]] | |
then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
if [[ $# -ne 1 ]] | |
then | |
echo "need to specify kernel version" | |
exit 1 | |
fi | |
version=$1 | |
VersionSeries=$(echo ${version} | cut -d. -f1) | |
# Download | |
url=https://cdn.kernel.org/pub/linux/kernel/v${VersionSeries}.x/linux-${version}.tar.xz | |
wget -S --spider ${url} 2>&1 | grep -q 'HTTP/1.1 200 OK' | |
if [[ $? == "1" ]] | |
then | |
echo "Could not find kernel with url: ${url}" | |
exit 1 | |
fi | |
mkdir -p /tmp/ramdisk | |
# use 5GB ram as ramdisk | |
# building 4.18 kernel uses around 3.2GB | |
sudo mount -t tmpfs -o size=5G tmpfs /tmp/ramdisk | |
wget -O /tmp/ramdisk/linux-${version}.tar.xz ${url} | |
pushd /tmp/ramdisk | |
tar xf linux-${version}.tar.xz | |
cd linux-${version} | |
cp /boot/config-$(uname -r) ./.config | |
time make deb-pkg -j7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment