You are not logged in.

#1 2017-07-15 13:59:06

onexused
Member
Registered: 2009-10-07
Posts: 115

Configuring my own kernel

I would like to compile my own kernel, with a config I've made because up to date official Arch packages no longer properly support my older hardware (linux-lts started having problems when it switched from 4.4 to 4.9). I used to do this years ago with Gentoo, so I know the process. I started with the default configuration (extract the kernel sources, make menuconfig) and went from there. For my tests, I used linux 4.9.36. However, I haven't figured out these things with kernels I've compiled and successfully booted:
- The laptop (thinkpad T60 2007) doesn't sleep when the lid is closed, but the screen turns off and won't turn back on without reboot
   - ACPI and Thinkpad ACPI Laptop Extras are enabled
- Openvpn won't start because it can't find the expected /dev/net/tun node
   - Universal TUN/TAP device driver support is enabled

Until I can get this fixed, I have linux-lts package stuck at 4.4-51 . Help would be appreciated.

Offline

#2 2017-07-15 14:06:16

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Configuring my own kernel

Seems to be that you have multiple issues here but let's start with the title one: use a PKGBUILD and substitute the config.x86_64 with your functional config which you can likely obtain from the running functional system:

zcat /proc/config.gz > config.x86_64

Are you familiar with makepkg and PKGBUILDs?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2017-07-15 14:22:27

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Configuring my own kernel

Expanding on graysky's suggestion, I would be interested in seeing a diff between your kernel configuration and the stock kernel configuration.

Edit:  Also, as you are a former Gentoo user, I am going to go against the general advice you would receive here -- don't use a PKGBUILD.  Create a kernel, give it a unique name in its config, and install using make modules_install, then manually move your kernel to the boot partition under a unique name and configure your bootloader.  I generally build custom kernels such that they don't require an initrd so I don't have to mess with them.   This process lets you pick the kernel at boot time.  The custom kernel and its modules, having a unique kernel name, will not interfere with pacman's operation and they are easy to find in the file system

Edit2:  Snaked by ooo wink

Last edited by ewaller (2017-07-15 14:30:08)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2017-07-15 14:24:25

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Configuring my own kernel

You can also use 'make localmodconfig' for more optimal configuration for your system.
Just make sure all necessary modules are loaded when you run it.

https://wiki.archlinux.org/index.php/Ke … figuration

If you're familiar with building the kernel on gentoo, you are probably better off building kernel the traditional way instead of using PKGBUILDs.

Offline

#5 2017-07-15 14:29:40

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Configuring my own kernel

ooo wrote:

If you're familiar with building the kernel on gentoo, you are probably better off building kernel the traditional way instead of using PKGBUILDs.

Gotta disagree with you ... a PKGBUILD is the way to go for multiple reasons including ease, reproducible, filesystem management.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2017-07-15 14:31:55

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Configuring my own kernel

ewaller wrote:

I am going to go against the general advice you would receive here -- don't use a PKGBUILD.

graysky wrote:

Gotta disagree with you ... a PKGBUILD is the way to go for multiple reasons including ease, reproducible, filesystem management.

See? smile

Last edited by ewaller (2017-07-15 14:47:56)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2017-07-15 14:44:54

init0
Member
Registered: 2011-04-12
Posts: 37

Re: Configuring my own kernel

The lazy yet proper way could be to get the last v4.4 revision of linux-lts from svn (see this commit https://git.archlinux.org/svntogit/pack … 0fe35f93ab), change the version to 4.4.77 / adjust checksums / use "make olddefconfig" all in the PKGBUILD file, build your new 4.4 kernel and tell pacman not to update linux-lts.
From time to time you should follow the 4.4 upstream version.

Last edited by init0 (2017-07-15 14:46:47)

Offline

#8 2017-07-15 15:04:58

init0
Member
Registered: 2011-04-12
Posts: 37

Re: Configuring my own kernel

... besides that guy is also maintaining 4.4
https://aur.archlinux.org/packages/linux-lts44/

Offline

#9 2017-07-15 17:07:05

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Configuring my own kernel

graysky wrote:
ooo wrote:

If you're familiar with building the kernel on gentoo, you are probably better off building kernel the traditional way instead of using PKGBUILDs.

Gotta disagree with you ... a PKGBUILD is the way to go for multiple reasons including ease, reproducible, filesystem management.

Both methods have its benefits, but traditional kernel compilation is exactly the same as how you build the kernel on gentoo, so that should be the way to go for ex-gentoo user.

I find building kernel manually better when you're tweaking the .config, since you don't have to rebuild the whole kernel every time you want to add a module, or do a small config change. For simple version bumps editing the PKGBUILD is a little bit simpler. For maintaining a repo full of kernel packages, using makepkg/PKGBUILDs is definitely way more convenient :)

Nevertheless, the issue here has nothing to do with the build method, but the kernel configuration. However you're building your custom kernel, you should be ok using the arch kernel .config as base and tweaking it to your liking.

Offline

#10 2017-07-17 01:07:31

onexused
Member
Registered: 2009-10-07
Posts: 115

Re: Configuring my own kernel

graysky wrote:

Are you familiar with makepkg and PKGBUILDs?

ooo wrote:

If you're familiar with building the kernel on gentoo, you are probably better off building kernel the traditional way instead of using PKGBUILDs.

ewaller wrote:

Edit:  Also, as you are a former Gentoo user, I am going to go against the general advice you would receive here -- don't use a PKGBUILD.[...]

The way suggested by ewaller and ooo (give it a custom name, make && make modules_install, copy kernel to /boot, edit bootloader config) is the way I tried it.  I'm more comfortable with that method and I don't need an initrd, but I am familiar enough with makepkg and PKGBUILDs to usually correctly modify an existing one.

ewaller wrote:

Expanding on graysky's suggestion, I would be interested in seeing a diff between your kernel configuration and the stock kernel configuration.

Here's a diff between the stock config (downloaded from archlinux.org/packages) and mine: https://paste.pound-python.org/show/1Ua … lFaXwxUDG/ (there's quite a lot of difference. To rephrase what I said, I started with whatever config `make menuconfig`autogenerates when there's none present.)
Edit: And here's the config itself: https://paste.pound-python.org/show/moM … IB9723jvF/

init0 wrote:

... besides that guy is also maintaining 4.4
https://aur.archlinux.org/packages/linux-lts44/

I didn't even think about the possibility that someone else would want this even though I have a number of packages from AUR already : )  That would be easier, if I can't get my config to work.

ooo wrote:

Nevertheless, the issue here has nothing to do with the build method, but the kernel configuration. However you're building your custom kernel, you should be ok using the arch kernel .config as base and tweaking it to your liking.

This is the first thing I tried, but I had no idea where to start since so many options were enabled or modularized already. I haven't yet tried comparing the 4.4 and 4.9 stock configs to see what was removed.

Last edited by onexused (2017-07-17 16:10:13)

Offline

#11 2017-07-22 02:24:43

GenkiSky
Member
From: This account is henceforth dis
Registered: 2017-04-04
Posts: 82

Re: Configuring my own kernel

1. If the non-pacman method for installing the kernel works for you, that's fine. But I second @graysky 's recommendation to use a PKGBUILD if maintaining your own kernel is something you end up doing for a while. My guess is there are nice workarounds to any downsides you might think of. For example, it was mentioned above that "since you don't have to rebuild the whole kernel every time you want to add a module, or do a small config change". However, note that you can use the --noextract  passed to makepkg so that it doesn't start from scratch each time.

2. You shouldn't have to try comparing the 4.4 and 4.9 stock configs to see what was removed. Like @ooo mentioned, you can use "make localmodconfig" to autogenerate a config for you that should Just Work. Basically what you will do is install linux-lts44 like @init0 mentioned, boot in, use the computer like you normally would for a while (set up the VPN, plug in external hardware, etc. -- this is the important step because it's basically loading in all the modules you will want to use), run "make localmodconfig" when you're done (but before rebooting!), and save the .config file created. Then, assuming you still want to use the LTS kernel, clone the linux-lts PKGBUILD etc., change the .config file to the one you saved, then change the PKGBUILD to use "make olddefconfig". This will make it so that the kernel will use the .config file you gave it, and for any new configurations added between 4.4 and 4.9, it will use the defaults for your hardware. That should (hopefully) work just fine, and you will boot into a nice working 4.9 kernel. If not, I'd be curious to hear about it.

Edit: Added important step between booting in and "make localmodconfig".

Last edited by GenkiSky (2017-07-22 02:28:03)

Offline

#12 2017-07-23 13:52:29

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Configuring my own kernel

You can also use ccache to cache the results of compilation in between runs, which should make most object files be recreated almost instantaneously.

(This can also be useful in between patchlevel version updates, when you don't want to leave deleted files around and you want prepare() to run cleanly.)

Last edited by eschwartz (2017-07-23 14:13:30)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#13 2017-08-03 19:54:31

onexused
Member
Registered: 2009-10-07
Posts: 115

Re: Configuring my own kernel

With the `make localmodconfig` command, I was able to build a 4.9 kernel which runs on my machine without problems. Thank you all for your advice regarding the use of the various config possibilities and PKGBUILDs.

Offline

Board footer

Powered by FluxBB