5

Ubuntu 16.04 LTS running kernel 4.10.0-27-generic.

uname -a shows

Linux my-pc 4.10.0-27-generic #30~16.04.2-Ubuntu SMP Thu Jun 29 16:07:46 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

When I download the kernel source

apt-get source linux-image-4.10.0-27-generic

I get the message

Picking 'linux-hwe' as source package instead of 'linux-image-4.10.0-27-generic'

When I check the kernel version of the downloaded source

make kernelversion

The version is reported as

4.10.17

How do I download the actual source for the actual kernel I am currently running ?

When compiling the kernel, how do I specify the target architecture ? (amd64 for me).

hatterman
  • 2,260
  • 2
  • 21
  • 33
  • Might have figured this out. Do I simply download the latest linux-hwe source and answer "no" to all new features at configure time ? Does that acheive the same result ? – hatterman Jul 25 '17 at 10:39
  • The target architecture will by default the same as it is already in your system. – Pilot6 Jul 26 '17 at 12:11

2 Answers2

3

You downloaded the source correctly.

make kernelversion will never give you the correct Ubuntu kernel version. It outputs the mainline version.

It may be done by some command, but the easiest way is to look into debian.master/changelog.

A better way is to get sources from git. Run

git clone git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git
cd ubuntu-xenial
git checkout 6cac304f7f239ac

and you will get your 4.10.0-27 kernel source.

Pilot6
  • 88,764
  • 91
  • 205
  • 313
  • The latest entry in that change log is for 4.10.0-26.30. I am running 4.10.0-27-generic. Does that sound right ? – hatterman Jul 26 '17 at 12:07
  • It looks almost right. I think that if you download the source again, it will be 4.10.0-27. – Pilot6 Jul 26 '17 at 12:08
  • Just did an apt-get update then performed the download again. Same version is shown in the change log. – hatterman Jul 26 '17 at 12:10
  • This looks wierd. Where did you get the 4.10.0-27? Maybe proposed repo is enabled... The current hwe kernel is 4.10.0-26. – Pilot6 Jul 26 '17 at 12:13
  • Also try `sudo apt install linux-source-4.10.0`. That has 4.10.0-27 version. You can also clone the source from git and checkout whatever version you like. – Pilot6 Jul 26 '17 at 12:14
  • And also make sure you build a Debian way, not by `make` command. – Pilot6 Jul 26 '17 at 12:17
  • I do build the debian way, yes. Had a look at my sources.list file and I do have a xenial-backports entry, but no proposed entry. – hatterman Jul 26 '17 at 12:21
  • This is some repo inconsistency. I prefer to get sources from `http://kernel.ubuntu.com/git/ubuntu/ubuntu-xenial.git`. You can checkout what you want and not depend on the repos. – Pilot6 Jul 26 '17 at 12:23
  • Is there a list anywhere of the commit checksums for each kernel revision? Or is there a git command that will list the branches/tags. I'm not quite sure how you got from wanting version `4.10.0-27` to using `git checkout 6cac304f7f239ac` – Michael Firth Jul 23 '18 at 14:39
  • See http://kernel.ubuntu.com/git/ubuntu/ubuntu-xenial.git/log/?qt=range&q=6cac304f7f239ac – Pilot6 Jul 23 '18 at 16:38
2
sudo apt-get source linux-image-$(uname -r)
sudo apt-get build-dep linux-image-$(uname -r)

Also - makes sure you enable the source urls in /etc/apt/sources.list

Larry R. Irwin
  • 377
  • 3
  • 7
  • This describes the HWE kernel dev environment: https://wiki.ubuntu.com/Kernel/LTSEnablementStack – Larry R. Irwin Jul 25 '17 at 19:50
  • 1
    That won't get any sources any more. `unsigned` is needed. See https://askubuntu.com/questions/1171491/why-is-apt-source-picking-linux-signed-hwe-instead-of-a-real-kernel – Pilot6 Mar 01 '20 at 16:56