The officially official Devuan Forum!

You are not logged in.

#1 2020-08-19 09:10:23

Bill Evans
Member
Registered: 2020-08-06
Posts: 13  

how to install kernel source

When I install package kernel-source (which I need so I can compile downloaded drivers), I see two files:

/usr/src/linux-patch-4.19-rt.patch.xz
/usr/src/linux-source-4.19.tar.xz

When I explode the source, I guess that's the, um, source. When I explode the patch file, it doesn't look like any diff output I've ever seen, and it doesn't look like a shell script of any sort. But I imagine I'm supposed to apply it to the source tree somehow. How do I do that?

EDIT: The drivers I'm compiling seem to be looking for a file named ".config" in the kernel source tree, but I don't see such a file in the expanded source tree. What would generate a ".config" file?

Last edited by Bill Evans (2020-08-19 09:32:55)

Offline

#2 2020-08-19 10:18:25

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 976  
Website

Re: how to install kernel source

Which drivers are these? It is highly unusual to have to compile your own drivers in Linux, the kernel should already include drivers for just about everything.


Black Lives Matter

Offline

#3 2020-08-19 11:30:49

Bill Evans
Member
Registered: 2020-08-06
Posts: 13  

Re: how to install kernel source

The dahdi drivers (for Asterisk, though I don't use Asterisk itself).  I install those packages and can find the compiled drivers nowhere, having done:

find / | sort

I assume that the names of the files containing the drivers would end with ".ko".

Offline

#4 2020-08-19 11:34:50

fsmithred
Administrator
Registered: 2016-11-25
Posts: 1,619  

Re: how to install kernel source

apt install build-essential linux-headers-$(uname -r)

is what you normally need to compile anything other than a full kernel.

Offline

#5 2020-08-19 11:59:38

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 976  
Website

Re: how to install kernel source

The module-assistant package is probably the best way to set up a build environment for custom kernel modules:

# apt install module-assistant
# m-a prepare
# apt install dahdi{,-dkms}

Then reboot, ensure that the dahdi service is started and then use the various user space utilities to set things up.


Black Lives Matter

Offline

#6 2020-09-07 08:56:17

Bill Evans
Member
Registered: 2020-08-06
Posts: 13  

Re: how to install kernel source

It seems that module-assistant does the trick, but at least for me there remains a problem.

My ultimate goal is to be able to work with module source code on machines which are not connected to the Internet. Unfortunately, module-assistant requires an Internet connection. The question arises: is there a workaround?  Can I do the same thing without an Internet connection, and therefore without module-assistant?

In theory, module-assistant does only two things: install some packages; and place the appropriate symbolic link at /usr/src/linux.  The trick is to discover whether this is ALL that module-assistant does.  If so, we can get along without it, and install without access to the Internet.

So I did some before-and-after comparisons for two sequences.  The first sequence, with access to the Internet:

-- do a stock install of devuan from DVD
-- run dhclient
-- add deb http://deb.devuan.org/merged beowulf contrib main nonfree to /etc/apt/sources.list
-- in that same file, comment out the cdrom line
-- run apt-get update
-- run apt install module-assistant
-- run m-a prepare

Preparation for the second sequence:

-- download all packages installed in the previous ma-prepare

Now the second sequence, on a host without access to the Internet:

-- do a stock install of devuan from DVD
-- do NOT run dhclient
-- download from the mothership host a directory containing packages downloaded from the Internet
-- run dpkg --recursive --install that-directory
-- run

ln -s $(ls /usr/src | grep linux-headers | grep -v common) /usr/src/linux

Before-and-after comparisons were made by gathering the following data before, and then after, each sequence:

-- the names of all installed packages, found by running dpkg-query --list
-- the names of all files, basically a find / | sort
-- for each regular file less than 64k in length, the length and checksum

So, did the second sequence do as well as the first?  Yes, and actually a little better.  The only significant differences were that the second sequence created links in /etc/alternatives that the first did not (and, of course, package module-assistant itself wasn't installed).

It seems that module-assistant, when installing a package, did pretty much everything, but the output to the console looks different, as though module-assistant installed packages slightly different from how dpkg --install would. Indeed, that's so: links in /etc/alternatives are missing from the m-a prepare results.

Most importantly, m-a prepare didn't do anything other than what was advertised. So the second sequence is adequate, and solves the original "no Internet" problem.

Except:

One host of interest is older, a 32-bit machine.  I haven't tested this solution for 32 bits, but of course I will.  If I have any difficulty, I'll report it in this thread (unless the thread is closed at that point, or something).

Last edited by Bill Evans (2020-09-07 09:01:19)

Offline

Board footer