Jump to content
Read the Funtoo Newsletter: Summer 2023 ×

How to upgrade and patch kernel?


Recommended Posts

Hello! Some news like this https://lkml.org/lkml/2018/1/3/780 nudged me to ask how to work with my kernel. I am using debian-sources and seeing this

# eix debian-sources
[I] sys-kernel/debian-sources
     Available versions:  
     (4.8.15) 4.8.15^mbs
     (4.11.11-r1) **4.11.11-r1^mbs
     (4.12.12) **4.12.12^mbs
     (4.13.10) **4.13.10^mbs
     (4.13.13) **4.13.13^mbs
     (4.14.2) 4.14.2^mbs
       {binary}
     Installed versions:  4.8.15(4.8.15)^mbs(21:21:26 18.12.2017)(binary) 4.14.2(4.14.2)^mbs(09:27:22 27.12.2017)(binary)
     Homepage:            http://www.debian.org
     Description:         Debian Sources (and optional binary kernel)

* sys-kernel/debian-sources-lts
     Available versions:  
     (4.9.30-LTS) **4.9.30^mbs
     (4.9.47-LTS) **4.9.47^mbs
     (4.9.51-LTS) **4.9.51^mbs
     (4.9.65-LTS) **4.9.65^mbs
       {binary}
     Homepage:            http://www.debian.org
     Description:         Debian Sources (and optional binary kernel)

Found 2 matches

 

# cat /proc/version
Linux version 4.8.15-1 (portage@sysresccd) (gcc version 5.4.0 (Funtoo 5.4.0) ) #1 SMP Mon Dec 18 16:46:40 -00 2017

# uname -r
4.8.15-1

# dmesg | grep Linux
[    0.000000] Linux version 4.8.15-1 (portage@sysresccd) (gcc version 5.4.0 (Funtoo 5.4.0) ) #1 SMP Mon Dec 18 16:46:40 -00 2017
[    4.182641] Linux agpgart interface v0.103
[   16.151446] usb usb1: Manufacturer: Linux 4.8.15-1 ehci_hcd
[   16.222632] ACPI: [Firmware Bug]: BIOS _OSI(Linux) query ignored
[   17.943979] media: Linux media interface: v0.10
[   17.954357] Linux video capture interface: v2.00

# eselect kernel list
Available kernel symlink targets:
  [1]   linux-debian-sources-4.8.15
  [2]   linux-debian-sources-4.14.2 *

What is mbs? Where to look if debian-sources had been patched?

If you have a time which criteria do you use choosing the kernel?

 

I am trying to compile kernel using wiki https://www.funtoo.org/Funtoo_Linux_Kernels

But I cannot configure kernel for intel n3530:

# lscpu
Архитектура:x86_64
CPU op-mode(s):        32-bit, 64-bit
Порядок байт:Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Ядер на сокет:4
Сокетов:        1
NUMA node(s):          1
ID прроизводителя:GenuineIntel
Семейство ЦПУ:6
Модель:          55
Имя модели:   Intel(R) Pentium(R) CPU  N3530  @ 2.16GHz
Степпинг:      8
CPU MHz:               575.422
CPU max MHz:           2582,3000
CPU min MHz:           499,8000
BogoMIPS:              4331.60
Виртуализация:VT-x
L1d cache:             24K
L1i cache:             32K
L2 cache:              1024K
NUMA node0 CPU(s):     0-3
Флаги:            fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer rdrand lahf_lm 3dnowprefetch epb tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm ida arat


# ./config-extract -l

====== standard featureset ======

       alpha: alpha-generic, alpha-smp
       amd64
       arm64
       armel
       armhf: armmp, armmp-lpae
        hppa: parisc, parisc64-smp
        i386: 686, 686-pae
        m68k
        mips: 4kc-malta, 5kc-malta, octeon
      mips64: 5kc-malta, octeon
    mips64el: 5kc-malta, loongson-3, octeon
    mips64r6
  mips64r6el
      mipsel: 4kc-malta, 5kc-malta, loongson-3, octeon
      mipsr6: mips32r6, mips64r6
    mipsr6el: mips32r6el, mips64r6el
     powerpc: powerpc, powerpc-smp, powerpc64
  powerpcspe
       ppc64
     ppc64el
       s390x
         sh4: sh7751r, sh7785lcr
     sparc64: sparc64, sparc64-smp

