Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

compiling a kernel for debian in gentoo [UNSOLVED]

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
25 posts • Page 1 of 1
Author
Message
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

compiling a kernel for debian in gentoo [UNSOLVED]

  • Quote

Post by mikefot » Sun May 19, 2019 10:49 am

Dear All,

I notice that it is possible to compile kernels for a different architecture in gentoo.

I belive this is termed cross compiling:

https://wiki.gentoo.org/wiki/Cross_build_environment

Most of the discussions about this seem to be about making a kernel that would run on a mobile phone etc.

Suppose that I would want to make a kernel that I could run in the debian installation I have alongside
gentoo on the amd64 kaveri box I currently use.

I am running gentoo stable and debian buster.

If I would install a new kernel in debian I would follow the instructions here:

https://kernel-team.pages.debian.net/ke ... n-official

Supposing I copied the debian kernel config file I am using in debian buster to my gentoo install.

Could I use it with the kernel compilation tools in portage to make a kernel that would run successfully in debian buster?

What would be the best way to do that?

Also is it possible to do the equivalent of the

Code: Select all

make deb.pkg
command you would run in portage in some way to produce the linux-image.deb
file that you install in debian with the

Code: Select all

dpkg -i 
command?

Then I could copy the new kernel image file over to the debian install and then install it.

I think that gentoo is a good environment in which to obtain new kernels and configure them.

Comments appreciated.

Regards

Michael Fothergill
Last edited by mikefot on Thu May 30, 2019 3:05 pm, edited 1 time in total.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Sun May 19, 2019 11:16 am

mikefot,

Your dual boot system is not a different arch, so you don't cross compile.

To save your sanity either make a complete copy of your existing kernel tree or use different kernel version for debian.
If you go with the copy, edit the top of the makefile in the copy

Code: Select all

# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 1
SUBLEVEL = 1
EXTRAVERSION = -gentoo
NAME = Shy Crocodile
by changing the EXTRAVERSION. This prevents the modules from the different kernels being mixed up.
Do a

Code: Select all

make clean
in this copy, as any left over binaries will be tagged as 5.1.1-gentoo.

Add your config of choice then build the kernel.

What do you mean
kernel compilation tools in portage
genkernel?
genkernel will build and install the kernel and an initrd but you don't want the install.

The kernel make system has some interesting targets.

Code: Select all

...
Kernel packaging:
  rpm-pkg             - Build both source and binary RPM kernel packages
  binrpm-pkg          - Build only the binary kernel RPM package
  deb-pkg             - Build both source and binary deb kernel packages
  bindeb-pkg          - Build only the binary kernel deb package
...
but that won't build or package the initrd. I expect that it will include the kernel modules, so you can install the resulting .deb.
Now you need the matching initrd, if you need an initrd at all.

-- edit --
You may be able to cheat a little and build the initrd into the kernel. I'm sure thats a whole new world of pain.
My initrd is kernel agnostic (no kernel modules), I built it when the system was new in 2009 and it still works.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sun May 19, 2019 3:05 pm

Many thanks for your comments.

When I said that I was interested in making use of portage to do the kernel compilation etc I think I caused a bit of confusion.

What I meant was that I think that gentoo is advantageous for the building of kernels in general.

Thus the manual kernel configuration and compilation methods in gentoo are well oiled tools.

You would use gcc to compile the kernel not portage e.g. in the manual approach
here:
https://wiki.gentoo.org/wiki/Handbook:X ... ion/Kernel

The command

Code: Select all

make && make modules_install
and

Code: Select all

make install
are using

Code: Select all

gcc
directly
not portage and the emerge command etc.....

But the suggestion you made about genkernel is interesting.

Presumably I could do a manual configuration (if needed) and compilation of the new kernel using current approach (but also making use of the EXTRAVERSION setting)
and then run genkernel not to compile the kernel but to take the new manually compiled kernel binary and make a debian linux-image .deb file out of it.

That would be useful.

I looked to see what the debian OS does about the initrd problem.

I found these sites:

https://kernel-team.pages.debian.net/ke ... ramfs.html

https://wiki.debian.org/Initrd

It seems to suggest that the initrd set up is created by the OS after the kernel is installed.

If you have problems you can possibly cure them by running this command in debian after installing the
new kernel image:

Code: Select all

# dpkg-reconfigure linux-image
But perhaps relying on debian to fix this problem after creating the new kernel image
is a bit clunky; we would do better to fix the initrd problem in gentoo somehow before
moving the image file to the debian install.

Comments appreciated.

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Sun May 19, 2019 3:46 pm

mikefot,

Don't even think about genkernel, except maybe for the initrd.
Turning the initrd into a deb is left as an exercise for the reader :)

For the kernel and modules, try

Code: Select all

make bindeb-pkg
or even

Code: Select all

make deb-pkg
It will build the kernel using the .config at the top of the kernel tree and spit out your debs.

The make targets in the kernel are kernel tools, not Gentoo tools.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Mon May 20, 2019 9:45 am

Many thanks again.

I tried to obtain the latest kernel here:

https://packages.gentoo.org/packages/sy ... oo-sources

I did the following:

Code: Select all

root@storm /home/mikef/Downloads # emerge =sys-kernel/gentoo-sources-5.1.3
Calculating dependencies... done!

emerge: there are no ebuilds to satisfy "=sys-kernel/gentoo-sources-5.1.3"
Here is the current available kernel:

Code: Select all

root@storm /home/mikef/Downloads # eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.19.27-gentoo-r1 *
My internet connection is working OK.

Am I making some simple mistake here?

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Mon May 20, 2019 9:53 am

mikefot,

You want the latest testing kernel. Only the LTS kernels ever go stable on Gentoo and 4.19 is the newest stable series.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Mon May 20, 2019 10:24 am

Many thanks again.

I created a file in

Code: Select all

/etc/portage/package.accept_keywords
called testing-kernels.

I put the name of the package I wanted to be able to use in testing mode and the testing flag for amd64 gentoo into it:.

Code: Select all

root@storm /etc/portage/package.accept_keywords # more testing-kernels
sys-kernel/gentoo-sources ~amd64
I updated the source profile

and ran

Code: Select all

emerge =sys-kernel/gentoo-sources-5.1.3
Calculating dependencies... done!

emerge: there are no ebuilds to satisfy "=sys-kernel/gentoo-sources-5.1.3
and got the same error again.

What am I doing wrong here?

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Mon May 20, 2019 2:48 pm

mikefot,

That should work. Do you need to

Code: Select all

emerge --sync
Check if you have the gentoo-sources-5.1.3 ebuild
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Tue May 21, 2019 10:48 am

Many thanks again.

I ran

Code: Select all

emaint -a sync
and did a world update.

I now have the 5.1.3 kernel.

Before I obtained the 5.1.3 kernel I compiled the newest gentoo stable kernel:

Code: Select all

4.19.27-gentoo-r1
When I booted into it, I got an error message about

Code: Select all

interface eth0 
not existing etc.

It was not caused by me forgetting to run

Code: Select all

rc-update add net.eth0 default.
I think it is because I need to add an extra kernel setting to include the network card setup in kernel itself
and not in a separate module etc.

The output from

Code: Select all

dmesg 
is here:

http://dpaste.com/1CAMD65

The kernel config file I used is here:

http://dpaste.com/063ZQ9R

I plan to install the 5.1.3 kernel in gentoo itself first and fix the network card problem.

Once I can see it is running properly, then I will recompile it with the

Code: Select all

EXTRAVERSION 
parameter set to

Code: Select all

-debian
cf

Code: Select all

-gentoo
etc.

If I can make a sensible .deb file out of it I will then copy it over to debian and see if it runs OK there too.

Regards

MF

PS

The output of lspci is

Code: Select all

root@storm /home/mikef/Downloads # lspci
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) I/O Memory Management Unit
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri [Radeon R7 Graphics]
00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Kaveri HDMI/DP Audio Controller
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Port
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Port
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Port
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Port
00:10.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 09)
00:10.1 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 09)
00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 40)
00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI Controller (rev 11)
00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI Controller (rev 11)
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 16)
00:14.1 IDE interface: Advanced Micro Devices, Inc. [AMD] FCH IDE Controller
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia Controller (rev 01)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 11)
00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] FCH PCI Bridge (rev 40)
00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI Controller (rev 11)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 3
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 5
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
root@storm /home/mikef/Downloads #

PPS

I ran the ethtool check:

Code: Select all

root@storm /home/mikef/Downloads # ethtool eth0
Settings for eth0:
Cannot get device settings: No such device
Cannot get wake-on-lan settings: No such device
Cannot get message level: No such device
Cannot get link status: No such device
No data available
root@storm /home/mikef/Downloads #
I need to fix this.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue May 21, 2019 6:30 pm

mikefot,

Code: Select all

