![]() | 1 | initial version |
How do I compile custom kernels
sudo dnf install bison bison-devel ccache gcc gcc-c++ lz4 openssl-devel patch qt4-devel
makedir -p ~/DATA/devel/CCACHE;
compose a custom defconfig via make xconfig && make savedefconfig
copy it to ~/DATA/devel/
run the following bash script as user (!) to compile a custom kernel:
MY_JOBS=-j8; CCACHE_DIR=~/DATA/devel/CCACHE; export CCACHE_DIR;
NEW_SRC=linux-.xz; OLD_SRC=$(find . -type d -name 'linux-');
if [ -e linux-.xz ] then [ -s ${OLD_SRC} ] && rm -rf ${OLD_SRC}; echo -e "\n unpacking src, wait...\n" tar -Jxf ${NEW_SRC} && mv ${NEW_SRC} ./SRC; OLD_SRC=$(find . -type d -name 'linux-') ccache -cz; fi;
[ -z ${OLD_SRC} ] && echo -e "\n\n damn NO source OR working Linux Tree !!! \n\n" && exit 13;
[ -s defconfig ] && [ ! -e defconfig.OLD ] && cp defconfig defconfig.OLD;
cd ./linux-*;
echo -e "\n cleaning tree ...\n"
[ -e vmlinux.o ] && make clean mrproper;
[ -e defconfig ] && rm -rf ./defconfig;
echo -e "\n building kernel ...\n"
[ -s ../defconfig ] && make KCONFIG_ALLCONFIG=../defconfig alldefconfig;
make xconfig && make savedefconfig && cp defconfig ../ && make all ${MY_JOBS};
RC=$?
[ "$RC" -gt 0 ] && echo -e "\n error in make\n" && exit 13;
echo -e "\n installing kernel ...\n"
sudo make modules_install && sudo make install && sudo rm -rf /boot/{System.map,vmlinuz,*.old} && sudo grub2-mkconfig -o /boot/grub2/grub.cfg; # && sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg;
sync && sync && sync;
exit 0;
my script is NOT completely bug free, there some point I could do better ..., but it runs !!!
What it does (in short): - looks for a new linux-.tar.xz - unpacks it and saves linux-.tar.xz for later use - cleans the tree - generate a new defconfig and save the new one for later use - makes kernel and modules (as user) - installs teh new kernel (as root) - adjusts grub.cfg
![]() | 2 | No.2 Revision |
How do I compile custom kernels
PREMISE (do only once)
sudo dnf install bison bison-devel ccache gcc gcc-c++ lz4 openssl-devel patch qt4-devel
makedir -p ~/DATA/devel/CCACHE;
makedir -p ~/DATA/devel/SRC;
compose a custom defconfig via make xconfig && make savedefconfig
copy it this defconfig to ~/DATA/devel/
COMPILE a new custom kernel (do for each new kernels)
run the following bash script as user (!) to compile a custom kernel:
(!)
#!/bin/bash
MY_JOBS=-j8;
CCACHE_DIR=~/DATA/devel/CCACHE;
export CCACHE_DIR; NEW_SRC=linux-.xz;
CCACHE_DIR;
NEW_SRC=linux-*.xz;
OLD_SRC=$(find . -type d -name 'linux-'); 'linux-*');
if [ -e linux-.xz linux-*.xz ]
then
[ -s ${OLD_SRC} ] && rm -rf ${OLD_SRC};
echo -e "\n unpacking src, wait...\n"
tar -Jxf ${NEW_SRC} && mv ${NEW_SRC} ./SRC;
OLD_SRC=$(find . -type d -name 'linux-')
'linux-*')
ccache -cz;
fi; fi;
[ -z ${OLD_SRC} ] && echo -e "\n\n damn NO source OR working Linux Tree !!! \n\n" && exit 13; 13;
[ -s defconfig ] && [ ! -e defconfig.OLD ] && cp defconfig defconfig.OLD; defconfig.OLD;
cd ./linux-*;
echo -e "\n cleaning tree ...\n"
[ -e vmlinux.o ] && make clean mrproper;
[ -e defconfig ] && rm -rf ./defconfig;
echo -e "\n building kernel ...\n"
[ -s ../defconfig ] && make KCONFIG_ALLCONFIG=../defconfig alldefconfig;
make xconfig && make savedefconfig && cp defconfig ../ && make all ${MY_JOBS};
RC=$?
[ "$RC" -gt 0 ] && echo -e "\n error in make\n" && exit 13;
echo -e "\n installing kernel ...\n"
sudo make modules_install && sudo make install && sudo rm -rf /boot/{System.map,vmlinuz,*.old} && sudo grub2-mkconfig -o /boot/grub2/grub.cfg; # /boot/grub2/grub.cfg && sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg;
sync && sync && sync;
exit 0;
sync && sync && sync;
exit 0;
my script is NOT completely bug free, there some point points I could do better ..., but it runs !!! !!!
What it does (in short):
short):
- looks for a new linux-.tar.xz
linux-*.tar.xz (fetched from kernel.org)
- unpacks it and saves linux-.tar.xz linux-*.tar.xz for later use
- cleans the tree
tree (removes gruft from previous run)
- generate a new defconfig and save saves old one and the new one for later use
- makes kernel and modules (as (runs as user)
- installs teh the new kernel (as (runs as root)
- adjusts grub.cfg grub.cfg (runs as root)
![]() | 3 | No.3 Revision |
How do I compile custom kernels
PREMISE (do only once)
sudo dnf install bison bison-devel ccache gcc gcc-c++ lz4 openssl-devel patch qt4-devel
makedir -p ~/DATA/devel/CCACHE;
makedir -p ~/DATA/devel/SRC;
compose a custom defconfig via make xconfig && make savedefconfig
copy this defconfig to ~/DATA/devel/
COMPILE a new custom kernel (do for each new kernels)
run the following bash script as user (!)
#!/bin/bash
MY_JOBS=-j8;
CCACHE_DIR=~/DATA/devel/CCACHE;
export CCACHE_DIR;
NEW_SRC=linux-*.xz;
OLD_SRC=$(find . -type d -name 'linux-*');
if [ -e linux-*.xz ]
then
[ -s ${OLD_SRC} ] && rm -rf ${OLD_SRC};
echo -e "\n unpacking src, wait...\n"
tar -Jxf ${NEW_SRC} && mv ${NEW_SRC} ./SRC;
OLD_SRC=$(find . -type d -name 'linux-*')
ccache -cz;
fi;
[ -z ${OLD_SRC} ] && echo -e "\n\n damn NO source OR working Linux Tree !!! \n\n" && exit 13;
[ -s defconfig ] && [ ! -e defconfig.OLD ] && cp defconfig defconfig.OLD;
cd ./linux-*;
echo -e "\n cleaning tree ...\n"
[ -e vmlinux.o ] && make clean mrproper;
[ -e defconfig ] && rm -rf ./defconfig;
echo -e "\n building kernel ...\n"
[ -s ../defconfig ] && make KCONFIG_ALLCONFIG=../defconfig alldefconfig;
make xconfig && make savedefconfig && cp defconfig ../ && make all ${MY_JOBS};
RC=$?
[ "$RC" -gt 0 ] && echo -e "\n error in make\n" && exit 13;
echo -e "\n installing kernel ...\n"
sudo make modules_install && sudo make install && sudo rm -rf /boot/{System.map,vmlinuz,*.old} && sudo grub2-mkconfig -o /boot/grub2/grub.cfg && sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg;
sync && sync && sync;
exit 0;
my script is NOT completely bug free, there some points I could do better ..., but it runs !!!
What it does (in short):
- looks for a new linux-*.tar.xz (fetched from kernel.org)
- unpacks it and saves linux-*.tar.xz for later use
- cleans the tree (removes gruft from previous run)
- generate a new defconfig and saves old one and the new one for later use
- makes kernel and modules (runs as user)
- installs the new kernel (runs as root)
- adjusts grub.cfg (runs as root)