This article mainly describes how to find the corresponding kernel source code according to the currently running Ubuntu version.
First, download the corresponding kernel source code repository according to the content in the link below.
https://wiki.ubuntu.com/Kernel/Dev/KernelGitGuide
If you think the content in the link is too long, you can try the following command.
git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/$(lsb_release -cs)
This command will download the corresponding kernel code according to your current Ubuntu version.
If this command reports no error, it means everything went well, just wait for the download to complete.
After the Ubuntu kernel code is downloaded, the default is the master branch. This branch usually does not exactly correspond to the Ubuntu version we are currently running, so we have to switch branches.
First, find the exact version number of Ubuntu currently running through the following command.
➜ bionic git:(master) cat /proc/version_signature
Ubuntu 4.15.0-45.48-generic 4.15.18
Among them, the information before -generic corresponds to the tag of the Ubuntu kernel source code, but the space after Ubuntu should be replaced with a dash. For example, the tag corresponding to the output of the above command is Ubuntu-4.15.0-45.48.
Then, we enter the downloaded kernel source code directory and execute the following command to switch the source code to the version corresponding to the tag.
➜ bionic git:(master) git checkout Ubuntu-4.15.0-45.48
HEAD is now at ffdd392b8196 UBUNTU: Ubuntu-4.15.0-45.48
Well, now we have the kernel source code of the currently running Ubuntu version, and can start to read the source code and do experiments.
Get it done.
Recommended Posts