https://www.kernel.org/doc/html/latest/admin-guide/README.html
Docs » The Linux kernel user’s and administrator’s guide » Linux kernel release 5.x < http://kernel.org/ >
Installing the kernel source
If you install the full sources, put the kernel tarball in a directory where you have permissions (e.g. your home directory) and unpack it:
To install the full source code, place the kernel tarball in a directory you have permissions on (eg your home directory) and unpack it.
xz -cd linux-5.x.tar.xz | tar xvf -
Replace “X” with the version number of the latest kernel.
Replace "X" with the latest kernel version.
Do NOT use the /usr/src/linux area! This area has a (usually incomplete) set of kernel headers that are used by the library header files. They should match the library, and not get messed up by whatever the kernel-du-jour happens to be.
definitely! Do not use / usr / src / linux area. This area contains the (generally incomplete) kernel header and is used by the library header files. This should match the library and should not be confused by what the latest kernel is doing.
You can also upgrade between 5.x releases by patching. Patches are distributed in the xz format. To install by patching, get all the newer patch files, enter the top level directory of the kernel source (linux-5.x) and execute:
You can also upgrade with patches from 5.x release. Patch is distributed in xz format. To install patch, get the meticulous patch file and run the following in the kernel source top level directory (linux-5.x):
xz -cd ../patch-5.x.xz | patch -p1
Replace “x” for all versions bigger than the version “x” of your current source tree, in_order, and you should be ok. You may want to remove the backup files (some-file-name~ or some-file-name.orig), and make sure that there are no failed patches (some-file-name# or some-file-name.rej). If there are, either you or I have made a mistake.
Please specify all the "x" larger than the "x" version of the source code you are currently using, in order as much as you need. Files where you deleted the backup file (files are given "~" or ".orig") and failed to patch (files are given "#" or ".rej") Make sure there is no. If so, you are making a mistake in me.
Unlike patches for the 5.x kernels, patches for the 5.x.y kernels (also known as the -stable kernels) are not incremental but instead apply directly to the base 5.x kernel. For example, if your base kernel is 5.0 and you want to apply the 5.0.3 patch, you must not first apply the 5.0.1 and 5.0.2 patches. Similarly, if you are running kernel version 5.0.2 and want to jump to 5.0.3, you must first reverse the 5.0.2 patch (that is, patch -R) before applying the 5.0.3 patch. You can read more on this in Documentation/process/applying-patches.rst.
Unlike patches for the 5.x kernel, patches for the 5.x.y kernel (also known as the -stable kernel) are applied directly to the base 5.x kernel, not incrementally. For example, if the base kernel is 5.0 and you want to apply the 5.0.3 patch, do not apply the 5.0.1 and 5.0.2 patches first. Similarly, if you are running kernel version 5.0.2 and want to jump to 5.0.3, you must first revert the 5.0.2 patch (that is, patch-R) before applying the 5.0.3 patch. .. See Documentation / process / applying-patches.rst for more information on this.
Alternatively, the script patch-kernel can be used to automate this process. It determines the current kernel version and applies any patches found:
Alternatively, a patch-kernel script can be used to automate this process. Determine the current kernel version and apply the appropriate patch.
linux/scripts/patch-kernel linux
The first argument in the command above is the location of the kernel source. Patches are applied from the current directory, but an alternative directory can be specified as the second argument.
The first argument given to the command is the location of the kernel source. The patch will be applied from the current directory, but you can specify an alternate directory as the second argument.
Make sure you have no stale .o files and dependencies lying around:
Make sure there are no dependencies on the old .o file.
cd linux
make mrproper
You should now have the sources correctly installed.
The source code should now be installed correctly.
Software requirements
Compiling and running the 5.x kernels requires up-to-date versions of various software packages. Consult Documentation/process/changes.rst for the minimum version numbers required and how to get updates for these packages. Beware that using excessively old versions of these packages can cause indirect errors that are very difficult to track down, so don’t assume that you can just update packages when obvious problems arise during build or operation.
New versions of various software packages are required to compile and run the 5.x kernel. See Documentation / process / changes.rst for the minimum required versions and how to update those packages. Be aware that using very old versions of these packages can cause indirect pictorial errors that are very difficult to track. Also, it is not always possible to update a package if there is an obvious problem during build or operation.
Build directory for the kernel
When compiling the kernel, all output files will per default be stored together with the kernel source code. Using the option make O=output/dir allows you to specify an alternate place for the output files (including .config). Example:
When compiling the kernel, by default all products are stored with the kernel source code. You can also specify the file product (including .config) as a different location by specifying option make O = output / dir. For example;
cd /usr/src/linux-5.x
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install
Please note: If the O=output/dir option is used, then it must be used for all invocations of make.
Note: If you use the O = output / dir option, it must be applied to all make calls.
Configuring the kernel
Do not skip this step even if you are only upgrading one minor version. New configuration options are added in each release, and odd problems will turn up if the configuration files are not set up as expected. If you want to carry your existing configuration to a new version with minimal work, use make oldconfig, which will only ask you for the answers to new questions.
Do not skip this step, even if you give one minor version. Each release adds a new configuration option. And if the config file isn't set up as expected, weird problems occur. If you want to migrate to a newer version with the smallest configuration, use make oldconfig. This will ask for answers to new questions.
Alternative configuration commands are:
Other commands for setting are as follows.
"make config" Plain text interface.
Plain text interface.
"make menuconfig" Text based color menus, radiolists & dialogs.
Text menu with colors, radio buttons and dialogs
"make nconfig" Enhanced text based color menus.
Extended text with color menu
"make xconfig" Qt based configuration tool.
Settings menu in Qt
"make gconfig" GTK+ based configuration tool.
GTK+Setting menu in
"make oldconfig" Default all questions based on the contents of
your existing ./.config file and asking about
new config symbols.
Current./Based on the contents of the config file
A setting that inquires about all symbols in the new setting.
"make olddefconfig"
Like above, but sets new symbols to their default
values without prompting.
Similar to the above, but without confirmation about the new symbol
Apply the default value.
"make defconfig" Create a ./.config file by using the default
symbol values from either arch/$ARCH/defconfig
or arch/$ARCH/configs/${PLATFORM}_defconfig,
depending on the architecture.
,Generate a config file with default settings.
It is necessary to specify the architecture, arch/$ARCH/defconfig
Or arch/$ARCH/configs/${PLATFORM}_defconfig,
Is used.
"make ${PLATFORM}_defconfig"
Create a ./.config file by using the default
symbol values from
arch/$ARCH/configs/${PLATFORM}_defconfig.
Use "make help" to get a list of all available
platforms of your architecture.
arch/$ARCH/configs/${PLATFORM}_defconfig.Return to
.Generate a config file with default values.
Which platform is valid in the target architecure is
"make help"You can get it at.
"make allyesconfig"
Create a ./.config file by setting symbol
values to 'y' as much as possible.
Set as much as possible"y"And then.Generate a config file.
"make allmodconfig"
Create a ./.config file by setting symbol
values to 'm' as much as possible.
Set as much as possible"m"And then.Generate a config file.
"make allnoconfig" Create a ./.config file by setting symbol
values to 'n' as much as possible.
Set as much as possible"n"And then.Generate a config file.
"make randconfig" Create a ./.config file by setting symbol
values to random values.
Randomize the settings.Generate a config file.
"make localmodconfig" Create a config based on current config and
loaded modules (lsmod). Disables any module
option that is not needed for the loaded modules.
Current config and loaded modules(lsmod)On the basis of the
Others not needed for loaded module to generate config
Disable module option.
To create a localmodconfig for another machine,
store the lsmod of that machine into a file
and pass it in as a LSMOD parameter.
To create a localmodconfig on another machine
Save as lsmod generated on another machine
Please pass it as an LSMOD parameter.
target$ lsmod > /tmp/mylsmod
target$ scp /tmp/mylsmod host:/tmp
host$ make LSMOD=/tmp/mylsmod localmodconfig
The above also works when cross compiling.
It will work with cross compiling.
"make localyesconfig" Similar to localmodconfig, except it will convert
all module options to built in (=y) options.
Similar to localmodconfig, but
All converted modules are build in(=y)option is
Will be specified.
"make kvmconfig" Enable additional options for kvm guest kernel support.
Enable additional options for kvm guest kernel support.
"make xenconfig" Enable additional options for xen dom0 guest kernel
support.
dom0 Enable additional options for guest kernel support.
"make tinyconfig" Configure the tiniest possible kernel.
Set to the minimum possible setting.
You can find more information on using the Linux kernel config tools in Documentation/kbuild/kconfig.rst.
See Documentation / kbuild / kconfig.rst for more information on how to use the Linux kernel config tools.
NOTES on make config:
- Having unnecessary drivers will make the kernel bigger, and can under some circumstances lead to problems: probing for a nonexistent controller card may confuse your other controllers.
--Ownering unnecessary drivers can make your kernel huge and cause unexpected problems. It confuses other controllers by activating a controller card that does not exist. --The kernel on which the math-emuration compile is compiled will continue to be used in cases with a coprocessor, in which case math-emuration will not work. The kernel is a bit larger, but it works on a variety of machines with or without a math coprocessor. --The "kernel hacking" setting usually has the effect of making the Kernel huge, slowing it down, or both. It also reduces kernel stability (kmalloc ()) because the shoeing process actively tries to break the bad code to find kernel problems. Therefore, you should answer "n2" to the "development", "experimental", and "debugging" feature questions.
Originally, it is a part of the Linux Kernel source code, so it will be treated as GPLv2 (recognition that it should be).
https://www.kernel.org/doc/html/latest/index.html
Licensing documentation
The following describes the license of the Linux kernel source code (GPLv2), how to properly mark the license of individual files in the source tree, as well as links to the full license text.
https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing
Recommended Posts