01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06) 
That's r8169 to the kernel.

You are suffering from persistent device renaming.

Code: Select all

[    8.292674] libphy: r8169: probed
[    8.293084] r8169 0000:01:00.0 eth0: RTL8168evl/8111evl, 74:d4:35:b2:0d:2c, XID 2c900800, IRQ 31
[    8.293087] r8169 0000:01:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
[    8.331338] r8169 0000:01:00.0 enp1s0: renamed from eth0
As soon as eth0 appeared udev ripped its head off , so no operations on eth0 work.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Wed May 22, 2019 2:34 pm

Many thanks again.

I reran the kernel compilation with the 5.1.3 kernel.

I think I have turned on the r8169 network flag on with a star so it should be built in etc.

But it still doesn't find the eth0 device and the internet connection has to be set up manually by running dhcpcd.

I looked at the networking section of the kernel entries and noticed that ipv6 is set to M.

Should it be not set to star (*)?

Could that be a problem?

My latest config file is here:

http://dpaste.com/2FMHKN3

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Wed May 22, 2019 10:34 pm

mikefot,

You don't have an eth0.

Look at

Code: Select all

ifconfig -a
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Tony0945
Watchman
Watchman
Posts: 5127
Joined: Tue Jul 25, 2006 12:19 am
Location: Illinois, USA

  • Quote

Post by Tony0945 » Wed May 22, 2019 11:28 pm

Mikefot, if you want eth0 you have to pass net.ifnames=0 to the kernel as it boots.

An example from /boot/grub/grub.conf (grub legacy)

Code: Select all

title=Gentoo LongTerm (4.14.90-gentoo)
root (hd0,0)
kernel /boot/vmlinuz-4.14.90-gentoo  root=/dev/sda3 vga=0x365 net.ifnames=0
The net.ifnames=0 is the part you have to duplicate.

And on reFind from /boot/refind_linux.conf

Code: Select all

"Boot by PARTUUID"   "root=PARTUUID=54fee329-ff75-4879-bdbb-93268b470f32 vga=0x365 net.ifnames=0  "
"Boot by /dev/sdXn"  "root=/dev/sda2 vga=0x365 net.ifnames=0" 
Again the relevant part is ifnames=0.

A third way is in 'make menuconfig' set

Code: Select all

CONFIG_CMDLINE="root=/dev/sda2 vga=0x365 net.ifnames=0"
with the usual caveat. In all three examples you can do a partial parameter set and add more parameters with another method. For example just set CONFIG_CMDLINE=" net.ifnames=0" and set root and vga in grub.conf or vice versa.

These are actual examples from my systems. I only boot with grub legacy or reFind. I would imagine that grub2 would be similar but I can't verify that.

If you are sure you always have just one ethernet device, I suggest using the kernel CONFIG_CMDLINE. If you think you might add another sometime, use your boot manager's facilities. Many people just take the line of least resistance and just use net.enp1so or whatever instead of net.eth0, but I'm a traditionalist and a stubborn cuss.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Thu May 23, 2019 10:45 am

Many thanks for the advice.

I used the CMDLINE= option in the kernel and it worked.

Eth0 runs on booting.

I am now trying to get the sound working.

I thought I had set everything correctly but I am not getting any sound on a youtube video I am running.

I ran the alsa command:

Code: Select all

root@storm /home/mikef # aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
hdmi:CARD=HDMI,DEV=0
    HDA ATI HDMI, HDMI 0
    HDMI Audio Output
usbstream:CARD=HDMI
    HDA ATI HDMI
    USB Stream Output
default:CARD=Generic
    HD-Audio Generic, ALC887-VD Analog
    Default Audio Device
sysdefault:CARD=Generic
    HD-Audio Generic, ALC887-VD Analog
    Default Audio Device
front:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    Front speakers
surround21:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Generic,DEV=0
    HD-Audio Generic, ALC887-VD Digital
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=Generic
    HD-Audio Generic
    USB Stream Output
root@storm /home/mikef #
I do not have a .asound local file:

Code: Select all

root@storm /home/mikef # more ~/.asoundrc
more: stat of /root/.asoundrc failed: No such file or directory
Comments appreciated

Regards

MF


PS

The video sound is now working.

I insatlled

Code: Select all

mediaplugs/alsa-plugins 
and

Code: Select all

media-video/mplayer
.

This has helped.

Cheers

PPS

The speaker test doesn't work however:

Code: Select all

root@storm /home/mikef # !493
speaker-test -Dsurroundaudio -c 6

