[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: make custom kernel



Hi,


On 2021-07-04 2:42 a.m., mick crane wrote:
> On 2021-07-04 06:22, mlnl wrote:
>> Hi Mick,
>>
>> mick crane <mick.crane@gmail.com> wrote:
>>
>>> I've done it before but I've forgotten and the order.
>>> What's the procedure for making a custom kernel?
>>
>> Do you mean a custom Debian or a vanilla kernel from kernel.org?
>> For a Debian kernel you can look at
>> <https://kernel-team.pages.debian.net/kernel-handbook/>
>>
>> For a vanilla kernel, i use the following steps:
>> 1. download the kernel source archive of your choice
>> 2. extract the xz archive with unxz
>> 3. verify the tar archive with gpg
>> 4. untar the tar archive
>> 5. cd linux-version
>> 6. make mrproper
>> (6b) copy old config as linux-version/.config and/or certs in
>> linux-version/certs for modules signing
>> 8. make menuconfig (you need some packages, libncurses etc.)
>> 9. export CONCURRENCY_LEVEL="$(grep -c '^processor' /proc/cpuinfo)"
>> 10. make deb-pkg LOCALVERSION=-nameN KDEB_PKGVERSION=$(make
>> kernelversion)-1 (nameN e. g. v1)
>> 11. sudo dpkg -i kernel-packages (-headers, -image, -libc-dev)
> 
> thank you very much. Can I somehow load the current configuration so
> menuconfig shows what choices were made for current kernel ?
> 
The step 6b does exactly what you ask.
The .config file contain the Kernel options.
You can use the files contained inside you /boot directory.
Ex:
For myself :

ls /boot

config-4.19.0-16-amd64       initrd.img-5.10.0-0.bpo.5-amd64
config-4.19.0-9-amd64        System.map-4.19.0-16-amd64
config-4.19.182              System.map-4.19.0-9-amd64
config-5.10.0-0.bpo.5-amd64  System.map-4.19.182
efi                          System.map-5.10.0-0.bpo.5-amd64
grub                         vmlinuz-4.19.0-16-amd64
initrd.img-4.19.0-16-amd64   vmlinuz-4.19.0-9-amd64
initrd.img-4.19.0-9-amd64    vmlinuz-4.19.182
initrd.img-4.19.182          vmlinuz-5.10.0-0.bpo.5-amd64

The file config-4.19-182 and config-5.10.0-0.bpo.5-and64 both contain
kernel configs.
So does the other config-* files.

If you copy this file into the base of your new kernel source it will be
used as base for building.
Depending on the differences between the config file you use as base and
the actual kernel you are compiling there may be some necessary config
missing. So it is always better to run a *make menuconfig* as a safe bet.

Also if you look into the /usr/src folder you may find some other config
files, depending if you installed kernel header or not.

For my case :

*usr/src/linux-headers-4.19.0-16-amd64*

will contain a file named .config
Here's a list of my */usr/src*

binutils                        linux-headers-4.19.182
castle-game-engine-6.4          linux-headers-5.10.0-0.bpo.5-amd64
gcc-7                           linux-headers-5.10.0-0.bpo.5-common
gcc-8                           linux-kbuild-4.19
gdb.tar.bz2                     linux-kbuild-5.10
glibc                           linux-patch-4.19-rt.patch.xz
gmock                           linux-patch-5.10-rt.patch.xz
googletest                      linux-source-4.19.tar.xz
gtest                           linux-source-5.10.tar.xz
libdvd-pkg                      linux-support-4.19.0-16
liblzf                          linux-support-4.19.0-9
linux-config-4.19               nvidia-current-418.181.07
linux-config-5.10               nvidia-tesla-460-460.73.01
linux-headers-4.19.0-16-amd64   nvidia-tesla-460-kernel.tar.xz
linux-headers-4.19.0-16-common  v4l2loopback-0.12.1
linux-headers-4.19.0-9-amd64    v4l2loopback.tar.bz2
linux-headers-4.19.0-9-common

Everything called linux-config* and linux-headers-* will contain a
.config file.

So as a hint, I'd say to install the closest linux-headers you can get
to the version you wish to compile as your custom kernel.
For example if you plan compiling 5.19.182 then installing Debian kernel
version 4.19.0 would be a good start.
If planning to compile a custom kernel version 5.10.xxx then installing
a 5.10 backport kernel headers and using this .config as a base would be
a good start for this one.

Hope this will put you on track for your new custom kernel.

Sincerely,
PM



> mick

-- 
Polyna-Maude R.-Summerside
-Be smart, Be wise, Support opensource development

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: