Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
About rebuilding the kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
user57260
n00b
n00b


Joined: 26 Sep 2017
Posts: 2

PostPosted: Tue Sep 26, 2017 1:19 pm    Post subject: About rebuilding the kernel Reply with quote

I have just installed Gentoo using genkernel and afterwards I changed a few options in the kernel configuration because sound isn't working. Did #make menuconfig, changed the settings I needed, exited X, then followed the commands mentioned here:
Code:
# make && make modules_install
# mount /boot
# make install
# grub-mkconfig -o /boot/grub/grub.cfg
# reboot

However, now the contents of /usr/src are:
Code:
$ ls -la
-rw-r--r--  1 root root    0 Sep  7 03:28 .keep
lrwxrwxrwx  1 root root   20 Sep 21 19:04 linux -> linux-4.12.12-gentoo
drwxr-xr-x 22 root root 4096 Sep 26 00:54 linux-4.12.12-gentoo
drwxr-xr-x 25 root root 4096 Sep 26 16:04 linux-4.13.3-gentoo

Why are there two kernels?
The symlink linux points to linux-4.12.12-gentoo, but there is no Makefile in this directory:
Code:
$ ls -la
total 1330160
drwxr-xr-x 22 root root      4096 Sep 26 00:54 .
drwxr-xr-x  4 root root      4096 Sep 24 02:01 ..
-rw-r--r--  1 root root    153972 Sep 24 23:50 .config
-rw-r--r--  1 root root    154105 Sep 24 16:31 .config.old
-rw-r--r--  1 root root       485 Sep 24 18:36 .missing-syscalls.d
-rw-r--r--  1 root root   2977805 Sep 24 18:40 .tmp_System.map
-rw-r--r--  1 root root   7125840 Sep 24 18:40 .tmp_kallsyms1.S
-rw-r--r--  1 root root   1190944 Sep 24 18:40 .tmp_kallsyms1.o
-rw-r--r--  1 root root   7125840 Sep 24 18:40 .tmp_kallsyms2.S
-rw-r--r--  1 root root   1190944 Sep 24 18:40 .tmp_kallsyms2.o
drwxr-xr-x  2 root root     69632 Sep 24 18:39 .tmp_versions
-rwxr-xr-x  1 root root 325087416 Sep 24 18:40 .tmp_vmlinux1
-rwxr-xr-x  1 root root 327184592 Sep 24 18:40 .tmp_vmlinux2
-rw-r--r--  1 root root         2 Sep 24 18:39 .version
-rw-r--r--  1 root root        97 Sep 24 18:40 .vmlinux.cmd
-rw-r--r--  1 root root    937965 Sep 24 18:41 Module.symvers
-rw-r--r--  1 root root   2977805 Sep 24 18:40 System.map
drwxr-xr-x  4 root root      4096 Sep 26 00:54 arch
drwxr-xr-x  3 root root     12288 Sep 26 00:54 block
drwxr-xr-x  2 root root      4096 Sep 26 00:54 certs
drwxr-xr-x  4 root root     24576 Sep 26 00:54 crypto
drwxr-xr-x 83 root root      4096 Sep 26 00:54 drivers
drwxr-xr-x 36 root root      4096 Sep 26 00:54 firmware
drwxr-xr-x 58 root root     12288 Sep 26 00:54 fs
drwxr-xr-x  4 root root      4096 Sep 26 00:54 include
drwxr-xr-x  2 root root      4096 Sep 26 00:54 init
drwxr-xr-x  2 root root      4096 Sep 26 00:54 ipc
drwxr-xr-x 15 root root     12288 Sep 26 00:54 kernel
drwxr-xr-x 11 root root     24576 Sep 26 00:54 lib
drwxr-xr-x  2 root root     12288 Sep 26 00:54 mm
-rw-r--r--  1 root root      6102 Sep 24 18:40 modules.builtin
-rw-r--r--  1 root root     63565 Sep 24 18:40 modules.order
drwxr-xr-x 39 root root      4096 Sep 26 00:54 net
drwxr-xr-x  9 root root      4096 Sep 26 00:54 scripts
drwxr-xr-x  5 root root      4096 Sep 26 00:54 security
drwxr-xr-x 22 root root      4096 Sep 26 00:54 sound
drwxr-xr-x  3 root root      4096 Sep 26 00:54 usr
drwxr-xr-x  4 root root      4096 Sep 26 00:54 virt
-rwxr-xr-x  1 root root 327184592 Sep 24 18:40 vmlinux
lrwxrwxrwx  1 root root        56 Sep 24 18:39 vmlinux-gdb.py -> /usr/src/linux-4.12.12-gentoo/scripts/gdb/vmlinux-gdb.py
-rw-r--r--  1 root root 378053616 Sep 24 18:39 vmlinux.o