speaker-test 1.1.8

Playback device is surroundaudio
Stream parameters are 48000Hz, S16_LE, 6 channels
Using 16 octaves of pink noise
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.8/work/alsa-lib-1.1.8/src/pcm/pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM surroundaudio
Playback open error: -2,No such file or directory
root@storm /home/mikef #
PPPS

If I would try the debian kernel compilation then presumably as was suggested by NS in an earlier post I should do in the

Code: Select all

/usr/src/linux
directory and then edit the

Code: Select all

Makefile
that lives in it.

I would create a new version with the

Code: Select all

EXTRAVERSION
parameter set to

Code: Select all

 -debian
.

When the kernel has been compiled and installed I assume that it will be parked in /boot.

Is that correct?

If so, then if I would

Code: Select all

 cd
into the boot area then I could run

Code: Select all

make .deb
and then the

Code: Select all

 linux-image deb
file should be created.

Then I can copy it over to the debian install and test it.

Comments appreciated.

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Thu May 23, 2019 6:44 pm

mikefot,

To preserve your sanity make a copy of the kernel tree. Don't point /usr/src/linux at it. That will make your head hurt later.
cd to this new kernel tree.
Edit the EXTRAVERSION
Configure it as you will
Build it with

Code: Select all

make -jX  deb-pkg 
X is the number of threads to use for the build

When its done, you should have two .deb packages. One is the sources and one the binary.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Fri May 24, 2019 9:08 am

Many thanks for the advice again.

I have looked up the command for copying an entire directory on google.

I found a discussion here that seemed helpful:

https://askubuntu.com/questions/86822/h ... nt-directo

Should I use the command

Code: Select all

cp -a /source/. /dest/
it recommends or should I use the

Code: Select all

copy -r
type command instead?

The discussion says that the

Code: Select all

cp -a
command preserves symlinks etc.

But your last post suggests that I don't want to be creating or keeping old symlinks with this kernel tree copy.

Hence I am asking about the

Code: Select all

 cp -r 
command alternative.

I am thinking to run a command like this:

Code: Select all

cp -a /usr/src/linux/ . /usr/src/temp-kernel-tree
and if the debian kernel compilation works then I could in theory delete
the temp-kernel-tree directory after I have successfully installed and tested
the new kernel in debian.

Or I could overwrite the entire temp-kernel-tree directory with a new copy
of the gentoo kernel tree directory after e.g. I installed a newer kernel in the
future that I wanted to use in both gentoo and debian etc.

Comments appreciated.

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Fri May 24, 2019 8:12 pm

mikefot,

Code: Select all

$ cp --help
is worth a read.

For the kernel, cp -a and cp -r both work.

Be careful with your spaces.

Code: Select all

cp -a /usr/src/linux/ . /usr/src/temp-kernel-tree
That command will recursively copy /usr/src/linux/ and recursively copy the current directory, the single dot, into /usr/src/temp-kernel-tree
You won't like the result anyway.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Hu
Administrator
Administrator
Posts: 24400
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Sat May 25, 2019 12:32 am

If you would prefer not to copy the kernel tree, there are ways to build multiple kernels from a single tree by setting certain environment variables ($KBUILD_OUTPUT, $INSTALL_PATH, $INSTALL_MOD_PATH). Copying is simpler though.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sat May 25, 2019 2:20 pm

Many thanks for the help again.

I found an old thread in this area:

viewtopic-t-850681-start-0.html

In it a script was put forward by Hu:

Code: Select all

#!/bin/bash

TDIR="$1"; shift
if [ -z "${TDIR}" ]; then
   TDIR="$(uname -r)"
   echo 'No release specified.  Defaulting to '"\"$TDIR\""'.'
fi

TKERN="${TDIR/*_}"
BDIR="$HOME"/kernel/
KSRC="${1:-/usr/src/linux-"${TKERN}"}"; shift

export KBUILD_OUTPUT="${BDIR}${TDIR}/"
export INSTALL_PATH="${BDIR}install/${TDIR}/boot/"
export INSTALL_MOD_PATH="${BDIR}install/${TDIR}/"

if [ ! -d "$KSRC" ]; then
   echo 'Directory '"$KSRC"' does not exist.' >&2
   exit 1
fi

for a in "$KBUILD_OUTPUT" "$INSTALL_PATH"; do
   if [ ! -d "$a" ]; then
      mkdir -p "$a" || exit $?
      echo "Created $a"
   fi
done

