How do I download current kernel source

10,774

Solution 1

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.

Solution 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

Share:
10,774

Related videos on Youtube

hatterman
Author by

hatterman

I was first exposed to Linux around 15 years ago, the equipment I support ran on Red Hat. Nowadays it's all open SuSE. The more I learned the more I liked it and I eventually moved over from the dark side and installed Ubuntu on my home PCs about 2 years ago. I do still have Windows, I am not one to get involved in the operating system arguments, but i find I am using it less and less. I run my main PC and laptop on Ubuntu 14.04 LTS with the Gnome desktop. I run my Intel Atom based netbook on Ubuntu 14.04 LTS with the Lxde desktop. My preference these days is to install from the minimal ISO and add the desktop environment and chosen applications on top. I run my Raspberry Pi on Raspbian and use it as an 'always on' remote access port for when I am away from home. When I am connected to a random hotel wifi I ssh into my Pi and, with dynamic port forwarding, route all my traffic through it. The Pi uses around 2W, it's my best gadget of the year. I run my server on Open Media Vault using an old cube PC I salvaged from the work skip. This shuts down automatically and I wake it, as needed, with a WOL command from the Pi. I am by no means an expert but an enthusiastic amatuer. I try to provide help on here and often find my self googling around in order to answer a question. I find I am learning more myself when I try to answer questions.

Updated on September 18, 2022

Comments

  • hatterman
    hatterman over 1 year

    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).

  • Larry R. Irwin
    Larry R. Irwin almost 7 years
    This describes the HWE kernel dev environment: wiki.ubuntu.com/Kernel/LTSEnablementStack
  • hatterman
    hatterman over 6 years
    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 ?
  • Pilot6
    Pilot6 over 6 years
    It looks almost right. I think that if you download the source again, it will be 4.10.0-27.
  • hatterman
    hatterman over 6 years
    Just did an apt-get update then performed the download again. Same version is shown in the change log.
  • Pilot6
    Pilot6 over 6 years
    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
    Pilot6 over 6 years
    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
    Pilot6 over 6 years
    And also make sure you build a Debian way, not by make command.
  • hatterman
    hatterman over 6 years
    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.
  • Pilot6
    Pilot6 over 6 years
    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.
  • Michael Firth
    Michael Firth almost 6 years
    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
  • Pilot6
    Pilot6 almost 6 years
  • Pilot6
    Pilot6 about 4 years
    That won't get any sources any more. unsigned is needed. See askubuntu.com/questions/1171491/…