====== rt featureset ======

       amd64
        i386


# ./config-extract 686
Traceback (most recent call last):
  File "./config-extract", line 169, in <module>
    if featureset not in archdict[arch]:
KeyError: '686'
# ./config-extract i386 686
Error: There is no '686' featureset kernel config for arch 'i386'. Exiting.
{'rt': ['686-pae'], None: ['686-pae', '686']}
# ./config-extract i386
Error: there is more than one 'sub-architecture' for this arch.
Please specify [arch] [featureset] [subarch], with one of these subarches:
686-pae, 686
# ./config-extract i386 686
Error: There is no '686' featureset kernel config for arch 'i386'. Exiting.
{'rt': ['686-pae'], None: ['686-pae', '686']}
# ./config-extract i386 686-pae
Error: There is no '686-pae' featureset kernel config for arch 'i386'. Exiting.
{'rt': ['686-pae'], None: ['686-pae', '686']}

As I know my proc is 686. How to define 686 sub-arch to config-extract?

Link to comment
Share on other sites

Thank you! I look more problems, But the next does as I need

# ./config-extract amd64
Wrote amd64_none_amd64 kernel configuration to /usr/src/linux-debian-sources-4.14.2/.config.
# genkernel --kernel-config=/usr/src/linux-debian-sources-4.14.2/.config all
* Funtoo Linux Genkernel; Version 3.4.40.20-funtoo
* Running with options: --kernel-config=/usr/src/linux-debian-sources-4.14.2/.config all

* Linux Kernel 4.14.2-1 for x86_64...
* .. with config file /usr/src/linux-debian-sources-4.14.2/.config
* mount: /boot mounted successfully!
* fixing include/linux/version.h
* kernel: Using config from /usr/src/linux-debian-sources-4.14.2/.config
*         Previous config backed up to .config--2018-01-04--16-44-29.bak
* kernel: >> Running mrproper...
cp: не удалось выполнить stat для «/usr/src/linux-debian-sources-4.14.2/.config»: No such file or directory
* ERROR: Could not copy configuration file!
* 
* -- Grepping log... --
* 
*  CLEAN   include/config include/generated arch/x86/include/generated
*  CLEAN   .config .config.old Module.symvers
* Funtoo Linux Genkernel; Version 3.4.40.20-funtoo
* Running with options: --kernel-config=/usr/src/linux-debian-sources-4.14.2/.config all
*
* ERROR: Could not copy configuration file!
* 
* -- End log... --
* 
* Please consult /var/log/genkernel.log for more information and any
* errors that were reported above.
* 
* Report any genkernel bugs to bugs.gentoo.org and
* assign your bug to genkernel@gentoo.org. Please include
* as much information as you can in your bug report; attaching
* /var/log/genkernel.log so that your issue can be dealt with effectively.
* 
* Please do *not* report compilation failures as genkernel bugs!
* 
# ls -la
итого 912
drwxr-xr-x  24 root root   4096 янв  4 16:44 .
drwxr-xr-x   4 root root   4096 янв  4 12:07 ..
-rw-r--r--   1 root root     59 ноя 24 10:37 .cocciconfig
-rw-r--r--   1 root root 151394 янв  4 16:44 .config--2018-01-04--16-44-29.bak
-rw-r--r--   1 root root     31 ноя 24 10:37 .get_maintainer.ignore
-rw-r--r--   1 root root     30 ноя 24 10:37 .gitattributes
-rw-r--r--   1 root root   1273 дек 27 07:16 .gitignore
-rw-r--r--   1 root root   8885 ноя 24 10:37 .mailmap
-rw-r--r--   1 root root  18693 ноя 24 10:37 COPYING
-rw-r--r--   1 root root  98556 ноя 24 10:37 CREDITS
drwxr-xr-x 121 root root  12288 дек 27 09:29 Documentation
-rw-r--r--   1 root root   2293 ноя 24 10:37 Kbuild
-rw-r--r--   1 root root    287 ноя 24 10:37 Kconfig
-rw-r--r--   1 root root 430911 дек 27 07:16 MAINTAINERS
-rw-r--r--   1 root root  60190 дек 27 07:16 Makefile
-rw-r--r--   1 root root    722 ноя 24 10:37 README
drwxr-xr-x  32 root root   4096 дек 27 09:29 arch
drwxr-xr-x   3 root root   4096 дек 27 09:28 block
drwxr-xr-x   2 root root   4096 дек 27 09:28 certs
-rwxr-xr-x   1 root root   6638 дек 27 07:17 config-extract
drwxr-xr-x   4 root root   4096 дек 27 09:28 crypto
drwxr-xr-x 131 root root   4096 дек 27 09:29 drivers
drwxr-xr-x   2 root root   4096 дек 27 09:29 firmware
drwxr-xr-x  74 root root   4096 дек 27 09:29 fs
drwxr-xr-x  27 root root   4096 янв  4 16:44 include
drwxr-xr-x   2 root root   4096 дек 27 09:29 init
drwxr-xr-x   2 root root   4096 дек 27 09:28 ipc
drwxr-xr-x  17 root root   4096 янв  4 16:44 kernel
drwxr-xr-x  13 root root  12288 дек 27 09:29 lib
drwxr-xr-x   3 root root   4096 дек 27 09:29 mm
drwxr-xr-x  69 root root   4096 дек 27 09:29 net
drwxr-xr-x  28 root root   4096 дек 27 09:28 samples
drwxr-xr-x  14 root root   4096 янв  4 16:44 scripts
drwxr-xr-x  10 root root   4096 дек 27 09:29 security
drwxr-xr-x  24 root root   4096 дек 27 09:29 sound
drwxr-xr-x  30 root root   4096 дек 27 09:29 tools
drwxr-xr-x   2 root root   4096 дек 27 09:29 usr
drwxr-xr-x   4 root root   4096 дек 27 09:29 virt
# ./config-extract amd64
Unable to open debian/rules.gen; can't continue.
# ls
COPYING        Kconfig      arch            crypto    include  lib      scripts   usr
CREDITS        MAINTAINERS  block           drivers   init     mm       security  virt
Documentation  Makefile     certs           firmware  ipc      net      sound
Kbuild         README       config-extract  fs        kernel   samples  tools
# ls -la
итого 912
drwxr-xr-x  24 root root   4096 янв  4 16:44 .
drwxr-xr-x   4 root root   4096 янв  4 12:07 ..
-rw-r--r--   1 root root     59 ноя 24 10:37 .cocciconfig
-rw-r--r--   1 root root 151394 янв  4 16:44 .config--2018-01-04--16-44-29.bak
-rw-r--r--   1 root root     31 ноя 24 10:37 .get_maintainer.ignore
-rw-r--r--   1 root root     30 ноя 24 10:37 .gitattributes
-rw-r--r--   1 root root   1273 дек 27 07:16 .gitignore
-rw-r--r--   1 root root   8885 ноя 24 10:37 .mailmap
-rw-r--r--   1 root root  18693 ноя 24 10:37 COPYING
-rw-r--r--   1 root root  98556 ноя 24 10:37 CREDITS
drwxr-xr-x 121 root root  12288 дек 27 09:29 Documentation
-rw-r--r--   1 root root   2293 ноя 24 10:37 Kbuild
-rw-r--r--   1 root root    287 ноя 24 10:37 Kconfig
-rw-r--r--   1 root root 430911 дек 27 07:16 MAINTAINERS
-rw-r--r--   1 root root  60190 дек 27 07:16 Makefile
-rw-r--r--   1 root root    722 ноя 24 10:37 README
drwxr-xr-x  32 root root   4096 дек 27 09:29 arch
drwxr-xr-x   3 root root   4096 дек 27 09:28 block
drwxr-xr-x   2 root root   4096 дек 27 09:28 certs
-rwxr-xr-x   1 root root   6638 дек 27 07:17 config-extract
drwxr-xr-x   4 root root   4096 дек 27 09:28 crypto
drwxr-xr-x 131 root root   4096 дек 27 09:29 drivers
drwxr-xr-x   2 root root   4096 дек 27 09:29 firmware
drwxr-xr-x  74 root root   4096 дек 27 09:29 fs
drwxr-xr-x  27 root root   4096 янв  4 16:44 include
drwxr-xr-x   2 root root   4096 дек 27 09:29 init
drwxr-xr-x   2 root root   4096 дек 27 09:28 ipc
drwxr-xr-x  17 root root   4096 янв  4 16:44 kernel
drwxr-xr-x  13 root root  12288 дек 27 09:29 lib
drwxr-xr-x   3 root root   4096 дек 27 09:29 mm
drwxr-xr-x  69 root root   4096 дек 27 09:29 net
drwxr-xr-x  28 root root   4096 дек 27 09:28 samples
drwxr-xr-x  14 root root   4096 янв  4 16:44 scripts
drwxr-xr-x  10 root root   4096 дек 27 09:29 security
drwxr-xr-x  24 root root   4096 дек 27 09:29 sound
drwxr-xr-x  30 root root   4096 дек 27 09:29 tools
drwxr-xr-x   2 root root   4096 дек 27 09:29 usr
drwxr-xr-x   4 root root   4096 дек 27 09:29 virt
# pwd
/usr/src/linux
# ./config-extract amd64
Unable to open debian/rules.gen; can't continue.
# ls
COPYING        Kconfig      arch            crypto    include  lib      scripts   usr
CREDITS        MAINTAINERS  block           drivers   init     mm       security  virt
Documentation  Makefile     certs           firmware  ipc      net      sound
Kbuild         README       config-extract  fs        kernel   samples  tools
# cd emerge -1 debian-sources
bash: cd: слишком много аргументов
#  emerge -1 debian-sources
...
...
...
* Applying debian-sources-4.13.10-mcelog.patch ...                                        [ ok ]
Wrote amd64_none_amd64 kernel configuration to /var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/linux-4.14.2/.config.
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/linux-4.14.2 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/linux-4.14.2 ...
* Funtoo Linux Genkernel; Version 3.4.40.20-funtoo
* Running with options: --no-save-config --kernel-config=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/temp/config --kernname=debian-sources --build-src=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/linux-4.14.2 --build-dst=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/build --makeopts=-j5 --cachedir=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/temp/cache --tempdir=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/temp/twork --logfile=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/genkernel.log --bootdir=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/out/boot --disklabel --lvm --luks --mdadm --iscsi --module-prefix=/var/tmp/portage/sys-kernel/debian-sources-4.14.2/work/out all

* Linux Kernel 4.14.2-1 for x86_64...
* .. with config file /var/tmp/portage/sys-kernel/debian-sources-4.14.2/temp/config
* kernel: Using config from /var/tmp/portage/sys-kernel/debian-sources-4.14.2/temp/config
* kernel: >> Running mrproper...
*         >> Running oldconfig...
* kernel: >> Cleaning...
*         >> Compiling 4.14.2-1 bzImage...
...

I could not use prepared config for amd64, because of genkernel 'Could not copy configuration file'.

Also I could not create config again, because of config-extract 'Unable to open debian/rules.gen'

But `emerge -1 debian-sources` downloaded ad started to compile it.

Please let me know if there is way to turn back to old kernel when Funtoo will not boot after reboot?

Link to comment
Share on other sites

that will depend on your /etc/boot.conf

make sure your config looks like this

boot {
        generate grub
        default "Funtoo Linux genkernel"
        timeout 3
}

and also if you have already run emerge --depclean it will try to remove old kernels.

if you want to keep your older 4.8.15 kernel around you should do

 emerge --ask --noreplace =sys-kernel/debian-sources-4.8.15

remember to run boot-update after any changes to boot.conf

Link to comment
Share on other sites

thank you. I cannot compare your code with this i have

# cat  /etc/boot.conf 
boot {
	generate grub
	default "Funtoo Linux" 
	timeout 3 
}

"Funtoo Linux" {
	kernel bzImage[-v]
}

"Funtoo Linux genkernel" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto rootfstype=auto
} 

"memtest86+" {
	type linux16
	kernel /memtest86.bin
}

but I mentioned pcmanfm offered me twice to open new media while emerge worked, and I had only 2 variants on grub but here are 4.

Link to comment
Share on other sites

24 minutes ago, znavko said:

hummm.. is there case if I run genkernel in /usr/src/linux ? may be for better result need previously  `cd /root` ?

not sure what you mean here.. but running getkernel there see the "Important" where it says:

Unless explicitly stated via --no-clean or --no-mrproper, Genkernel will do a make mrproper in the kernel source tree, thus cleaning a previous build and removing the previous kernel configuration file in it.

meaning it will remove your configuration and clean all previous builds!

as to your boot.conf the boot { } part is what you need to change

default "Funtoo Linux" to default "Funtoo Linux genkernel"

mount /boot and look you should see the new kernel and initramfs 

then your ready to run boot-update

Link to comment
Share on other sites

I've made changes but boot-update displayed warning. can you explain?

 

# cat /etc/boot.conf
boot {
	generate grub
	default "Funtoo Linux genkernel" 
	timeout 3 
}

"Funtoo Linux" {
	kernel bzImage[-v]
}

"Funtoo Linux genkernel" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto rootfstype=auto
} 

"memtest86+" {
	type linux16
	kernel /memtest86.bin
}


# boot-update

boot-update 1.8.2 /
Copyright 2009-2017 Funtoo Technologies

 [use option "-l" for license info, "-h" for help]

  * Generating config for grub...

            Funtoo Linux genkernel - kernel-debian-sources-x86_64-4.8.15-1
  DEFAULT > Funtoo Linux genkernel - kernel-debian-sources-
          x86_64-4.14.2-1
            memtest86+

  * NOTE: Detected MBR boot. Configuring for Legacy MBR booting.
  * WARN: multiple matches found for default "Funtoo Linux genkernel" -
          most recent used.

  * Completed successfully with warnings.



# pwd
/boot

# ls
System.map-debian-sources-x86_64-4.14.2-1
System.map-debian-sources-x86_64-4.8.15-1
early_ucode.cpio
grub
initramfs-debian-sources-x86_64-4.14.2-1
initramfs-debian-sources-x86_64-4.8.15-1
kernel-debian-sources-x86_64-4.14.2-1
kernel-debian-sources-x86_64-4.8.15-1
lost+found
memtest86.bin

 

Link to comment
Share on other sites

yes.i rebooted with new kernel

# uname -r
4.14.2-1

and I have 3 variants in grub: funtoo 4.8, funtoo 4.14 and memory test

thank you very much! As I understood the result is kernel's xz (or bz if choosed this type) image on /dev/sda1 that intramfs loads to ram

# fdisk -l
Диск /dev/sda: 111,8 GiB, 120034123776 байт, 234441648 секторов
Единицы: секторов по 1 * 512 = 512 байт
Размер сектора (логический/физический): 512 байт / 512 байт
Размер I/O (минимальный/оптимальный): 512 байт / 512 байт
Тип метки диска: dos
Идентификатор диска: 0x462af8c6

Устр-во    Загрузочный  начало     Конец   Секторы Размер Идентификатор Тип
/dev/sda1                 2048    264191    262144   128M            83 Linux
/dev/sda2               264192   4458495   4194304     2G            82 Linux св
/dev/sda3              4458496 234441647 229983152 109,7G            83 Linux

# mount /dev/sda1 /boot
# cd /boot
# ls
System.map-debian-sources-x86_64-4.14.2-1
System.map-debian-sources-x86_64-4.8.15-1
early_ucode.cpio
grub
initramfs-debian-sources-x86_64-4.14.2-1
initramfs-debian-sources-x86_64-4.8.15-1
kernel-debian-sources-x86_64-4.14.2-1
kernel-debian-sources-x86_64-4.8.15-1
lost+found
memtest86.bin

# ls -la
итого 34276
drwxr-xr-x  4 root root    1024 янв  4 19:39 .
drwxr-xr-x 22 root root    4096 дек 25 02:20 ..
-rw-r--r--  1 root root       0 янв  4 19:39 .keep
-rw-r--r--  1 root root       0 дек 17 22:03 .keep_sys-apps_baselayout-0
-rw-r--r--  1 root root 3282244 янв  4 17:16 System.map-debian-sources-x86_64-4.14.2-1
-rw-r--r--  1 root root 3368872 дек 18 19:47 System.map-debian-sources-x86_64-4.8.15-1
-rw-r--r--  1 root root 1303552 сен  9 17:36 early_ucode.cpio
drwxr-xr-x  6 root root    1024 янв  4 19:57 grub
-rw-r--r--  1 root root 8995764 янв  4 19:28 initramfs-debian-sources-x86_64-4.14.2-1
-rw-r--r--  1 root root 8421020 дек 18 21:16 initramfs-debian-sources-x86_64-4.8.15-1
-rw-r--r--  1 root root 4929296 янв  4 17:16 kernel-debian-sources-x86_64-4.14.2-1
-rw-r--r--  1 root root 4479264 дек 18 19:47 kernel-debian-sources-x86_64-4.8.15-1
drwx------  2 root root   12288 сен  9 13:00 lost+found
-rw-r--r--  1 root root  150024 дек 18 21:49 memtest86.bin

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...