But in the linux-4.13.3-gentoo directory there is a Makefile:
Code:
$ ls -la
total 748
drwxr-xr-x  25 root root   4096 Sep 26 16:04 .
drwxr-xr-x   4 root root   4096 Sep 24 02:01 ..
-rw-r--r--   1 root root     59 Sep  3 22:56 .cocciconfig
-rw-r--r--   1 root root     31 Sep  3 22:56 .get_maintainer.ignore
-rw-r--r--   1 root root     30 Sep  3 22:56 .gitattributes
-rw-r--r--   1 root root   1312 Sep  3 22:56 .gitignore
-rw-r--r--   1 root root   8299 Sep  3 22:56 .mailmap
-rw-r--r--   1 root root  18693 Sep  3 22:56 COPYING
-rw-r--r--   1 root root  98465 Sep  3 22:56 CREDITS
drwxr-xr-x 121 root root  12288 Sep 24 02:01 Documentation
-rw-r--r--   1 root root   2258 Sep  3 22:56 Kbuild
-rw-r--r--   1 root root    277 Sep 24 02:01 Kconfig
-rw-r--r--   1 root root 420816 Sep  3 22:56 MAINTAINERS
-rw-r--r--   1 root root  60252 Sep 24 02:01 Makefile
-rw-r--r--   1 root root    722 Sep  3 22:56 README
drwxr-xr-x  32 root root   4096 Sep 24 02:01 arch
drwxr-xr-x   3 root root   4096 Sep 24 02:01 block
drwxr-xr-x   2 root root   4096 Sep 24 02:01 certs
drwxr-xr-x   4 root root   4096 Sep 24 02:01 crypto
drwxr-xr-x   2 root root   4096 Sep 24 02:01 distro
drwxr-xr-x 132 root root   4096 Sep 24 02:01 drivers
drwxr-xr-x  36 root root   4096 Sep 24 02:01 firmware
drwxr-xr-x  74 root root   4096 Sep 24 02:01 fs
drwxr-xr-x  30 root root   4096 Sep 26 16:04 include
drwxr-xr-x   2 root root   4096 Sep 24 02:01 init
drwxr-xr-x   2 root root   4096 Sep 24 02:01 ipc
drwxr-xr-x  17 root root   4096 Sep 24 02:01 kernel
drwxr-xr-x  12 root root  12288 Sep 24 02:01 lib
drwxr-xr-x   3 root root   4096 Sep 24 02:01 mm
drwxr-xr-x  69 root root   4096 Sep 24 02:01 net
drwxr-xr-x  27 root root   4096 Sep 24 02:01 samples
drwxr-xr-x  14 root root   4096 Sep 24 02:01 scripts
drwxr-xr-x  10 root root   4096 Sep 24 02:01 security
drwxr-xr-x  24 root root   4096 Sep 24 02:01 sound
drwxr-xr-x  31 root root   4096 Sep 24 02:01 tools
drwxr-xr-x   2 root root   4096 Sep 24 02:01 usr
drwxr-xr-x   4 root root   4096 Sep 24 02:01 virt

So # make menuconfig only works with linux-4.13.3-gentoo. How should I proceed? Should I have booted from a USB instead to make the changes?
Back to top
View user's profile Send private message
xaviermiller
Administrator
Administrator


Joined: 23 Jul 2004
Posts: 7309
Location: ~Brussels - Belgique

PostPosted: Tue Sep 26, 2017 1:25 pm    Post subject: Reply with quote

Hi,

This is because the kernel has been updated. See https://wiki.gentoo.org/wiki/Kernel/Upgrade
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 578

PostPosted: Tue Sep 26, 2017 1:26 pm    Post subject: Reply with quote

It looks like the symlink was made wrong. You'll probably have to delete it and then ln -sf /usr/src/<kernel folder> /usr/src/linux

Be careful though, because you may lose your .config file where your kernel configuration is stored. Find that file first and back it up. It's in one of those two kernel folders is my guess.


Last edited by duby2291 on Tue Sep 26, 2017 1:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Tue Sep 26, 2017 1:28 pm    Post subject: Reply with quote

after making your kernel, you may

cp /usr/src/linux/arch/x86/boot/bzImage /boot/your_file_name

than edit your bootloader accordingly. Most of the time I just replace the active boot entry number, and the kernel name.

I suggest that you name your kernel to something reasonable
=> e.g. the date => CONFIG_LOCALVERSION="-05-08-2017"
than verify when you have booted your kernel with uname -a

ofc my kernel name, config_localversion are named similar
Back to top
View user's profile Send private message
user57260
n00b
n00b


Joined: 26 Sep 2017
Posts: 2

PostPosted: Tue Sep 26, 2017 3:58 pm    Post subject: Reply with quote

Thank you all for answering.
xaviermiller wrote:
Hi,

This is because the kernel has been updated. See https://wiki.gentoo.org/wiki/Kernel/Upgrade

I'm now reading the link. I did eselect but it tells me there is only one available kernel source:
Code:
$ eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.13.3-gentoo

