Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 221 lines (150 sloc) 7.365 kb
f15c976 Seth House Added current collection to recover from SVN-repo break.
authored
1 ===========================
2 Ogden Area Linux User Group
3 ===========================
4 Compiling a Custom Kernel
5 -------------------------
6
7 :Presenter: Seth House
8 :Date: 2009-03-31
9
10
11 What is the Linux kernel?
12 =========================
13
14 .. FIXME
15
16 .. class:: handout
17
18 The kernel is Linux.
19
20 In computing, the kernel is the central component of most computer
21 operating systems. Its responsibilities include managing the system's
22 resources (the communication between hardware and software
23 components). As a basic component of an operating system, a kernel
24 provides the lowest-level abstraction layer for the resources
25 (especially memory, processors and I/O devices) that application
26 software must control to perform its function.
27
28 — http://en.wikipedia.org/wiki/Kernel_(computer_science)
29
30
31 Why Compile it Yourself?
32 ========================
33
34 .. class:: handout
35
36 Chances are you don't need to compile your own kernel.
37
38 Compiling some drivers (e.g. ATI or Nvidia graphics drivers, VirtualBox or
39 VMware kernel modules) require kernel headers to be installed. If you only
40 need the headers, you don’t need to compile your own kernel. If your kernel
41 headers aren’t installed, consult your distro’s documentation.
42
43 Kernel headers are C header files which provide some definitions of the
44 low-level kernel ABI, to be shared between the kernel and userspace
45 programs. Most userspace programs should not include kernel headers;
46 they are only intended to be used directly by system libraries and
47 low-level tools and daemons.
48
49 The ``make headers_install`` command, when executed in the kernel's
50 source tree, exports the kernel's header files in a form suitable for
51 use by userspace programs.
52
53 When exported, most kernel headers reside in the ``/usr/include/asm``
54 and ``/usr/include/linux directories``.
55
56 — http://en.wikipedia.org/wiki/Kernel_header#Kernel_headers
57
58 .. sidebar:: kernel headers
59
60 Kernel headers are sometimes needed to compile certain drivers.
61
62 .. class:: incremental
63
64 * You want to know how to do it.
65 * You are doing kernel development.
66 * You don’t want to wait for new drivers/features/fixes to make it to your
67 favorite Linux distribution.
68 * You want to apply a patch, maybe to modify some driver.
69 * You are blind and want TTS to begin right as Linux boots. (Speakup_)
70 * You’re trying to wring every last micro-second from your bootup time.
71
72 .. _Speakup: http://www.linux-speakup.org/
73
74 .. footer:: http://www.faqs.org/docs/Linux-HOWTO/Kernel-HOWTO.html
75
76
77 Where Do You Get It?
78 ====================
79
80 .. class:: handout
81
82 Get it from kernel.org.
83
84 The old scheme (after 1.0 and prior to version 2.6):
85
86 * The A number denotes the kernel version. It is rarely changed,
87 and only when major changes in the code and the concept of the
88 kernel occur. It has been changed twice in the history of the
89 kernel: In 1994 (version 1.0) and in 1996 (version 2.0).
90 * The B number denotes the major revision of the kernel
91
92 * The kernel used the traditional even-odd system version
93 numbering system.
94
95 * The C number indicates the minor revision of the kernel. This
96 number was changed when security patches, bug fixes, new features
97 or drivers were implemented in the kernel.
98
99 After the release of 2.6.0 (Dec 2003[34]) it was realized that a much
100 shorter release cycle would be beneficial. Since then:
101
102 * A and B are largely irrelevant
103 * C is the version of the kernel
104
105 — http://en.wikipedia.org/wiki/Kernel_header#Version_numbering
106
107 http://kernel.org/
108
109 .. class:: incremental
110
111 1. Untar the source in ``/usr/src/``.
112 2. Symlink the new directory to ``/usr/src/linux``.
113
114
115 Quick Overview
116 ==============
117
118 .. class:: handout
119
120 ``mrproper`` refers to the Procter & Gamble product, Mr. Proper, which is
121 the European (at least Finnish/German/Czech) branding for Mr. Clean [1]_.
122
123 “…‘make clean’ is simple soap wash, ‘make mrproper’ cleans also tougher
124 stains by using stronger solvents…”
125
126 — http://lkml.indiana.edu/hypermail/linux/kernel/0101.3/0295.html
127
128 .. [1] http://en.wikipedia.org/wiki/Mr._Clean#Mr._Clean_in_popular_culture
129
130 .. class:: incremental
131
132 1. ``make mrproper``
133 2. ``make all``
134 3. ``make modules_install``
135 4. ``cp ./arch/i386/boot/bzimage /boot/vmlinuz-2.6.27.7``
136 5. ``cp ./.config /boot/config-2.6.27.7``
137 6. ``cp ./System.map /boot/System.map-2.6.27.7``
138 7. Make symlinks to the files in ``/boot`` as needed.
139 8. Configure grub or LILO.
140 9. Reboot to test.
141 10. ``make clean`` (optional, to free up disk space)
142
143
144 Create the Config File
145 ======================
146
147 .. class:: handout
148
149 Your best bet is to start with a copy of your distro’s kernel config file.
150 This step is optional, but it will save you a lot of time and give you a
151 kernel that is most like one that your distro ships.
152
153 The file usually lives in ``/boot/config`` (it may be a symlink). Or if you
154 already have other kernel sources installed look for a hidden file in the
155 base directory (e.g. ``/usr/src/linux-2.6.26.6/.config``). Or you may have
156 to hunt it down in your distro’s packages.
157
158 If you’re using a config file for an older kernel version you’ll want to
159 start by running ``make oldconfig``. It will ask you a bunch of questions
160 about things that have changed between kernel versions; generally the
161 default answer is fine.
162
163 Using the graphical config utility is easiest for users unfamiliar with the
164 process. The new ``xconfig`` option uses the QT libraries, the older
165 ``gconfig`` uses the GTK libraries.
166
167 .. class:: sidebar
168
169 Copy the config *after* running ``make mrproper`` or it will be deleted.
170
171 .. class:: incremental
172
173 1. ``cp /boot/config /usr/src/linux/.config``
174 2. ``make oldconfig``
175 3. Tweak any configuration options
176
177 * ``make config``
178 * ``make menuconfig``
179 * ``make xconfig``
180 * ``make gconfig``
181
182
183 How Can You Uninstall an Old Version?
184 =====================================
185
186 1. ``rm -r /lib/modules/2.6.27.7``
187 2. ``rm /boot/vmlinuz-2.6.27.7``
188 3. ``rm /boot/config-2.6.27.7``
189 4. ``rm /boot/System.map-2.6.27.7``
190
191
192 Patching an Existing Source Tree
193 ================================
194
195 .. class:: handout
196
197 Sometimes you already have a kernel source tree on your system and would
198 rather download a smaller patch than a whole new source tar-ball.
199
200 .. class:: incremental
201
202 1. ``cd /usr/src/linux-2.6.26``
203 2. ``gzip -dc patch-2.6.27.gz | patch -p0``
204
205 Some Nomenclature
206 =================
207
208 vmlinuz
209 The compressed built kernel that has been made bootable.
210 vmlinux
211 The vmlinux is the uncompressed built kernel.
212 bzImage
213 The compressed kernel image created with command ``make bzImage`` during
214 kernel compile.
215 System.map
216 A “phone directory” list of function in a particular build of a kernel. If
217 you use the wrong (or no) System.map, debugging crashes is harder (kernel
218 oopses), but has no other effects.
219
220 .. vim:filetype=rst
Something went wrong with that request. Please try again.