echo KBUILD_OUTPUT="${KBUILD_OUTPUT}"
echo INSTALL_PATH="${INSTALL_PATH}"
echo INSTALL_MOD_PATH="${INSTALL_MOD_PATH}"

cd "$KSRC"
exec /bin/bash
The script assumes that the directory that contains the kernel source would be named /usr/src/linux-gentoo-5.1.3 or something like that.

The script file would be named setup-build.sh. It would be run like this: ./setup-build.sh gentoo-5.1.3 etc.

But in my case I have not named the kernel source directory in that way. It is simply called /usr/src/linux even though it contains the source for the 5.1.3 kernel......

The script checks to see if there is a release number ie

Code: Select all

gentoo-5.1.3-r1
etc. If it does not find any release number it then runs the uname -r command to get the current installed kernel and then uses that.

ie

Code: Select all

root@storm /usr/src/linux # uname -r
5.1.3-gentoo
I need to modify it so that it doesn't look for an extension of the kernel directory using the kernel name and number, but it lilkely would use a kernel name+number specified as an argument that would be written to the newly compiled kernel.

Comments appreciated.

Regards

MF
Top
Hu
Administrator
Administrator
Posts: 24400
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Sat May 25, 2019 5:27 pm

Portage installs the source under a version-qualified path, then maintains a symlink pointing the unqualified name to the one of the qualified names. The automatic qualification should do the right thing when you want the source for the current kernel, and can be overridden to pick a different version if you want to work on sources for an upcoming kernel. If you don't want the default, remove the [ -z "${TDIR}" ] block.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sun May 26, 2019 1:25 pm

Many thanks for your help again.

If I understand you correctly, the script is not looking for a modified directory name, it still uses plain old

Code: Select all

 /usr/src/linux
etc.

The

Code: Select all

-gentoo-5.1.3
extension is part of the symlink/kernel name+number assignation system not the kernel tree directory structure etc.

Or something like that.

In that case, the script looks pretty good as it is to me.

So, to recap then, I will log in to the gentoo install create a file called

Code: Select all

setup-build.sh
.

I would then put the script code in to it. The file could be kept in my user home directory (is that correct?).

I would run the script as follows

Code: Select all

./setup-build.sh gentoo-5.1.3
.

Then I would edit the

Code: Select all

Makefile
in the kernel source directory and modify
the

Code: Select all

EXTRAVERSION
parameter in it.

It would be set to

Code: Select all

-debian
not

Code: Select all

-gentoo
as it as present.

I would then run

Code: Select all

make -j5  deb-pkg
and the new kernel will be put in my
user directory in a sub directory called

Code: Select all

 /kernel
(Please correct me if I am wrong here).

The kernel name+number within it ought to be

Code: Select all

debian-5.1.3
not

Code: Select all

gentoo-5.1.3


Comments appreciated.

Regards

MF
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Sun May 26, 2019 4:06 pm

mikefot,

Experiment is the spice of life.
Do it and tells us all about it.

If your Gentoo is converted to a complete debian install, you may have made a typo. :)
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sun May 26, 2019 4:28 pm

Many thanks for the encouragement.

I booted up the gentoo install and created the

Code: Select all

setup-build.sh
(including chmod +x) script and ran:

Code: Select all

root@storm /home/mikef # ./setup-build.sh gentoo-5.1.3
Directory /usr/src/linux-gentoo-5.1.3 does not exist.
root@storm /home/mikef # pwd
/home/mikef
Comments appreciated.

Regards

MF

PS No new

Code: Select all

 /kernel 
directory has been created in my user home directory.

It seems as if it is looking for a real directory name not a symlink........
Top
Hu
Administrator
Administrator
Posts: 24400
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Sun May 26, 2019 4:43 pm

mikefot wrote:If I understand you correctly, the script is not looking for a modified directory name, it still uses plain old

Code: Select all

 /usr/src/linux
etc.
Not exactly. It uses a qualified directory name. It never looks at the bare /usr/src/linux. It's your choice whether to let it guess the qualified name or to specify one explicitly.
mikefot wrote:The

Code: Select all

-gentoo-5.1.3
extension is part of the symlink/kernel name+number assignation system not the kernel tree directory structure etc.
Portage assigns that suffix to the name of the directory containing the kernel source. The symlink is there to let you ignore that detail.
mikefot wrote:I would then put the script code in to it. The file could be kept in my user home directory (is that correct?).
Yes.
mikefot wrote:I would run the script as follows

