{"id":9324,"date":"2025-03-13T01:02:00","date_gmt":"2025-03-13T05:02:00","guid":{"rendered":"https:\/\/www.both.org\/?p=9324"},"modified":"2025-03-07T08:51:42","modified_gmt":"2025-03-07T13:51:42","slug":"kernel-musings","status":"publish","type":"post","link":"http:\/\/www.both.org\/?p=9324","title":{"rendered":"Kernel musings"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"9324\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>Being a curious sort of person, I wonder about a lot of interesting things. For some reason, I&#8217;ve started wondering about the Linux kernel and how many lines of code it contains, and the size of the Linux kernel as it&#8217;s compiled for Fedora, my preferred distro.<\/p>\n\n\n\n<p>I don&#8217;t especially care about exact numbers at a point in time, I just want to get a general feel for those questions. Turning to the Internet, I found this chart on Wikipedia, which indicates that kernel version 6.6 contains just over 37 million lines of source code. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1979\" height=\"980\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2025\/03\/Linux_Kernel_Sizes_Graph.png\" alt=\"\" class=\"wp-image-9887\" style=\"width:864px;height:auto\"\/><figcaption class=\"wp-element-caption\">Source: Wikipedia. This file is made available under the <a href=\"https:\/\/en.wikipedia.org\/wiki\/en:Creative_Commons\">Creative Commons<\/a> <a href=\"https:\/\/creativecommons.org\/publicdomain\/zero\/1.0\/deed.en\">CC0 1.0 Universal Public Domain Dedication<\/a>.<\/figcaption><\/figure>\n\n\n\n<p>Another <a href=\"https:\/\/linuxiac.com\/linux-kernel-surpasses-40-million-lines\/\" data-type=\"link\" data-id=\"https:\/\/linuxiac.com\/linux-kernel-surpasses-40-million-lines\/\" target=\"_blank\" rel=\"noreferrer noopener\">source<\/a> says that Linux has just passed 40 million lines of source code, and that makes sense since the most recent kernel is 6.13. That seems huge, but it&#8217;s important to understand that the Linux kernel code contains support for the following processor hardware architectures.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>alpha<\/li>\n\n\n\n<li>arc<\/li>\n\n\n\n<li>arm<\/li>\n\n\n\n<li>arm64<\/li>\n\n\n\n<li>csky<\/li>\n\n\n\n<li>hexagon<\/li>\n\n\n\n<li>loongarch<\/li>\n\n\n\n<li>m68k<\/li>\n\n\n\n<li>microbaze<\/li>\n\n\n\n<li>mips<\/li>\n\n\n\n<li>nios2<\/li>\n\n\n\n<li>openrisc<\/li>\n\n\n\n<li>parisc<\/li>\n\n\n\n<li>powerpc<\/li>\n\n\n\n<li>riscv<\/li>\n\n\n\n<li>s390<\/li>\n\n\n\n<li>sh<\/li>\n\n\n\n<li>sparc<\/li>\n\n\n\n<li>um<\/li>\n\n\n\n<li>x86<\/li>\n\n\n\n<li>xtensa<\/li>\n<\/ol>\n\n\n\n<p>And this is the short list. Wikipedia has the <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_Linux-supported_computer_architectures\" data-type=\"link\" data-id=\"https:\/\/en.wikipedia.org\/wiki\/List_of_Linux-supported_computer_architectures\" target=\"_blank\" rel=\"noreferrer noopener\">longer and more detailed list<\/a>. <\/p>\n\n\n\n<p>That is impressive because Windows only supports one processor architecture, the Intel x86, which is what most PCs use. Microsoft doesn&#8217;t release statistics like lines of code, and the entire kernel is proprietary, so you can&#8217;t check it out on GitHub to count for yourself. However there are <a href=\"https:\/\/windowsreport.com\/windows-11-how-many-lines-of-code\/\" data-type=\"link\" data-id=\"https:\/\/windowsreport.com\/windows-11-how-many-lines-of-code\/\" target=\"_blank\" rel=\"noreferrer noopener\">estimates<\/a> that place it between 60 and 100 million lines of code. For just one hardware architecture.<\/p>\n\n\n\n<p>Even better, compiled versions of Linux for any architecture, such as the Intel X86, don&#8217;t use all those lines. The actual number of lines of source code used in any compiled kernel, and therefore the size of the kernel, depends upon the target architecture and the options selected for the kernel at compile time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Kernel files<\/h2>\n\n\n\n<p>The installed kernels are located in the \/boot directory, along with other kernel related files. There are usually three kernels stored there, the most current and the two most recent prior to that. I personally keep a total of 5 kernels &#8212; not counting the so-called rescue kernel. <\/p>\n\n\n\n<p>I had an instance several years ago, in which a critical software package would crash when running on the current kernel. I rebooted and selected the most recent previous kernel, and that software worked just fine. Eventually, another kernel update resolved the issue. Such problems are an excellent reason for keeping older kernels.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@david:\/boot# <strong>ll -h<\/strong>\ntotal 509M\n-rw-r--r--. 1 root root 274K Jan 22 19:00 config-6.12.11-200.fc41.x86_64\n-rw-r--r--. 1 root root 274K Feb  7 19:00 config-6.12.13-200.fc41.x86_64\n-rw-r--r--. 1 root root 274K Feb 17 19:00 config-6.12.15-200.fc41.x86_64\n-rw-r--r--. 1 root root 276K Feb 21 19:00 config-6.13.4-200.fc41.x86_64\n-rw-r--r--. 1 root root 276K Feb 26 19:00 config-6.13.5-200.fc41.x86_64\ndrwx------. 4 root root 4.0K Dec 31  1969 efi\ndrwxr-xr-x. 2 root root 4.0K Oct 29 12:31 extlinux\ndrwx------. 4 root root 4.0K Mar  4 10:28 grub2\n-rw-------. 1 root root  83M Sep 10  2020 initramfs-0-rescue-0b07292c495a42ee9f5867ebff1ccee2.img\n-rw-------. 1 root root  57M Jan 31 08:07 initramfs-6.12.11-200.fc41.x86_64.img\n-rw-------. 1 root root  57M Feb 16 20:48 initramfs-6.12.13-200.fc41.x86_64.img\n-rw-------. 1 root root  57M Feb 22 08:47 initramfs-6.12.15-200.fc41.x86_64.img\n-rw-------. 1 root root  57M Feb 26 10:27 initramfs-6.13.4-200.fc41.x86_64.img\n-rw-------. 1 root root  57M Mar  1 10:21 initramfs-6.13.5-200.fc41.x86_64.img\ndrwxrwxr-x. 3 root root 4.0K Sep 10  2020 loader\ndrwx------. 2 root root  16K Sep 10  2020 lost+found\n-rw-r--r--. 1 root root 154K Nov 11 19:00 memtest86+x64.efi\n-rw-r--r--. 1 root root 179K Jan 31 08:07 symvers-6.12.11-200.fc41.x86_64.xz\n-rw-r--r--. 1 root root 179K Feb 16 20:48 symvers-6.12.13-200.fc41.x86_64.xz\n-rw-r--r--. 1 root root 179K Feb 22 08:47 symvers-6.12.15-200.fc41.x86_64.xz\n-rw-r--r--. 1 root root 181K Feb 26 10:27 symvers-6.13.4-200.fc41.x86_64.xz\n-rw-r--r--. 1 root root 181K Mar  1 10:21 symvers-6.13.5-200.fc41.x86_64.xz\n-rw-r--r--. 1 root root  11M Jan 22 19:00 System.map-6.12.11-200.fc41.x86_64\n-rw-r--r--. 1 root root  11M Feb  7 19:00 System.map-6.12.13-200.fc41.x86_64\n-rw-r--r--. 1 root root  11M Feb 17 19:00 System.map-6.12.15-200.fc41.x86_64\n-rw-r--r--. 1 root root  11M Feb 21 19:00 System.map-6.13.4-200.fc41.x86_64\n-rw-r--r--. 1 root root  11M Feb 26 19:00 System.map-6.13.5-200.fc41.x86_64\n-rwxr-xr-x. 1 root root  11M Sep 10  2020 vmlinuz-0-rescue-0b07292c495a42ee9f5867ebff1ccee2\n-rwxr-xr-x. 1 root root  16M Jan 22 19:00 vmlinuz-6.12.11-200.fc41.x86_64\n-rwxr-xr-x. 1 root root  16M Feb  7 19:00 vmlinuz-6.12.13-200.fc41.x86_64\n-rwxr-xr-x. 1 root root  16M Feb 17 19:00 vmlinuz-6.12.15-200.fc41.x86_64\n-rwxr-xr-x. 1 root root  16M Feb 21 19:00 vmlinuz-6.13.4-200.fc41.x86_64\n-rwxr-xr-x. 1 root root  16M Feb 26 19:00 vmlinuz-6.13.5-200.fc41.x86_64\nroot@david:\/boot#<\/code><\/pre>\n\n\n\n<p>And since we&#8217;re here, there are some interesting files to understand. Each kernel has supporting files that are necessary to help get it loaded and up and running. <\/p>\n\n\n\n<p>All of these explanations are rather simple &#8212; just enough to understand their function.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">vmlinuz<\/h3>\n\n\n\n<p>The vmlinuz files are the Linux kernels. You can see that they are all about 16MB in size. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">initramfs<\/h3>\n\n\n\n<p>The initramfs files are the initial boot images for each kernel. They are large compared to the kernel files because they contain not only the kernel, but also all the hardware modules necessary to load into memory, and basic system support such as hardware and filesystems to get the computer up and running enough to load the vmlinuz kernel and turn control over to it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">symvers<\/h3>\n\n\n\n<p>The symvers files are a map of system library versions, so that the running kernel can find the library it needs for particular function calls. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">System.map<\/h3>\n\n\n\n<p>These files are, as their name implies, maps of where kernel symbols are located in RAM. This enables the kernel to easily locate functions identified by the symbols in the map. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">config<\/h3>\n\n\n\n<p>The config files are a little different because they aren&#8217;t required to boot or run the system. They define the configuration of the kernels with variables used by the makefile during the kernel compilation. You could compile the kernel yourself and, using these configuration files, the result would be kernels identical to the ones already installed. <\/p>\n\n\n\n<p>I&#8217;ve seen some software that requires the kernel to be compiled with one or more specific features included. You can use these configuration files to determine which features are compiled into the kernel you&#8217;re using. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">memtest86+x64.efi<\/h3>\n\n\n\n<p>This program is a memory test. The GRUB menu has an entry for this tool so that it can be selected before the system boots up. Use this to test system memory without the kernel, other programs, and data taking up space that would prevent the most thorough test possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final thoughts<\/h2>\n\n\n\n<p>Numbers such as the kernel contains 40 million lines of code are rather misleading since they don&#8217;t take into consideration other factors. Taking into account that the compiled kernel only contains those lines of code required for the target architecture and the specific features specified during the compile process, the actual number is far less. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Being a curious sort of person, I wonder about a lot of interesting things. For some reason, I&rsquo;ve<\/p>\n","protected":false},"author":2,"featured_media":4837,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[109,570,5,728],"tags":[571,731],"class_list":["post-9324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-curiosity","category-kernel","category-linux","category-musings","tag-linux-kernel","tag-size"],"modified_by":"David Both","_links":{"self":[{"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/9324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9324"}],"version-history":[{"count":24,"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/9324\/revisions"}],"predecessor-version":[{"id":9917,"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/9324\/revisions\/9917"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/4837"}],"wp:attachment":[{"href":"http:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9324"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}