How to compile a linux kernel with grsec and custom kernel configuration on Arch Linux
- Download the latest sources via the Arch Built System tool
sudo abs community/linux-grsec
The default abs directory is
/var/abs/, so the linux-grsec build files will be located in
I build kernel things in my home directory, so I change to that directory:
- Copy the abs directory to the current working directory:
cp -R /var/abs/community/linux-grsec/ . cd linux-grsec/
PKGBUILDfile with your favourite editor.
- Scroll down to the section
#load configurationand uncomment your favourite config tool. I like
Save the file and exit your editor.
Rename the .install file to match the name specified in
mv linux-grsec.install linux-grsec-custom.install
- Start the
MAKEFLAGS="-j$(nproc)" makepkg -s
-j flag specifies the number of jobs to be run simultaneously my
We set it to
$(nproc) - the number of processor cores on our machine.
Using multiple cores speeds up the compilation considerably.
makepkg has downloaded the kernel sources and patches,
you will see the kernel configuration menu pop up in your terminal.
Now you can either find and set kernel options by yourself (view a
list of grsec config options here), or provide an existing config file.
For example, use the following command to write your current .config to a file:
sudo zcat /proc/config.gz > current.config
(You may need to move the file into the
src/linux-*/ subdirectory so your config editor can find it.)
- When you're done setting kernel options, exit the configuration menu and watch the kernel compile. That's going to take a while.
Once compilation is finished, you will find that
makepkg has written 3 files to your current directory:
linux-grsec-custom-*.pkg.tar linux-grsec-custom-docs-*.pkg.tar linux-grsec-custom-headers-*.pkg.tar
- Install them with
sudo pacman -U linux-grsec-custom-*.pkg.tarand you're done!