Code: Select all

./setup-build.sh gentoo-5.1.3
.
Yes.
mikefot wrote:Then I would edit the

Code: Select all

Makefile
in the kernel source directory and modify
the

Code: Select all

EXTRAVERSION
parameter in it.
Instead of editing the Makefile, you could configure a localversion suffix in make menuconfig.
mikefot wrote:I would then run

Code: Select all

make -j5  deb-pkg
I don't know, but that seems reasonable.
mikefot wrote:and the new kernel will be put in my
user directory in a sub directory called

Code: Select all

 /kernel
(Please correct me if I am wrong here).
I believe so. You can edit the wrapper script if you prefer some other location.
mikefot wrote:

Code: Select all

root@storm /home/mikef # ./setup-build.sh gentoo-5.1.3
Directory /usr/src/linux-gentoo-5.1.3 does not exist.
root@storm /home/mikef # pwd
/home/mikef
What is the output of ls -la /usr/src/?
mikefot wrote: PS No new

Code: Select all

 /kernel 
directory has been created in my user home directory.
Per the script, that happens after it verifies you have a valid kernel source directory. In your case, it didn't find a kernel directory, so it exited early. Also, note that if you run the script as root, $HOME likely refers to root's home directory. Part of the point of this script is to let you build without being root.
Top
mikefot
l33t
l33t
Posts: 709
Joined: Wed Nov 19, 2014 5:34 pm

  • Quote

Post by mikefot » Sun May 26, 2019 5:00 pm

Many thanks for your helpful advice.

I tried running the script with no argument.

Here is the result:

Code: Select all

root@storm /home/mikef # ./setup-build.sh
No release specified.  Defaulting to "5.1.3-gentoo".
Created /root/kernel/5.1.3-gentoo/
Created /root/kernel/install/5.1.3-gentoo/boot/
KBUILD_OUTPUT=/root/kernel/5.1.3-gentoo/
INSTALL_PATH=/root/kernel/install/5.1.3-gentoo/boot/
INSTALL_MOD_PATH=/root/kernel/install/5.1.3-gentoo/
root@storm /usr/src/linux-5.1.3-gentoo #
I thought it would use the kernel name it got from

Code: Select all

uname -r
and then moan that

Code: Select all

/usr/src/linux-5.1.3-gentoo 
does not exist.






But it didn't do that. It really is sniffing out symlinks and kernel id's etc as you said........

It has moved me into the

Code: Select all

/usr/src/linux-5.1.3-gentoo 
directory (has it renamed the

Code: Select all

/usrsrc/linux 
to

Code: Select all

/usr/src/linux-5.1.3 
?).

The kernel tree is there.

I am going to try compiling the kernel.

Regards

MF



PS

I ran the following command after setting the EXTRAVERSION parameter in Makefile to -debian:

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # make -j5 deb-pkg
make[1]: Entering directory '/root/kernel/5.1.3-gentoo'
Error: kernelrelease not valid - run 'make prepare' to update it
  UPD     include/config/kernel.release
make clean
make[3]: *** No rule to make target 'clean'.  Stop.
make[2]: *** [/usr/src/linux-5.1.3-gentoo/scripts/package/Makefile:70: deb-pkg] Error 2
make[1]: *** [/usr/src/linux-5.1.3-gentoo/Makefile:1396: deb-pkg] Error 2
make[1]: Leaving directory '/root/kernel/5.1.3-gentoo'
make: *** [Makefile:169: sub-make] Error 2
root@storm /usr/src/linux-5.1.3-gentoo #
Should I run make prepare as it says?

Comments appreciated.

PS

I booted into the gentoo install again and went into the /usr/src directory.

Sure enough some new directories have been created:

Code: Select all

drwxr-xr-x  4 root root      4096 May 27 11:12 .
drwxr-xr-x 13 root root      4096 Apr 27 13:42 ..
-rw-r--r--  1 root root         0 Apr 24 22:52 .keep
lrwxrwxrwx  1 root root        18 May 22 16:09 linux -> linux-5.1.3-gentoo
drwxr-xr-x 23 root root      4096 May 20 23:35 linux-4.19.27-gentoo-r1
-rw-r--r--  1 root root 170330757 May 27 11:12 linux-5.1.3-debian_.orig.tar.gz
drwxr-xr-x 26 root root      4096 May 27 11:12 linux-5.1.3-gentoo
root@storm /usr/src #
I ran the compilation command again:

make -j5 deb-pkg

