[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howtos:slackware_admin:building_the_linux_kernel_using_git_repository [2012/09/30 09:07 (UTC)] – [What to build] htexmexh | howtos:slackware_admin:building_the_linux_kernel_using_git_repository [2014/11/26 01:08 (UTC)] (current) – Added info about VFAT and EFI partitions metaschima | ||
---|---|---|---|
Line 24: | Line 24: | ||
<code bash> | <code bash> | ||
- | version=3.4.11 | + | version=3.10.24 |
+ | base=3.10 | ||
</ | </ | ||
- | 1. You can use git to get the kernel source. This has the advantage that it will avoid issues | + | 1. You can use git to get the kernel source. This has the advantage that it will avoid issues |
<code bash> | <code bash> | ||
git clone --depth 1 git:// | git clone --depth 1 git:// | ||
cd linux-stable | cd linux-stable | ||
- | git pull # run this every time after the first run to update the source | + | git pull # run this every time to update the source |
- | git checkout v$version # you MUST checkout a kernel version or you will get the base version, i.e. 3.4.0 | + | git checkout v$version # you MUST checkout a kernel version or you will get the base version, i.e. 3.10 |
git log # just check to make sure the top of the log says the version you want | git log # just check to make sure the top of the log says the version you want | ||
git tag -v v$version # this is not necessary, but it validates the source using gpg public key, which you need to import | git tag -v v$version # this is not necessary, but it validates the source using gpg public key, which you need to import | ||
</ | </ | ||
- | < | + | < |
- | 2. You can download the source tarball from [[http:// | + | 2. You can download the source tarball from [[http:// |
<code bash> | <code bash> | ||
- | wget http:// | + | kernelsite=" |
- | unxz linux-$version.tar.xz | + | lftp -c "open $kernelsite; |
- | gpg --verify linux-$version.tar.sign | + | unxz -k "linux-$base.tar.xz" |
- | tar -xf linux-$version.tar | + | gpg --verify |
- | cd linux-$version | + | # the following is done with every new kernel update |
+ | tar -xf "linux-$base.tar.xz" | ||
+ | mv " | ||
+ | cd "linux-$version" | ||
+ | lftp -c "open $kernelsite; | ||
+ | unxz " | ||
+ | gpg --verify " | ||
+ | patch -p1 < " | ||
</ | </ | ||
+ | < | ||
+ | Patching a kernel can be confusing, because patches are relative to the base kernel version. Lets say you currently have the kernel source for 3.10.24, and you want to upgrade to 3.10.25. You can either revert the 3.10.24 patch (getting you back to 3.10), or you can download kernel version 3.10 and apply the 3.10.25 patch. If you try to apply the 3.10.25 patch over 3.10.24, it will fail. Thus, it is recommended to keep the source tarball for the base version in the kernel build directory, especially if you plan on regularly upgrading your kernel for security fixes. | ||
+ | </ | ||
+ | |||
+ | Here is a script that downloads the latest patch for the current running kernel. It assumes you already have an xz compressed tarball in the kernel build directory. | ||
+ | <file bash kernupd> | ||
+ | #!/bin/sh | ||
+ | |||
+ | error () # error | ||
+ | { | ||
+ | echo " | ||
+ | exit 1 | ||
+ | } | ||
+ | |||
+ | kerneldir=" | ||
+ | kernelsite=" | ||
+ | currentver=" | ||
+ | basever=" | ||
+ | newver=" | ||
+ | |||
+ | if test " | ||
+ | then | ||
+ | echo ' | ||
+ | else | ||
+ | echo " | ||
+ | cd " | ||
+ | tar -xf " | ||
+ | mv " | ||
+ | cd " | ||
+ | lftp -c "open $kernelsite; | ||
+ | unxz " | ||
+ | gpg --verify " | ||
+ | patch -p1 < " | ||
+ | make mrproper | ||
+ | zcat / | ||
+ | make oldconfig | ||
+ | echo "cd $PWD" | ||
+ | fi | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
==== How to build ==== | ==== How to build ==== | ||
First run the following to make sure everything is setup properly for a build. | First run the following to make sure everything is setup properly for a build. | ||
Line 60: | Line 109: | ||
<file txt README> | <file txt README> | ||
- | | + | |
- | "make config" | + | |
- | "make menuconfig" | + | "make config" |
- | "make nconfig" | + | |
- | "make xconfig" | + | "make menuconfig" |
- | "make gconfig" | + | |
- | "make oldconfig" | + | "make nconfig" |
- | your existing ./.config file and asking about | + | |
- | new config symbols. | + | "make xconfig" |
- | "make silentoldconfig" | + | |
- | Like above, but avoids cluttering the screen | + | "make gconfig" |
- | with questions already answered. | + | |
- | Additionally updates the dependencies. | + | "make oldconfig" |
- | "make defconfig" | + | your existing ./.config file and asking about |
- | symbol values from either arch/ | + | new config symbols. |
- | or arch/ | + | |
- | depending on the architecture. | + | "make silentoldconfig" |
- | "make ${PLATFORM}_defconfig" | + | Like above, but avoids cluttering the screen |
- | | + | with questions already answered. |
- | | + | Additionally updates the dependencies. |
- | | + | |
- | | + | " |
- | | + | Like above, but sets new symbols to their default |
- | "make allyesconfig" | + | values without prompting. |
- | Create a ./.config file by setting symbol | + | |
- | values to ' | + | "make defconfig" |
- | "make allmodconfig" | + | symbol values from either arch/ |
- | Create a ./.config file by setting symbol | + | or arch/ |
- | values to ' | + | depending on the architecture. |
- | "make allnoconfig" | + | |
- | values to ' | + | "make ${PLATFORM}_defconfig" |
- | "make randconfig" | + | Create a ./.config file by using the default |
- | values to random values. | + | symbol values from |
+ | arch/ | ||
+ | Use "make help" to get a list of all available | ||
+ | platforms of your architecture. | ||
+ | |||
+ | "make allyesconfig" | ||
+ | Create a ./.config file by setting symbol | ||
+ | values to ' | ||
+ | |||
+ | "make allmodconfig" | ||
+ | Create a ./.config file by setting symbol | ||
+ | values to ' | ||
+ | |||
+ | "make allnoconfig" | ||
+ | values to ' | ||
+ | |||
+ | "make randconfig" | ||
+ | values to random values. | ||
+ | |||
+ | " | ||
+ | | ||
+ | | ||
+ | |||
+ | To create a localmodconfig for another machine, | ||
+ | store the lsmod of that machine into a file | ||
+ | and pass it in as a LSMOD parameter. | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | host$ make LSMOD=/ | ||
+ | |||
+ | The above also works when cross compiling. | ||
+ | |||
+ | " | ||
+ | all module options to built in (=y) options. | ||
You can find more information on using the Linux kernel config tools | You can find more information on using the Linux kernel config tools | ||
Line 114: | Line 198: | ||
This option lets you add a string to the end of the kernel version, in case you want to install more that one kernel of the same version. | This option lets you add a string to the end of the kernel version, in case you want to install more that one kernel of the same version. | ||
>> Kernel compression mode | >> Kernel compression mode | ||
- | This lets you select the kernel compression mode. Gzip is the good default choice. Higher compression (LZMA/XZ) requires more RAM and processor usage, but is faster to load from disk to RAM. Lower compression (Gzip/LZO) requires less RAM and processor usage, but is slower to load from disk to RAM. | + | This lets you select the kernel compression mode. LZMA is the good default choice. Higher compression (LZMA/XZ) requires more RAM and processor usage, but is faster to load from disk to RAM. Lower compression (Gzip/LZO) requires less RAM and processor usage, but is slower to load from disk to RAM. |
+ | >> Kernel .config support | ||
+ | >>> | ||
+ | Make sure to enable this so you can have easy access to your current kernel config at / | ||
>> Automatic process group scheduling | >> Automatic process group scheduling | ||
This option can greatly improve the performance of responsiveness of multi-threaded machines. So you can run '' | This option can greatly improve the performance of responsiveness of multi-threaded machines. So you can run '' | ||
Line 124: | Line 211: | ||
Can increase kernel performance. | Can increase kernel performance. | ||
> **Enable the block layer** | > **Enable the block layer** | ||
+ | >> Partition Types ---> | ||
+ | >>> | ||
+ | Enable this if you plan on using the new GPT partition scheme and want to boot from UEFI. | ||
>> IO Schedulers ---> | >> IO Schedulers ---> | ||
>>> | >>> | ||
Line 139: | Line 229: | ||
</ | </ | ||
> **Processor type and features** | > **Processor type and features** | ||
- | >> Tickless System (Dynamic Ticks) | ||
- | This causes timer interrupts to only trigger on an as-needed basis both when the system is busy and idle. | ||
>> Symmetric multi-processing support | >> Symmetric multi-processing support | ||
This should be enabled for multi-core and multi-processor machines. | This should be enabled for multi-core and multi-processor machines. | ||
+ | >> Intel Low Power Subsystem Support | ||
+ | Enable if you have a newer system with Intel Lynxpoint PCH. Check the output of '' | ||
>> Processor family | >> Processor family | ||
For maximum performance you should choose the right processor family. | For maximum performance you should choose the right processor family. | ||
Line 150: | Line 240: | ||
cat / | cat / | ||
</ | </ | ||
- | If you still cannot tell what processor family to choose, then look up the '' | + | If you still cannot tell what processor family to choose, then look up the '' |
</ | </ | ||
>> Maximum number of CPUs | >> Maximum number of CPUs | ||
Line 186: | Line 276: | ||
1 to enable it | 1 to enable it | ||
>>> | >>> | ||
- | This is the number of unused/ | + | This is the number of disabled/unused/ |
< | < | ||
As an example, run '' | As an example, run '' | ||
Line 199: | Line 289: | ||
6 disabled | 6 disabled | ||
</ | </ | ||
- | Here, registers 3,4,5,6 are unused, so MTRR cleanup spare reg num = 4 total unused registers. | + | Here, registers 3,4,5,6 are disabled/unused/spare, so MTRR cleanup spare reg num = 4 total unused registers. |
</ | </ | ||
+ | >> EFI runtime service support | ||
+ | Enable if you want to boot from UEFI. | ||
+ | >>> | ||
+ | Enable if you want to boot from UEFI. | ||
>> Enable -fstack-protector buffer overflow detection | >> Enable -fstack-protector buffer overflow detection | ||
Can prevent buffer overflows on systems with gcc version 4.2 and up. | Can prevent buffer overflows on systems with gcc version 4.2 and up. | ||
Line 208: | Line 302: | ||
>> ACPI | >> ACPI | ||
Always enable: Button, Fan, Processor, Thermal Zone. Without these, your computer (especially laptops) may overheat because ACPI cannot access thermal monitoring or fans. | Always enable: Button, Fan, Processor, Thermal Zone. Without these, your computer (especially laptops) may overheat because ACPI cannot access thermal monitoring or fans. | ||
+ | >> CPU Frequency scaling | ||
+ | >>> | ||
+ | Enable this if you have frequency scaling enabled in the UEFI/BIOS (Speedstep or similar). | ||
+ | >>>> | ||
+ | This sets CPU frequency to the maximum available. | ||
+ | >>>> | ||
+ | This sets CPU frequency to the minimum available. | ||
+ | >>>> | ||
+ | This allows userspace programs to set the CPU frequency. | ||
+ | >>>> | ||
+ | This governor is recommended for desktops. | ||
+ | >>>> | ||
+ | This governor is recommended for laptops/ | ||
+ | >>>> | ||
+ | >>>>> | ||
+ | This driver is mutually exclusive with the ACPI Processor P-States driver. It is a newer driver for Sandy Bridge processors and [[https:// | ||
+ | >>>>> | ||
+ | This is only required for HP ProLiant servers, which use this interface. Otherwise, disable it. | ||
+ | >>>>> | ||
+ | This is the recommended driver for newer CPUs Intel (Enhanced) Speedstep enabled and AMD K10 and newer. | ||
+ | >>>>> | ||
+ | This is for K8/early Opteron/ | ||
+ | >>>>> | ||
+ | This is a deprecated option that has been superseded by the ACPI Processor P-States driver, so leave this disabled. | ||
+ | >>>>> | ||
+ | This is a hack for Pentium 4s that may cause severe slowdowns and noticeable latencies, so disable it. | ||
> **Bus options** | > **Bus options** | ||
>> Message Signaled Interrupts (MSI and MSI-X) | >> Message Signaled Interrupts (MSI and MSI-X) | ||
This can offload IRQ interrupts by using MSI instead. However, if your BIOS is buggy this may need to be disabled. | This can offload IRQ interrupts by using MSI instead. However, if your BIOS is buggy this may need to be disabled. | ||
> **Executable file formats / Emulations** | > **Executable file formats / Emulations** | ||
+ | >> Kernel support for scripts starting with #! | ||
+ | You **MUST** say yes here or you will not be able to run script that start with ''# | ||
>> IA32 Emulation | >> IA32 Emulation | ||
Allows 32-bit emulation via multi-lib on 64-bit systems. | Allows 32-bit emulation via multi-lib on 64-bit systems. | ||
Line 230: | Line 352: | ||
>>> | >>> | ||
Required by cryptsetup. | Required by cryptsetup. | ||
+ | >> Input device support | ||
+ | >>> | ||
+ | >>>> | ||
+ | Enable this if you have a standard AT or PS/2 keyboard. | ||
+ | >>> | ||
+ | >>>> | ||
+ | Enable this if you have a PS/2 mouse. | ||
+ | >> Multimedia support | ||
+ | >>> | ||
+ | >>>> | ||
+ | >>>>> | ||
+ | If you have a newer webcam, you should enable this or it won't work. | ||
>> Graphics support | >> Graphics support | ||
>>> | >>> | ||
- | Only old graphics cards use this. Typically it will be auto-selected by the driver. | + | >>>> |
+ | Enable | ||
>>> | >>> | ||
- | >>>> | + | This should almost always be enabled. |
- | If you use nouveau, you only need this driver, because it has framebuffer support, you do **NOT** need: | + | >>> |
+ | If you use nouveau, you only need this driver, because it has framebuffer support. | ||
>>> | >>> | ||
+ | >>>> | ||
+ | This should almost always be enabled. | ||
+ | >>>> | ||
+ | You should enable this if you want to boot from UEFI. | ||
>>>> | >>>> | ||
Again this is **NOT** needed by nouveau. | Again this is **NOT** needed by nouveau. | ||
Line 246: | Line 386: | ||
A larger buffer (e.g. 2048) is preferred for systems using PulseAudio. | A larger buffer (e.g. 2048) is preferred for systems using PulseAudio. | ||
>> USB support | >> USB support | ||
+ | >>> | ||
+ | You should enable this for newer systems. | ||
>>> | >>> | ||
>>> | >>> | ||
Line 254: | Line 396: | ||
>> Staging drivers | >> Staging drivers | ||
Avoid drivers in this section if you value system stability. | Avoid drivers in this section if you value system stability. | ||
+ | >> Generic Dynamic Voltage and Frequency Scaling (DVFS) support | ||
+ | This provides frequency scaling support for devices. It also has governors similar to those for CPU frequency scaling. I'm not sure what devices require this. | ||
+ | > **Firmware Drivers** | ||
+ | >> EFI (Extensible Firmware Interface) Support | ||
+ | >>> | ||
+ | This option is deprecated in favor of EFI Variable filesystem. It can [[https:// | ||
> **File systems** | > **File systems** | ||
- | You **MUST** either build-in the driver for the filesystem on which the kernel modules reside **OR** create an initrd, or the kernel will **NOT** boot. | + | You **MUST** either build-in the driver for the filesystem on which the kernel modules reside **OR** create an initrd, or the kernel will **NOT** boot. You should also build-in the driver for the filesystem |
- | >> CD-ROM/DVD Filesystems | + | |
- | >>> | + | |
- | You need this if you plan on reading or writing disks with the UDF filesystem. | + | |
>> DOS/FAT/NT Filesystems | >> DOS/FAT/NT Filesystems | ||
+ | >>> | ||
+ | >>> | ||
+ | You need these built-in if you use EFI. The kernel will boot if they are modules, but catch22 type situations can easily result. | ||
>>> | >>> | ||
>>> | >>> | ||
You need this if you want to write to NTFS filesystems. | You need this if you want to write to NTFS filesystems. | ||
+ | >> CD-ROM/DVD Filesystems | ||
+ | >>> | ||
+ | You need this if you plan on reading or writing disks with the UDF filesystem. | ||
+ | >>> | ||
+ | >>>> | ||
+ | You should enable this if you want to boot from UEFI. | ||
> **Kernel hacking** | > **Kernel hacking** | ||
>> Magic SysRq key | >> Magic SysRq key | ||
Enable if you want to use SysRq REISUB (p.cogx on dvorak) to safely shutdown a hung system. | Enable if you want to use SysRq REISUB (p.cogx on dvorak) to safely shutdown a hung system. | ||
- | >> Write protect kernel read-only data structures | ||
- | Helps catch kernel bugs | ||
>> Allow gcc to uninline functions marked ' | >> Allow gcc to uninline functions marked ' | ||
Enable for gcc 4.x but not for gcc 3.x | Enable for gcc 4.x but not for gcc 3.x | ||
+ | > **Security Options** | ||
+ | >> Restrict unprivileged access to the kernel syslog | ||
+ | Disable this if you want users to be able to use the ' | ||
> **Cryptographic API** | > **Cryptographic API** | ||
Make sure to build-in all algorithms you plan to use for cryptography using cryptsetup, especially if you plan on full disk encryption, otherwise you won't be able to decrypt your disk and thus will not be able to boot. Note that there are optimized and 64-bit versions to choose from. | Make sure to build-in all algorithms you plan to use for cryptography using cryptsetup, especially if you plan on full disk encryption, otherwise you won't be able to decrypt your disk and thus will not be able to boot. Note that there are optimized and 64-bit versions to choose from. | ||
>> Parallel crypto engine | >> Parallel crypto engine | ||
Converts an arbitrary crypto algorithm into a parallel algorithm that executes in kernel threads. It allows multi-threading of any crypto algorithm. | Converts an arbitrary crypto algorithm into a parallel algorithm that executes in kernel threads. It allows multi-threading of any crypto algorithm. | ||
+ | > **Library routines** | ||
+ | >> JEDEC DDR data | ||
+ | You should probably enable this so that the JEDEC data from your RAM is available to drivers that need it. | ||
< | < | ||
If you are wondering what drivers you need, make sure to take a look at the output of these commands. | If you are wondering what drivers you need, make sure to take a look at the output of these commands. | ||
Line 282: | Line 440: | ||
dmesg | dmesg | ||
</ | </ | ||
+ | You may want to consider disabling Staging drivers and EXPERIMENTAL and OBSOLETE drivers if you want a stable, modern kernel. Some can be left on for good reason. | ||
</ | </ | ||
==== Building ==== | ==== Building ==== | ||
Line 306: | Line 465: | ||
#!/bin/sh | #!/bin/sh | ||
# installs kernel only, this should be run only from the kernel source directory | # installs kernel only, this should be run only from the kernel source directory | ||
+ | |||
+ | error() # error | ||
+ | { | ||
+ | echo " | ||
+ | exit 1 | ||
+ | } | ||
# make sure we are root | # make sure we are root | ||
- | if test $HOME != '/ | + | if test ~ != '/ |
then | then | ||
- | echo 'ERROR: | + | error 'This script must be run as root' |
- | exit 1 | + | |
fi | fi | ||
Line 328: | Line 492: | ||
cp System.map /boot | cp System.map /boot | ||
cp .config / | cp .config / | ||
+ | |||
+ | # for elilo | ||
+ | bootdir="/ | ||
+ | if test -d " | ||
+ | then | ||
+ | cp arch/ | ||
+ | fi | ||
# change permissions of vmlinuz | # change permissions of vmlinuz | ||
Line 338: | Line 509: | ||
echo ' | echo ' | ||
else | else | ||
- | echo ' | + | error ' |
- | exit 1 | + | |
fi | fi | ||
if cmp System.map / | if cmp System.map / | ||
Line 345: | Line 515: | ||
echo ' | echo ' | ||
else | else | ||
- | echo ' | + | error ' |
- | exit 1 | + | |
fi | fi | ||
if cmp .config / | if cmp .config / | ||
Line 352: | Line 521: | ||
echo ' | echo ' | ||
else | else | ||
- | echo ' | + | error ' |
- | exit 1 | + | fi |
+ | if test -d " | ||
+ | then | ||
+ | if cmp arch/ | ||
+ | then | ||
+ | echo ' | ||
+ | else | ||
+ | error ' | ||
+ | fi | ||
fi | fi | ||
echo | echo | ||
Line 361: | Line 538: | ||
exit 0 | exit 0 | ||
- | |||
</ | </ | ||
==== lilo ==== | ==== lilo ==== | ||
Line 413: | Line 589: | ||
* The lilo.conf excerpt is from the default lilo.conf that comes with Slackware plus a few options. | * The lilo.conf excerpt is from the default lilo.conf that comes with Slackware plus a few options. | ||
* Thanks to [[wiki: | * Thanks to [[wiki: | ||
+ | * Updated by [[wiki: | ||
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
<!-- You must remove the tag-word " | <!-- You must remove the tag-word " | ||
{{tag> | {{tag> |