Linux kernel git clone

Where to download Linux Kernel source code of a specific version?

Is there a resource to download a specific kernel version source? For example, I want to get 2.6.36.2 sources to compare with this package and see what changes were introduced?

5 Answers 5

The easiest and most bandwidth-friendly way, if you expect to do this more than once, would be to clone the kernel’s git repository and check out the version you want based on its tag. It’s probably best to clone the linux-stable repo, since that will include tags for all of the stable releases:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git cd linux git checkout v2.6.36.2 

To later switch to another version, it’s easy:

To update your repository to include all of the latest tags and commits:

—depth and —branch can also drastically reduce the clone size: unix.stackexchange.com/a/473373/32558

Ah.. Thanks. That repository is one of hundreds of the addresses in git.kernel.org. Why should it be so difficult to find it? linux people are keeping it as a secret??

While the git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git remote still works, it appears to be deprecated, as kernel/git/stable/linux-stable.git is no longer listed on the official list of Kernel.org git repositories at git.kernel.org. It has been replaced by kernel/git/stable/linux.git instead. So, the new recommended clone command is git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git instead.

Yes, kernel.org has all released versions, including 2.6.36.2. Note, however, that most Linux distributions apply own patches to the vanilla kernel source.

If you do not want to download whole kernel commit history (which is well above 1 GiB), you can download only such part of the kernel Git repo that leads to your desired branch. E.g. to locally checkout the Ubuntu kernel in version 4.5, you’d do:

git clone --depth 1 --single-branch --branch v4.5 git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack 

This way, the clone is about 150 MiB.

If you just want to get one tag for quick compilation, do:

git clone --depth 1 --branch v4.18 \ git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 

—depth 1 does a shallow clone, which drastically reduces the clone time and disk usage.

Читайте также:  Linux chown chmod chgrp

It only works for tags currently unfortunately, not arbitrary commits, due to how the cgit git server works and is configured. See also: https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset

I’ve been struggling to figure out where and how to get the various Linux kernel branches, so I wanted to expound upon that and show where I learned it. This research also allowed me to fix and update the link in the most-upvoted answer, which I recently did.

Where and how to get the official Linux kernel source code

Quick summary

The official code location for the Linux kernel source is https://kernel.org/.

Option 1: manually download just the kernel version tar file of interest

Go here to navigate and download just your version of interest: https://mirrors.edge.kernel.org/pub/linux/kernel/.

Ex: the OP’s v2.6.32.2 is on this page here: https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/. I recommend downloading the .tar.xz version of the file, since it is the smallest: linux-2.6.36.2.tar.xz. The .sign file next to it contains the cryptographic PGP signature to verify the downloaded file’s authenticity and integrity. Read more about that here, including seeing commands to verify the signature: https://kernel.org/category/signatures.html.

It’s also really easy to download the files from the command-line. Here’s what that might look like:

# Download the file, showing a progress bar; this file is 56 MB wget https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.2.tar.xz # extract it; on a fast computer this takes ~4 sec.; the extracted # "linux-2.6.36.2" dir is ~400 MB when done time tar -xvf linux-2.6.36.2.tar.xz 
# clone the latest Stable and Longterm release tree (git repo) git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git # cd into it cd linux # view all tags, which contain the many many version numbers # - see my answer here: https://stackoverflow.com/a/69275540/4561887 git log --no-walk --tags --oneline # Once you identify the one of interest (ex: 2.6.36.2), check out the commit # with that tag git checkout v2.6.36.2 

Details

The official Linux kernel source code is at The Linux Kernel Archives at https://kernel.org/.

Choose the git repository «tree» you wish to clone:

These quotes just below are from this page: https://kernel.org/category/releases.html. I’ve also added my words in square brackets ([]).

Prepatch
Prepatch or «RC» [Release Candidate] kernels are mainline kernel pre-releases that are mostly aimed at other kernel developers and Linux enthusiasts. They must be compiled from source and usually contain new features that must be tested before they can be put into a stable release. Prepatch kernels are maintained and released by Linus Torvalds. [Their versions end in -rcX , where X is a number.]

Mainline
Mainline tree is maintained by Linus Torvalds. It’s the tree where all new features are introduced and where all the exciting new development happens. New mainline kernels are released every 9-10 weeks.

Stable
After each mainline kernel is released, it is considered «stable.» Any bug fixes for a stable kernel are backported from the mainline tree and applied by a designated stable kernel maintainer. There are usually only a few bugfix kernel releases until next mainline kernel becomes available — unless it is designated a «longterm maintenance kernel.» Stable kernel updates are released on as-needed basis, usually once a week.

Longterm
There are usually several «longterm maintenance» kernel releases provided for the purposes of backporting bugfixes for older kernel trees. Only important bugfixes are applied to such kernels and they don’t usually see very frequent releases, especially for older trees. [See a table of all of the long-term releases here: https://kernel.org/category/releases.html. Most of them are supported for up to 6 years.]

git clone URLs

Clone the repo you want. Note that if there are multiple clone URLs, any are usable, but I prefer the first one in each list below:

Читайте также:  Linux dpkg install dependencies

    For Prepatch («Release Candidate», or -rc ) and Mainline (the main working tree) releases:

# From kernel.org directly # See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git # Or, an exact mirror on GitHub # See: https://github.com/torvalds/linux git clone https://github.com/torvalds/linux 
# From kernel.org directly # See: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux.git # Note: This URL still works as of Dec. 2022, and has the exact same content # as the URLs above, but is no longer listed in the list of **all** # repos/trees here (https://git.kernel.org/), and so it appears to be # deprecated. Use the URLs above instead. git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
# From kernel.org directly # See: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next.git 

If you’re developing in the kernel or want to see the latest, you’ll probably want the Mainline git tree:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git # or on GitHub git clone https://github.com/torvalds/linux 

If you’re just trying to download a given stable or longterm release number, such as in the question (v2.6.36.2), then clone the Stable and Longterm release tree instead, and cd into it:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git cd linux # cd into the newly-cloned dir 

You can then view all version number tags (see my answer for details and more commands), and check out the one of interest:

git log --no-walk --tags --oneline git checkout v2.6.36.2 

How did I find the kernel.org git clone URLs above?

Go to the main page at https://kernel.org/ and click the «browse» links:

enter image description here

Then click the «summary» column header at the top, and look for the «Clone» links at the bottom:

Читайте также:  Форматирование дисков консоль linux

enter image description here

References

  1. https://kernel.org/category/signatures.html — I learned how to verify the PGP signatures and find the download URLs for individual tar files from this page.
  2. My answer: show all tags in git log
  3. https://linuxize.com/post/how-to-extract-unzip-tar-xz-file/

Источник

Cloning Linux from a bundle

If you find yourself on an unreliable Internet connection and need to perform a fresh clone of Linux.git, you may find it tricky to do so if your connection resets before you are able to complete the clone. There is currently no way to resume a git clone using git, but there is a neat trick you can use instead of cloning directly — using git bundle files.

Here is how you would do it.

    Start with «wget -c «, which tells wget to continue interrupted downloads. If your connection resets, just rerun the same command while in the same directory, and it will pick up where it left off:

wget -c https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle
git bundle verify clone.bundle . clone.bundle is okay
git clone clone.bundle linux
cd linux git remote remove origin git remote add origin https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git pull origin master

Once this is done, you can delete the «clone.bundle» file, unless you think you will need to perform a fresh clone again in the future.

The «clone.bundle» files are generated weekly on Sunday, so they should contain most objects you need, even during kernel merge windows when there are lots of changes committed daily.

Other resources

Social

This site is operated by the Linux Kernel Organization, Inc., a 501(c)3 nonprofit corporation, with support from the following sponsors.

Источник

Оцените статью
Adblock
detector