Unfortunately I don't have the output from the first time I ran it. The compilation itself seemed to run OKish but there were problems with making the debian package.

I ran the command again here:

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # !515
make -j5 deb-pkg
make clean
/bin/sh ./scripts/package/mkdebian
Using default distribution of 'unstable' in the changelog
Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly
  TAR     linux-5.1.3-debian.tar.gz
origversion=$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$//');\
	mv linux-5.1.3-debian.tar.gz ../linux-5.1.3-debian_${origversion}.orig.tar.gz
/bin/sh: dpkg-parsechangelog: command not found
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -i.git -us -uc
/bin/sh: dpkg-buildpackage: command not found
make[1]: *** [scripts/package/Makefile:74: deb-pkg] Error 127
make: *** [Makefile:1396: deb-pkg] Error 2
root@storm /usr/src/linux-5.1.3-gentoo #
I looked in the newly created

Code: Select all

/root/kernel 
directory.

Code: Select all

root@storm ~/kernel/5.1.3-gentoo/include/config # ls -la
total 12
drwxr-xr-x 2 root root 4096 May 26 19:01 .
drwxr-xr-x 3 root root 4096 May 26 19:01 ..
-rw-r--r-- 1 root root   13 May 26 19:01 kernel.release
The kernel release is given here:

Code: Select all

root@storm ~/kernel/5.1.3-gentoo/include/config # more kernel.release
5.1.3-debian
root@storm ~/kernel/5.1.3-gentoo/include/config #
There is also another directory present that has been created that currently is empty:

Code: Select all

root@storm ~/kernel/5.1.3-gentoo/scripts/package # ls -l
total 0
root@storm ~/kernel/5.1.3-gentoo/scripts/package #
This file sitting in /usr/src seems to have been created by the kernel compilation:

Code: Select all

-rw-r--r--  1 root root 170330757 May 27 11:12 linux-5.1.3-debian_.orig.tar.gz
Could it be a new kernel?

Comments apprecaited.

Regards

MF

PPS

I also tried running the make bindeb-pkg command:

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # make -j5 bindeb-pkg
/bin/sh ./scripts/package/mkdebian
Using default distribution of 'unstable' in the changelog
Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -b -nc -uc
/bin/sh: dpkg-buildpackage: command not found
make[1]: *** [scripts/package/Makefile:79: bindeb-pkg] Error 127




make: *** [Makefile:1396: bindeb-pkg] Error 2
root@storm /usr/src/linux-5.1.3-gentoo #

It also fails.

The error here:

Code: Select all

dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -i.git -us -uc
/bin/sh: dpkg-buildpackage: command not found

could be caused by a package that needs to be installed in gentoo:



see discussion here:

viewtopic-t-26266-start-0.html

There seem to be a couple of relevant packages:

Code: Select all

sys-apps/fakeroot
and

Code: Select all

 sys-apps/fakeroot-ng
I will check to see if either is installed.

Apparently

Code: Select all

sys-apps/fakeroot 
is not installed.

I have emerged it.

I reran the two make commands.

Unfortunately they both gave the identical set of error messages.


I also tried emerging

Code: Select all

app-arch/dpkg:
But it didn't solve the problem.

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # !487
make -j5 bindeb-pkg
/bin/sh ./scripts/package/mkdebian
Using default distribution of 'unstable' in the changelog
Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -b -nc -uc
dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-buildpackage: info: source package linux-5.1.3-debian
dpkg-buildpackage: info: source version 5.1.3-debian-3
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by root <root@storm>
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build linux-5.1.3-gentoo
dpkg-checkbuilddeps: error: cannot open /var/lib/dpkg/status: No such file or directory
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
make[1]: *** [scripts/package/Makefile:79: bindeb-pkg] Error 3
make: *** [Makefile:1396: bindeb-pkg] Error 2
and

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # !499
make -j5 deb-pkg
make clean
/bin/sh ./scripts/package/mkdebian
Using default distribution of 'unstable' in the changelog
Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly
  TAR     linux-5.1.3-debian.tar.gz
origversion=$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$//');\
	mv linux-5.1.3-debian.tar.gz ../linux-5.1.3-debian_${origversion}.orig.tar.gz
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -i.git -us -uc
dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-buildpackage: info: source package linux-5.1.3-debian
dpkg-buildpackage: info: source version 5.1.3-debian-3
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by root <root@storm>
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable
dpkg-buildpackage: info: host architecture amd64
 dpkg-source -i.git --before-build linux-5.1.3-gentoo
