Forum › Forums › General › Tips and Tricks › Kernels, Make your own!
Tagged: kernel, kernel-compile, menuconfig, xconfig
- This topic has 39 replies, 9 voices, and was last updated Jun 4-1:39 pm by Brian Masinick.
-
AuthorPosts
-
February 23, 2018 at 2:48 pm #6899Member
sleekmason
Make your own kernel with options only you can choose!
If you would like to compile your own kernel, you can follow the steps below. Easy Peasy! in fact, it’s never been easier.
For the kernel source, pick one from here:
http://repo.antixlinux.com/stretch/pool/main/l/
I’m using linux-4.15.4-antix.1-486-smp_4.15.4-antix.1-486-smp.orig.tar.gz found inside the linux-4.15.4-antix.1-486-smp/ folder for this guide. If you want, you can also download the kernel-source directly from the Debian repos.
–
Because you are now using development files, you will need to download a few programs to help you.
–As Root:
apt-get install build-essential libncurses5-dev libssl1.0-dev
–
–
And here we go!
Create a directory to perform your work : *NOTE – all of this is done as USER, not Root!
Open a terminal and:
mkdir kernel
–
either download or transfer your linux-4.15.4-antix.1-486-smp/ to ~/kernel
–
Extract the files.
–
This will give you the linux-4.15.4-antix kernel folder you will be working from.
–
Change directories, or open a new terminal inside that folder.
–The first thing we will do is clean up any files that may have changed and make sure the kernel source tree is completely clean. So:
make clean && make mrproper
–
Next we open the configuration file that will instruct the compiler on what to add or leave out depending on the choices you choose:
make menuconfig
–
This will present you with a menu to change the ungodly number of options it contains. For the purpose of this tutorial, only change one thing:
–
Under General setup —> find, Local version – append to kernel release
click on Local version – append to kernel release and type something in. I use sleek. The reason for this is if you already have a 4.15 kernel installed it could be overwritten.
Save and exit
–
Since this is your first foray into the world of kernel-building, it’s best to make sure there are no errors before you make changes that may affect your computer. Later, go back and explore! for instance, under Block Devices look for the scheduler and change it to deadline. You will probably find that deadline is slower than your current scheduler CFQ. Other items to change can be found all over the internet.
–
Next is to make the kernel. Do this with:
make deb-pkg
–
Conversleymake -j2 deb-pkgif you have dual-core.
–
Go make a pot of coffee/tea and kick back for awhile. depending on your computer, may take several hours, but probably not.
When finished, simply install your new kernel with dpkg -i linux-headers-4.15.4-antix.1sleek_4.15.4-antix.1sleek-1_amd64.deb linux-image-4.15.4-antix.1sleek_4.15.4-antix.1sleek-1_amd64.deb
Don’t copy that, use your own!
–
In order to make things even easier, you should use tab-completion in the terminal. This works by typing the first few letters (or words), and then hitting the tab button. This will complete the name of the file if its in your path/folder. *example, type linux-h and hit tab and the rest will autocomplete. you can do this for each sequential item as well, not just the first. Anyway,
‘
dpkg -i linux-headers.foo linux-image.fooreplace with your new debs.
–
REBOOT!! Enjoy your new kernel!! *NOTEyour first boot will be slower than usual as your system repopulates the files.
–
Because of dkms, we no longer have to patch the kernel. This should be done automatically. You can tell at a glance if you have module issues by whether your wifi is working or not.
–
If it is not, and this is important, reboot into your old kernel and run:for i in $(dpkg-query -l |grep "\-dkms" |awk '{print $2'}); do dpkg-reconfigure $i |tee -a /var/log/rebuild-dkms.log doneIf you don’t boot into your old kernel, dkms won’t be able to find the required modules (the initial problem to begin with).
This guide is not even close to being comprehensive. for instance, while we are using make menuconfig to access the kernel config file, there are several other options to accomplish the same thing. One of them, make xconfig (I think), is easier to use for many.
–
Another option is to use:
make localmodconfigbefore running make menuconfig. This option takes the info from your computer and only compiles those items on your computer instead of the five billion options otherwise. The problem with this is that you need to have EVERTHING plugged in that you use, or certain drivers might not make it into the kernel. i.e. USB
–
It’s never been easier to make your own kernel!
Here’s a link to a kernel compile guide I made for android. Take a look to see what was involved 3-4 years ago. The sheer number of steps is staggering. Sleekmasons Android kernel compile guideAnyway, Hope you find this information useful in your quest for linux perfection:)
- This topic was modified 5 years, 2 months ago by sleekmason.
- This topic was modified 5 years, 2 months ago by sleekmason.
- This topic was modified 5 years, 2 months ago by sleekmason.
February 24, 2018 at 6:07 am #6916Forum Admin
rokytnji
::Might mention using the tab key to finish completing the typing out the dpkg -i command when building the kernel .deb. package.
It saves my bacon a lot when in a folder with a terminal and trying to be geeky. Nice tutorial as always sleekmason. Thanks.
example on mine
harry@biker:~ $ ls backup cl2 Downloads mocdata.py Screeny weather.sh batti-0.3.8 Claws_Themes Games mocpdata.py scripts Books Comics Music test Calibre Library Icons Pictures Themes Cartoons Desktop Images Public Videos cl1 Documents Isos S7 Wallpaper harry@biker:~ $ cd baI hit the tab key after typing in ba. Walla
harry@biker:~ $ cd ba backup/ batti-0.3.8/so to narrow things down. I type in ‘batt’ Hit the tab key
harry@biker:~ $ cd batti-0.3.8/The tab key keeps me from making typo errors when typing out large lines of code. Being I have large ham hands and fingers and am a 2 finger type of keyboard user.
Edit: If you edit your thread post with my tab key suggestion. I will delete my post to keep your thread clean and pristine.
`- This reply was modified 5 years, 2 months ago by rokytnji.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsFebruary 24, 2018 at 6:27 am #6918Forum Admin
anticapitalista
::Nice post sleekmason.
I use make localmodconfig for my laptop.
The kernels are much smaller and slightly faster to boot.
I also use alias in /etc/bash.bashrc
#Kernel building alias mold="make oldconfig" alias mpre="make prepare" alias mcl="make clean" alias bk32s="make -j <code>getconf _NPROCESSORS_ONLN</code> deb-pkg LOCALVERSION=-486-smp 2>&1 | tee ../logfile" alias bk32sp="make -j <code>getconf _NPROCESSORS_ONLN</code> deb-pkg LOCALVERSION=-686-smp-pae 2>&1 | tee ../logfile" alias bk64s="make -j <code>getconf _NPROCESSORS_ONLN</code> deb-pkg LOCALVERSION=-amd64-smp 2>&1 | tee ../logfile"- This reply was modified 5 years, 2 months ago by anticapitalista.
- This reply was modified 5 years, 2 months ago by anticapitalista.
Philosophers have interpreted the world in many ways; the point is to change it.
antiX with runit - leaner and meaner.
February 24, 2018 at 7:13 am #6925Member
sleekmason
::Thank you!
I also use alias in /etc/bash.bashrc
Nice!
I’m looking forward to digging in a bit:)February 24, 2018 at 7:45 am #6927Member
sleekmason
::Howdy @rokytnji
Might mention using the tab key to finish completing the typing out the dpkg -i command when building the kernel .deb. package.
You bet:)
–Edit: If you edit your thread post with my tab key suggestion. I will delete my post to keep your thread clean and pristine.
I would ask you to put it right here in tips and tricks. Good example for folks! No need to delete here. In fact, I want people to add ideas and suggestions.
`- This reply was modified 5 years, 2 months ago by sleekmason.
February 24, 2018 at 1:11 pm #6936Anonymous
::for i in $(dpkg-query -l |grep "\-dkms" |awk '{print $2'}); do dpkg-reconfigure $i |tee -a /var/log/rebuild-dkms.log done^—– Is there any harm in doing this, just for good measure, prior to installing the newly-compiled kernel?
(rationale: prevent later discovering “oh, I need to go back and do that”)=================
When I searched for a reference providing details / explanation / values for each kernel configuration option, I bookmarked the following set of “supplemental reading” reference links. These linked pages are maintained / updated.
Currently:
Kernel Sources: sys-kernel/gentoo-sources
Kernel Version: 4.14.12
Last Updated on: 06/01/2018
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-1-introduction/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-2-gentoo-linux-support/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-3-general-setup/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-4-enable-loadable-module-support/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-5-enable-the-block-layer/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-6-processor-type-and-features/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-7-power-management-and-acpi-options/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-8-bus-options-pci-etc/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-9-executable-file-formats-emulations/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-10-networking-support/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-11-device-drivers/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-12-firmware-drivers/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-13-file-systems/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-14-kernel-hacking/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-15-security-options/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-16-cryptographic-api/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-17-virtualization/
https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-18-library-routines/February 24, 2018 at 8:03 pm #6941Anonymous
::Thanks for the great links skidoo I bookmarked them right away.
I’ve built mine on the new gcc8 from sid repos and now my kernel
is the 4.16-rc2 from kernel.org. I put a shot of it in ps_mem.py post.February 25, 2018 at 7:23 am #6958Member
sleekmason
::for i in $(dpkg-query -l |grep "\-dkms" |awk '{print $2'}); do dpkg-reconfigure $i |tee -a /var/log/rebuild-dkms.log done^—– Is there any harm in doing this, just for good measure, prior to installing the newly-compiled kernel?
(rationale: prevent later discovering “oh, I need to go back and do that”)–
Nope! But, completely unnecessary if everything is already working correctly (wifi, virtualbox, etc..), <– (This allows dkms to find the working modules after installing the new kernel, but before booting into it).
*Caveat . . IF, upon rebooting and finding modules not working, do NOT run the above before first switching back to your prior kernel. dkms will look in the present kernel tree to find the modules, and if you are in your new kernel with the modules missing or broken, you will be trying to compile the broken ones into your system, and will corrupt ALL OF THEM!
–
Re-install becomes the easier option then, unless someone knows a simple fix. (backups of modules?)March 20, 2018 at 5:53 am #7999Member
sleekmason
::Latest Antix kernel as of 20 MAR 2018 linux-4.15.9-antix.1 –
Bunch of changes in this kernel. Well worth a rebuild to check it out.
–- This reply was modified 5 years, 1 month ago by sleekmason.
- This reply was modified 5 years, 1 month ago by sleekmason. Reason: ack ack ack
- This reply was modified 5 years, 1 month ago by sleekmason.
March 20, 2018 at 6:12 am #8000Forum Admin
anticapitalista
::I have this on my laptop.
uname -a Linux antix1 4.15.11-antix.2-amd64-smp #1 SMP PREEMPT Mon Mar 19 14:23:10 EET 2018 x86_64 GNU/LinuxPhilosophers have interpreted the world in many ways; the point is to change it.
antiX with runit - leaner and meaner.
March 20, 2018 at 6:25 am #8003Member
sleekmason
March 20, 2018 at 6:29 am #8004Member
sleekmason
March 20, 2018 at 6:37 am #8005Forum Admin
anticapitalista
::Personal build only 🙂
Latest in repos is 4.15.9 as you correctly stated in your post.
- This reply was modified 5 years, 1 month ago by anticapitalista.
Philosophers have interpreted the world in many ways; the point is to change it.
antiX with runit - leaner and meaner.
April 4, 2018 at 1:56 pm #8740Member
sleekmason
::Linux kernel 4.16 is newest stable from: https://www.kernel.org/
Need to install a few new packages to compile kernel 4.16. namely, Bison, flex, and perl5 (this is if you have been compiling kernels through 4.15.13).
For a complete list of dependencies refer to: https://www.kernel.org/doc/html/latest/process/changes.html#changes
April 17, 2018 at 7:52 am #9326Member
sleekmason
::Linux kernel 4.17-rc1 has been released: https://www.kernel.org/
–
Note that this is a prepatch kernel (unstable)
–
Prepatch or “RC” kernels are mainline kernel pre-releases that are mostly aimed at other kernel developers and Linux enthusiasts. They must be compiled from source and usually contain new features that must be tested before they can be put into a stable release.
–
And per Phoronix: https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.17-rc1-Released200,000 lines of code removed, making the kernel smaller than 4.16.
–
Linux 4.17 power measurements are looking surprisingly good for lowering the power use while idling and also the power efficiency under load.
–
Stable version coming in about 8 weeks. -
AuthorPosts
- You must be logged in to reply to this topic.