Why doesn't linux-4.12.12-gentoo appear in the list, since it is the one /usr/src/linux points to?
I've proceeded with this guide but I'm stuck at Automated build. I don't quite understand it:
Quote:
It is possible to automatically build and install the newly emerged kernel using portage hooks. While other approaches are also possible, the following is based on genkernel, gentoo-sources and requires the following prerequisites:

1. genkernel all is able to build and install the kernel to which the /usr/src/linux symlink points into $BOOTDIR and your bootloader.
2. the symlink use flag is set for the kernel ebuild

If those are fulfilled, simply install a post_pkg_postinst portage hook as shown below.

How do I check point 1? And "install a post_pkg_postinst portage hook" means to simply copy the text, right?
duby2291 wrote:
It looks like the symlink was made wrong. You'll probably have to delete it and then ln -sf /usr/src/<kernel folder> /usr/src/linux

Be careful though, because you may lose your .config file where your kernel configuration is stored. Find that file first and back it up. It's in one of those two kernel folders is my guess.

The kernel source I'm using is also the one symlink points to, but in that directory there's no Makefile, and it's not recognized by "eselect kernel list". It seems the problem is in the source rather than in the symlink.
Roman_Gruber wrote:
after making your kernel, you may

cp /usr/src/linux/arch/x86/boot/bzImage /boot/your_file_name

than edit your bootloader accordingly. Most of the time I just replace the active boot entry number, and the kernel name.

I suggest that you name your kernel to something reasonable
=> e.g. the date => CONFIG_LOCALVERSION="-05-08-2017"
than verify when you have booted your kernel with uname -a

ofc my kernel name, config_localversion are named similar

What does cp /usr/src/linux/arch/x86/boot/bzImage /boot/your_file_name accomplish, exactly? Also, I'm not familiar with editing the bootloader, if I do an automated build I shouldn't need to reconfigure it, right?

(This is my first time installing Linux, always used Windows)
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2441

PostPosted: Tue Sep 26, 2017 4:11 pm    Post subject: Reply with quote

user57260 wrote:
Thank you all for answering.
xaviermiller wrote:
Hi,

This is because the kernel has been updated. See https://wiki.gentoo.org/wiki/Kernel/Upgrade

I'm now reading the link. I did eselect but it tells me there is only one available kernel source:
Code:
$ eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.13.3-gentoo

Why doesn't linux-4.12.12-gentoo appear in the list, since it is the one /usr/src/linux points to?

Maybe, has 4.12.12 already been unmerged? Check eix -I gentoo-sources . The eselect kernel list only lists kernels being installed.

To prevent kernel being updated unconditionally, I always install the certain slot I want, e.g. emerge -avt gentoo-sources:4.9.49-r1, so the slot gets added to the /var/lib/portage/world file.
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 578

PostPosted: Tue Sep 26, 2017 4:21 pm    Post subject: Reply with quote

charles17 wrote:
user57260 wrote:
Thank you all for answering.
xaviermiller wrote:
Hi,

This is because the kernel has been updated. See https://wiki.gentoo.org/wiki/Kernel/Upgrade

I'm now reading the link. I did eselect but it tells me there is only one available kernel source:
Code:
$ eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.13.3-gentoo

Why doesn't linux-4.12.12-gentoo appear in the list, since it is the one /usr/src/linux points to?

Maybe, has 4.12.12 already been unmerged? Check eix -I gentoo-sources . The eselect kernel list only lists kernels being installed.

To prevent kernel being updated unconditionally, I always install the certain slot I want, e.g. emerge -avt gentoo-sources:4.9.49-r1, so the slot gets added to the /var/lib/portage/world file.


Ah, That's great advice. I hadn't realized the kernel could be slotted like that. I had assumed there must be a way to do it, but I didn't know for sure. Thanks very much!
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5958
Location: Saint Amant, Acadiana

PostPosted: Tue Sep 26, 2017 4:35 pm    Post subject: Reply with quote

The drawback is you also have to remove it manually, --depclean won't touch it. I personally manage my kernel sources by adding --exclude gentoo-sources to my emerge update command.
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2441

PostPosted: Tue Sep 26, 2017 4:47 pm    Post subject: Reply with quote

Jaglover wrote:
The drawback is you also have to remove it manually, --depclean won't touch it.

Code:
# emerge --depclean --ask --verbose gentoo-sources:4.9.49-r1

Calculating dependencies... done!
>>> Calculating removal order...

>>> These are the packages that would be unmerged:

 sys-kernel/gentoo-sources
    selected: 4.9.49-r1
   protected: none
     omitted: none

All selected packages: =sys-kernel/gentoo-sources-4.9.49-r1

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Would you like to unmerge these packages? [Yes/No]
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5958
Location: Saint Amant, Acadiana

PostPosted: Tue Sep 26, 2017 4:55 pm    Post subject: Reply with quote

See, that's what I said, you have to specify it manually.
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum