Another simple way to cut the kernel sources down to size

Adam McKee (
Mon, 01 Jul 1996 11:38:42 -0600 (CST)

As the kernel sources have become rather large, there has been an interest
in ways for the end-user to trim the kernel sources down. Recently, I saw
a script that prunes the source tree based on the contents of .config and
on user input. The script I present is even simpler than that, and I
expect some users may want to use a combination of these two simple
techniques to gain a nice savings in disk space (yes, disk space is cheap,
but that is no argument for throwing away money). The ideal is probably a
diced kernel [ no flames, please! ], but if Linus and the others aren't
interested in doing that, I say:

a) It's not a big deal anyway, and
b) Linux users are (generally) not dummies, and can do this kind
of thing themselves.

#! /bin/sh

# ksrc_gzip v1.0 by Adam McKee <>
# This is a quick-and-dirty shell script to save some disk space by compressing
# the kernel sources. The directories/files needed for development are left
# intact. This script takes no arguments -- it knows what you want it to do
# based on whether or not the kernel sources are compressed.
# - /usr/src/linux -> /usr/src/linux-${VERSION}
# i.e. /usr/src/linux -> /usr/src/linux-2.0.0
# - /usr/src/linux/include/asm -> /usr/src/linux/include/asm-${ARCH}
# i.e. /usr/src/linux/include/asm -> /usr/src/linux/include/asm-i386
# - The script is run with uid=euid=root, gid=egid=root.
# If any of these assumptions are invalid, make them valid before running the
# script :)

V=`ls -l /usr/src/linux` ; V=${V#* -> *-}

umask 022
if [ -f $ZIP ]; then
pushd / > /dev/null
rm -rf $SRC
tar xzf $ZIP
rm -f $ZIP
popd > /dev/null
tar czf $ZIP $SRC
mv $SRC $TMP
mkdir $SRC
mkdir ${SRC}/include
cp -Rp ${TMP}/include/asm ${SRC}/include
cp -Rdp ${TMP}/include/linux ${SRC}/include
rm -rf $TMP