dpkg-checkbuilddeps: error: cannot open /var/lib/dpkg/status: No such file or directory
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
make[1]: *** [scripts/package/Makefile:74: deb-pkg] Error 3
make: *** [Makefile:1396: deb-pkg] Error 2

Comments appreciated

PPS

I ran make -j5 alone.

The compilation seemed to run OK.

The last bit of the output is here:

Code: Select all

LD [M]  net/ipv6/xfrm6_mode_tunnel.ko
  LD [M]  net/netfilter/ipset/ip_set.ko
  LD [M]  net/netfilter/ipvs/ip_vs.ko
  LD [M]  net/netfilter/nf_log_common.ko
  LD [M]  net/netfilter/nf_nat.ko
  LD [M]  net/netfilter/nf_nat_ftp.ko
  LD [M]  net/netfilter/nf_nat_irc.ko
  LD [M]  net/netfilter/xt_LOG.ko
  LD [M]  net/netfilter/nf_nat_sip.ko
  LD [M]  net/netfilter/xt_TCPMSS.ko
  LD [M]  net/netfilter/xt_comment.ko
  LD [M]  net/netfilter/xt_addrtype.ko
  LD [M]  net/netfilter/xt_hl.ko
  LD [M]  net/netfilter/xt_limit.ko
  LD [M]  net/netfilter/xt_mark.ko
  LD [M]  net/netfilter/xt_multiport.ko
  LD [M]  net/netfilter/xt_nat.ko
  LD [M]  net/netfilter/xt_recent.ko
  LD [M]  net/xfrm/xfrm_ipcomp.ko
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS      arch/x86/boot/compressed/piggy.o
  LD      arch/x86/boot/compressed/vmlinux
ld: arch/x86/boot/compressed/head_64.o: warning: relocation in read-only section `.head.text'
ld: warning: creating a DT_TEXTREL in object
  ZOFFSET arch/x86/boot/zoffset.h
  OBJCOPY arch/x86/boot/vmlinux.bin
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Setup is 16028 bytes (padded to 16384 bytes).
System is 10049 kB
CRC e1f71926
Kernel: arch/x86/boot/bzImage is ready  (#4)
root@storm /usr/src/linux-5.1.3-gentoo #
I am going to try running make-deb separately and see what happens.

I am also investigating the electron-builder package.

MF

PPPS

Unfortunately it is still generating the same errors:

Code: Select all

root@storm /usr/src/linux-5.1.3-gentoo # make deb-pkg
make clean
  CLEAN   .
  CLEAN   arch/x86/entry/vdso
  CLEAN   arch/x86/kernel/cpu
  CLEAN   arch/x86/kernel
  CLEAN   arch/x86/realmode/rm
  CLEAN   arch/x86/lib
  CLEAN   certs
  CLEAN   drivers/base/firmware_loader/builtin
  CLEAN   drivers/gpu/drm/radeon
  CLEAN   drivers/scsi
  CLEAN   drivers/tty/vt
  CLEAN   kernel
  CLEAN   lib
  CLEAN   net/wireless
  CLEAN   security/selinux
  CLEAN   usr
  CLEAN   arch/x86/boot/compressed
  CLEAN   arch/x86/boot
  CLEAN   arch/x86/tools
  CLEAN   .tmp_versions
/bin/sh ./scripts/package/mkdebian
Using default distribution of 'unstable' in the changelog
Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly
  TAR     linux-5.1.3-debian.tar.gz
origversion=$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$//');\
	mv linux-5.1.3-debian.tar.gz ../linux-5.1.3-debian_${origversion}.orig.tar.gz
dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch)  -i.git -us -uc
dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-buildpackage: info: source package linux-5.1.3-debian
dpkg-buildpackage: info: source version 5.1.3-debian-4
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by root <root@storm>
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable
dpkg-buildpackage: info: host architecture amd64
 dpkg-source -i.git --before-build linux-5.1.3-gentoo
dpkg-checkbuilddeps: error: cannot open /var/lib/dpkg/status: No such file or directory
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
make[1]: *** [scripts/package/Makefile:74: deb-pkg] Error 3
make: *** [Makefile:1396: deb-pkg] Error 2
root@storm /usr/src/linux-5.1.3-gentoo # ^C
root@storm /usr/src/linux-5.1.3-gentoo #

I am going to try changing directory to arch/x86/boot and run make deb-pkg on the bzimage file

Regards

MF
Top
Post Reply

25 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic