Thursday, December 19, 2013

Build Linux kernel from source

A note for building Linux kernel from source under Archlinux

# fetch the kernel source code and extract it
tar Jxvf linux-3.12.5.tar.xz
cd linux-3.12.5/
# prepare for the compilation, this will delete all current configuration and all generated files
make mrproper
# copy the config from the running system
zcat /proc/config > .config
# configure your customized kernel
make menuconfig
# Go to play some games
# n for num of your process, e.g. make -j 8
make -j n
# install modules under /lib/modules/
sudo make modules_install
# prepare the new kernel under /boot/
sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-KernelName
sudo mkinitcpio -k /boot/vmlinuz-KernelName -c /etc/mkinitcpio.conf -g /boot/initramfs-KernelName.img
sudo cp /boot/
# update grub configuration
sudo grub-mkconfig -o /boot/grub/grub.cfg