├── .gitignore
├── Makefile
├── about_the_author.xml
├── appa.xml
├── biblio.xml
├── book.xml
├── ch00.xml
├── ch01.xml
├── ch02.xml
├── ch03.xml
├── ch04.xml
├── ch05.xml
├── ch06.xml
├── ch07.xml
├── ch08.xml
├── ch09.xml
├── ch10.xml
├── ch11.xml
├── images
├── config_search.png
├── config_search_found.png
├── config_search_pl2303.png
├── config_search_pl2303_found.png
├── gconfig_1.png
├── gconfig_2.png
├── gconfig_3.png
├── kernel.org.png
├── kernel.org.v2.6.png
├── kernel.org_finger_banner.png
├── kernel.org_patch.png
├── kernel_releases.dia
├── kernel_releases.eps
├── kernel_releases.png
├── menuconfig_1.png
├── menuconfig_2.png
├── menuconfig_3.png
├── menuconfig_4.png
├── menuconfig_5.png
├── menuconfig_6.png
├── xconfig_1.png
├── xconfig_2.png
└── xconfig_3.png
├── license.xml
├── lkn_outline
├── lkn_proposal
├── old
├── ch13.xml.old
└── ch13.xml.orig
├── rst
├── .gitignore
├── Makefile
├── ch00.rst
├── conf.py
├── index.rst
└── lkn.style
├── schedule
├── src
├── 2.6.15-rc5.raw.xml
├── 2.6.17.raw.xml
├── count_symbols.sh
├── find_all_modules.sh
├── get-driver.sh
├── gregkh_symbols.txt
├── gregkh_symbols.txt.orig
├── series
└── xml-config.patch
├── status
└── test_book.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.swp
3 | *.tar.gz
4 | src/linux-2.6.*
5 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | BOOK_NAME=lkn
2 |
3 | ###################################
4 | # book section
5 |
6 | BOOK_SRC := book.xml
7 |
8 | CHAP_SRC := ch01.xml \
9 | ch02.xml \
10 | ch03.xml \
11 | ch04.xml \
12 | ch05.xml \
13 | ch06.xml \
14 | ch07.xml \
15 | ch08.xml \
16 | ch09.xml \
17 | ch10.xml \
18 | ch11.xml \
19 | ch12.xml \
20 | ch13.xml \
21 | appa.xml \
22 | appb.xml \
23 | appc.xml \
24 | appd.xml
25 |
26 | all:
27 | @echo "need to tell me what to do"
28 | @echo "options are: clean check bookcheck html bookhtml"
29 |
30 | clean:
31 | -rm *.html
32 |
33 | check:
34 | xwf $(CHAP_SRC)
35 |
36 | bookcheck:
37 | xval $(BOOK_SRC)
38 |
39 | html:
40 | db2h $(CHAP_SRC)
41 |
42 | bookhtml:
43 | db2h $(BOOK_SRC)
44 |
45 |
46 | testbookcheck:
47 | xmllint --xinclude --postvalid --noout test_book.xml
48 |
49 | testchaptercheck:
50 | xmllint --dtdvalid "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" --noout $(FILES)
51 |
52 |
53 |
54 | VERSION=$(shell date "+%Y_%m_%d"| awk '{print $$1}')
55 |
56 | RELEASE_NAME=$(BOOK_NAME)-$(VERSION)
57 | HTML_NAME=$(BOOK_NAME)-html-$(VERSION)
58 | FIGURE_NAME=$(BOOK_NAME)-figures-$(VERSION)
59 |
60 | FIGURESFILES = $(shell find . \( -not -name '.' \) -print | egrep -v '(BitKeeper|SCCS)' | grep -v "\.tar\.gz" | grep -v "\.dia" | grep figures | sort )
61 | #HTMLFILES = $(shell find . \( -not -name '.' \) -print | egrep -v '(BitKeeper|SCCS|.git)' | grep -v "\.tar\.gz" | grep -v "\.dia" | grep html | sort )
62 | IMAGEFILES = $(shell find -type f -name *png | sort)
63 | HTMLFILES = $(shell ls *.html | sort )
64 |
65 | distdir := $(RELEASE_NAME)
66 | srcdir = .
67 | release: clean
68 | git-tar-tree HEAD $(RELEASE_NAME) | gzip -9v > $(RELEASE_NAME).tar.gz
69 | @echo "Built $(RELEASE_NAME).tar.gz"
70 |
71 | figure_release: clean
72 | @echo $(FIGURESFILES)
73 | #cd figures
74 | @-rm -rf $(distdir)
75 | @mkdir $(distdir)
76 | @-chmod 777 $(distdir)
77 | @for file in $(FIGURESFILES); do \
78 | if test -d $$file; then \
79 | mkdir $(distdir)/$$file; \
80 | else \
81 | cp -p $$file $(distdir)/$$file; \
82 | fi; \
83 | done
84 | @tar -c $(distdir) | gzip -9 > $(FIGURE_NAME).tar.gz
85 | @rm -rf $(distdir)
86 | @echo "Built $(FIGURE_NAME).tar.gz"
87 |
88 | html_release: bookhtml
89 | @echo $(HTMLFILES) $(IMAGEFILES)
90 | @-rm -rf $(distdir)
91 | @mkdir $(distdir)
92 | @-chmod 777 $(distdir)
93 | @for file in images $(HTMLFILES) $(IMAGEFILES); do \
94 | if test -d $$file; then \
95 | mkdir $(distdir)/$$file; \
96 | else \
97 | cp -p $$file $(distdir)/$$file; \
98 | fi; \
99 | done
100 | @tar -c $(distdir) | gzip -9 > $(HTML_NAME).tar.gz
101 | @rm -rf $(distdir)
102 | @echo "Built $(HTML_NAME).tar.gz"
103 |
--------------------------------------------------------------------------------
/about_the_author.xml:
--------------------------------------------------------------------------------
1 | Greg Kroah-Hartman has been building the Linux kernel since 1996 and
2 | started writing Linux kernel drivers in 1999. He is currently the
3 | maintainer of the USB, PCI, driver core and sysfs subsystems in the kernel
4 | source tree and is also one half of the -stable kernel release team. He
5 | created the udev program and maintains the Linux hotplug userspace project.
6 | He is a Gentoo Linux developer as well as the co-author of the third
7 | edition of the Linux Device Drivers book and a
8 | contributing editor to Linux Journal magazine. He also
9 | created and maintains the Linux Device Driver Kit. He
10 | currently works for SuSE Labs / Novell, doing various Linux kernel related
11 | tasks.
12 |
--------------------------------------------------------------------------------
/appa.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Helpful Utilities
5 |
6 |
7 |
8 | Retrieving, building, updating, and maintaining a Linux kernel
9 | source tree involves a lot of different steps, as this book has shown.
10 | Developers being naturally lazy creatures, they have created some programs
11 | to help with the various routine tasks. Here we describe a few of these
12 | useful tools and the basics on how to use them.
13 |
14 |
15 |
16 | Linux kernel development differs in many ways from traditional software
17 | development. Some of the special demands on kernel programmers include:
18 |
19 |
20 |
21 |
22 |
23 |
24 |
30 | Constantly applying your changes to the moving target of a fast-based
31 | kernel development release schedule.
32 |
33 |
34 |
35 |
36 |
37 |
46 | Resolving any merge conflicts between changes you have made and changes
47 | made by other people.
48 |
49 |
50 |
51 |
52 |
53 | Exporting your changes in a format that lets others incorporate and work
54 | with it easily.
55 |
56 |
57 |
58 |
59 |
60 |
61 | patch and diff
62 |
63 |
71 |
72 | This section is based on an article originally published in Linux Journal.
73 |
74 |
75 |
76 |
77 |
78 |
79 | One of the most common methods of doing kernel work is to use the
80 | patch and diff programs.
81 |
87 | To use these tools, two different directory trees: a "clean" one and a
88 | "working" one must be used. The clean tree is a released kernel version,
89 | while the working one is based on the same version but contains your
90 | modifications. Then you can use patch and
91 | diff to extract your changes and port them forward to a
92 | new kernel release.
93 |
94 |
95 |
104 |
105 | For an example, create two directories containing the latest kernel version
106 | as described in :
107 |
108 | $ tar -zxf linux-2.6.19.tar.gz
109 | $ mv linux-2.6.19 linux-2.6.19-dirty
110 | $ tar -zxf linux-2.6.19.tar.gz
111 | $ ls
112 | linux-2.6.19/
113 | linux-2.6.19-dirty/
114 |
115 |
116 |
117 |
118 | Now make all of the different changes you wish to do in the
119 | -dirty directory and leave the clean, original kernel
120 | directory alone. After finishing making changes, you should create a patch
121 | to send it to other people:
122 |
123 | $ diff -Naur -X linux-2.6.19/Documentation/dontdiff linux-2.6.19/ linux-2.6.19-dirty/ > my_patch
124 |
125 |
126 |
127 |
128 | This will create a file called my_patch that contains
129 | the difference between your work and a clean 2.6.19 kernel tree. This patch
130 | then can be sent to other people via e-mail.
131 |
132 |
133 |
134 | New Kernel Versions
135 |
136 |
137 | If a new kernel version is released, and you wish to port your changes to
138 | the new version, you need to try to apply your generated patch onto a clean
139 | kernel version. This can be done in the following steps:
140 |
141 |
142 |
143 |
144 |
145 | Generate your original patch, as in the previous example.
146 |
147 |
148 |
149 |
150 |
151 | Using the official patch from
152 | kernel.org, move the old kernel version
153 | forward one release:
154 |
155 |
156 |
157 | $ cd linux-2.6.19
158 | $ patch -p1 < ../patch-2.6.20
159 | $ cd ..
160 | $ mv linux-2.6.19 linux-2.6.20
161 |
162 |
163 |
164 |
165 |
166 | Move your working directory forward one release by removing your patch,
167 | then apply the new update:
168 |
169 | $ cd linux-2.6.19-dirty
170 | $ patch -p1 -R < ../my_patch
171 | $ patch -p1 < ../patch-2.6.20
172 | $ cd ..
173 | $ mv linux-2.4.19-dirty linux-2.6.20-dirty
174 |
175 |
176 |
177 |
178 |
179 |
180 | Try to apply your patch on top of the new update:
181 |
182 | $ cd linux-2.6.20-dirty
183 | $ patch -p1 < ../my_patch
184 |
185 |
186 |
187 |
188 | If your patch does not apply cleanly, resolve all of the conflicts that are
189 | created (the patch command will tell you about these,
190 | leaving behind .rej and .orig
191 | files for you to compare and fix up manually using your favorite
192 | editor). This merge process can be the most difficult part if you have
193 | made changes to portions of the source tree that have been changed by other
194 | people.
195 |
196 |
197 |
198 |
199 |
200 |
201 | If you use this development process, I highly recommend getting the
202 | excellent patchutils set of programs (found at
203 | http://cyberelk.net/tim/patchutils). These
204 | programs enable you to manipulate text patches easily in all sorts of
205 | useful ways, and have saved kernel developers many hours of tedious
206 | work.
207 |
208 |
209 |
210 |
211 |
212 |
213 | Managing Your Patches With quilt
214 |
215 |
216 | Kernel development using patch and
217 | diff generally works quite well. But after a while, most
218 | people grow tired of it and look for a different way to work that does not
219 | involve so much tedious patching and merging. Luckily, a few kernel
220 | developers came up with a program called quilt that
221 | handles the process of manipulating a number of patches made against an
222 | external source tree much easier.
223 |
224 |
225 |
226 | The idea for quilt came from a set of scripts written by
227 | Andrew Morton that he used to first maintain the memory management
228 | subsystem, and then later the entire development kernel tree. His scripts
229 | were tied very tightly to his workflow, but the ideas behind them were very
230 | powerful. Andreas Gruenbacher took those ideas and created the
231 | quilt tool.
232 |
233 |
234 |
235 | The basic idea behind quilt is that you work with a
236 | pristine source tree, and add a bunch of patches on top of it. You can
237 | push and pop different patches off of the source tree, and maintain this
238 | list of patches in a simple manner.
239 |
240 |
241 |
242 | To get started, create a kernel source tree like always:
243 |
244 | $ tar -zxf linux-2.6.19.tar.gz
245 | $ ls
246 | linux-2.6.19/
247 |
248 | And go into that directory:
249 |
250 | $ cd linux-2.6.19
251 |
252 | To get started, create a directory called patches that
253 | will hold all of our kernel patches:
254 |
255 | $ mkdir patches
256 |
257 | Then tell quilt to create a new patch called
258 | patch1:
259 |
260 | $ quilt new patch1
261 | Patch patches/patch1 is now on top
262 |
263 | quilt needs to be told about all of the different files
264 | that will be modifed by this new patch. To do this, use the
265 | add command:
266 |
267 | $ quilt add Makefile
268 | File Makefile added to patch patches/patch1
269 |
270 | Edit the file Makefile, modify the
271 | EXTRAVERSION line, and save the change.
272 | After you finish, tell quilt to refresh the patch:
273 |
274 | $ quilt refresh
275 | Refreshed patch patches/patch1
276 |
277 | The file patches/patch1 will contain
278 | a patch with the changes that you have just made:
279 |
280 | $ cat patches/patch1
281 | Index: linux-2.6.19/Makefile
282 | ===================================================================
283 | --- linux-2.6.19.orig/Makefile
284 | +++ linux-2.6.19/Makefile
285 | @@ -1,7 +1,7 @@
286 | VERSION = 2
287 | PATCHLEVEL = 6
288 | SUBLEVEL = 19
289 | -EXTRAVERSION =
290 | +EXTRAVERSION = -dirty
291 | NAME=Crazed Snow-Weasel
292 |
293 | # *DOCUMENTATION*
294 |
295 |
296 |
297 |
298 |
299 | You can continue on, working with this single patch, or create a new one to
300 | go on top of this patch. As an example, if three different patches had
301 | been created, patch1, patch2, and
302 | patch3, they will be applied one on top of one another.
303 |
304 |
305 |
306 | To see the list of patches that are currently applied:
307 |
308 | $ quilt series -v
309 | + patches/patch1
310 | + patches/patch2
311 | = patches/patch3
312 |
313 | This output shows that all three patches are applied, and that the current
314 | one is patch3.
315 |
316 |
317 |
318 | If a new kernel version is released, and you wish to port your changes to
319 | the new version, quilt can handle this easily with the following steps:
320 |
321 |
322 |
323 |
324 |
325 | Pop off all of the patches that are currently on the tree:
326 |
327 | $ quilt pop -a
328 | Removing patch patches/patch3
329 | Restoring drivers/usb/Makefile
330 |
331 | Removing patch patches/patch2
332 | Restoring drivers/Makefile
333 |
334 | Removing patch patches/patch1
335 | Restoring Makefile
336 |
337 | No patches applied
338 |
339 |
340 |
341 |
342 |
343 |
344 | Using the official patch from
345 | kernel.org, move the old kernel version
346 | forward one release:
347 |
348 |
349 |
350 | $ patch -p1 < ../patch-2.6.20
351 | $ cd ..
352 | $ mv linux-2.6.19 linux-2.6.20
353 |
354 |
355 |
356 |
357 |
358 | Now have quilt push all of the patches back on top of the new tree:
359 |
360 | $ quilt push
361 | Applying patch patches/patch1
362 | patching file Makefile
363 | Hunk #1 FAILED at 1.
364 | 1 out of 1 hunk FAILED -- rejects in file Makefile
365 | Patch patches/patch1 does not apply (enforce with -f)
366 |
367 |
368 |
369 |
370 |
371 |
372 | As the first patch doesn't apply cleanly, force the patch to be applied and
373 | then fix it up:
374 |
375 | $ quilt push -f
376 | Applying patch patches/patch1
377 | patching file Makefile
378 | Hunk #1 FAILED at 1.
379 | 1 out of 1 hunk FAILED -- saving rejects to file Makefile.rej
380 | Applied patch patches/patch1 (forced; needs refresh)
381 | $ vim Makefile.rej Makefile
382 |
383 |
384 |
385 |
386 |
387 |
388 | After the patch is applied by hand, refresh the patch:
389 |
390 | $ quilt refresh
391 | Refreshed patch patches/patch1
392 |
393 |
394 |
395 |
396 |
397 |
398 | And continue on pushing the other patches:
399 |
400 | $ quilt push
401 | Applying patch patches/patch2
402 | patching file drivers/Makefile
403 |
404 | Now at patch patches/patch2
405 | $ quilt push
406 | Applying patch patches/patch3
407 | patching file drivers/usb/Makefile
408 |
409 | Now at patch patches/patch3
410 |
411 |
412 |
413 |
414 |
415 |
416 | quilt also has options that will automatically email out
417 | all of the patches in the series to a group of people or a mailing list,
418 | delete specific patches in the middle of the series, go up or down the
419 | series of patches until a specific patch is found, and many more powerful
420 | options.
421 |
422 |
423 |
424 | If you want to do any kind of kernel development,
425 | quilt is strongly recommended, even for tracking a
426 | few patches, instead of using the more difficult diff
427 | and patch method. It is much simpler and will save you
428 | much time and effort.
429 |
430 |
431 |
432 | On a personal note, I cannot recommend this tool enough, as I
433 | use it every day to manage hundreds of patches in different development
434 | trees. It is also used by numerous Linux distributions to maintain their
435 | kernel packages, and has an involved and responsive development community.
436 |
437 |
438 |
439 |
440 |
441 |
442 | git
443 |
444 |
445 | git is a source code control tool that was originally
446 | written by Linus Torvalds when the Linux kernel was looking for a new
447 | source code control system. It is a distributed system, which differs from
448 | traditional source code control systems such as cvs in that
449 | it is not required to be connected to a server in order to make a commit to
450 | the repository.
451 |
452 |
453 |
454 | git is one of the most powerful, flexible, and fast source code control
455 | systems currently available, and has an active development team working
456 | behind it. The main web page for git can be found at
457 | http://git.or.cz/. It is recommended
458 | that any new user of git go through the published
459 | tutorials in order to become familiar with how git
460 | works, and how to use it properly.
461 |
462 |
463 |
464 | The Linux kernel is developed using git, and the latest
465 | git kernel tree can be found at
466 | http://www.kernel.org/git/, along with
467 | a large list of other kernel developer's git repositories.
468 |
469 |
470 |
471 | It is not necessary to use git in order to do Linux
472 | kernel development, but it is very handy in helping to track down kernel
473 | bugs. If you report a bug to the Linux kernel developers, they might ask
474 | you to use git bisect in order to find the exact change
475 | that caused the bug to happen. If so, follow the directions in the
476 | git documentation for how to use this.
477 |
478 |
479 |
480 |
481 |
482 | ketchup
483 |
484 |
485 | ketchup is a very handy tool used to update or
486 | switch between different versions of the Linux kernel source tree. It has
487 | the ability to:
488 |
489 |
490 |
491 | Find the latest version of the kernel, download it, and uncompress it.
492 |
493 |
494 |
495 |
496 | Update a currently installed version of the kernel source tree to any other
497 | version, by patching the tree to the proper version.
498 |
499 |
500 |
501 |
502 | Handle the different development and stable branches of the kernel
503 | tree, including the -mm and -stable trees.
504 |
505 |
506 |
507 |
508 | Download any patches or tarballs needed to do the update, if they
509 | are not present on the machine already.
510 |
511 |
512 |
513 |
514 | Check the GPG signatures of the tarball and patches to verify that it
515 | has downloaded a correct file.
516 |
517 |
518 |
519 |
520 |
521 |
522 | ketchup can be found at
523 | http://www.selenic.com/ketchup/
524 | and has lots of additional documentation in the wiki at
525 | http://www.selenic.com/ketchup/wiki/.
526 | .
527 |
528 |
529 |
530 | Here is a set of steps that show how simple it is to use
531 | ketchup to download a specific kernel version, and then
532 | have it switch the directory to another kernel version with only a minimal
533 | number of commands.
534 |
535 |
536 |
537 | To have ketchup download the 2.6.16.24 version of the
538 | kernel source tree into a directory, and rename the directory to be the
539 | same as the kernel version, enter:
540 |
541 | $ mkdir foo
542 | $ cd foo
543 | $ ketchup -r 2.6.16.24
544 | None -> 2.6.16.24
545 | Unpacking linux-2.6.17.tar.bz2
546 | Applying patch-2.6.17.bz2 -R
547 | Applying patch-2.6.16.24.bz2
548 | Current directory renamed to /home/gregkh/linux/linux-2.6.16.24
549 |
550 |
551 |
552 |
553 | Now, to upgrade this kernel to contain the latest stable kernel version, just
554 | enter:
555 |
556 | $ ketchup -r 2.6
557 | 2.6.16.24 -> 2.6.17.11
558 | Applying patch-2.6.16.24.bz2 -R
559 | Applying patch-2.6.17.bz2
560 | Downloading patch-2.6.17.11.bz2
561 | --22:21:14-- http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.17.11.bz2
562 | => `/home/greg/.ketchup/patch-2.6.17.11.bz2.partial'
563 | Resolving www.kernel.org... 204.152.191.37, 204.152.191.5
564 | Connecting to www.kernel.org|204.152.191.37|:80... connected.
565 | HTTP request sent, awaiting response... 200 OK
566 | Length: 36,809 (36K) [application/x-bzip2]
567 |
568 | 100%[====================================>] 36,809 93.32K/s
569 |
570 | 22:21:14 (92.87 KB/s) - `/home/greg/.ketchup/patch-2.6.17.11.bz2.partial' saved [36809/36809]
571 |
572 | Downloading patch-2.6.17.11.bz2.sign
573 | --22:21:14-- http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.17.11.bz2.sign
574 | => `/home/greg/.ketchup/patch-2.6.17.11.bz2.sign.partial'
575 | Resolving www.kernel.org... 204.152.191.37, 204.152.191.5
576 | Connecting to www.kernel.org|204.152.191.37|:80... connected.
577 | HTTP request sent, awaiting response... 200 OK
578 | Length: 248 [application/pgp-signature]
579 |
580 | 100%[====================================>] 248 --.--K/s
581 |
582 | 22:21:14 (21.50 MB/s) - `/home/greg/.ketchup/patch-2.6.17.11.bz2.sign.partial' saved [248/248]
583 |
584 | Verifying signature...
585 | gpg: Signature made Wed Aug 23 15:01:04 2006 PDT using DSA key ID 517D0F0E
586 | gpg: Good signature from "Linux Kernel Archives Verification Key >ftpadmin@kernel.org<"
587 | gpg: WARNING: This key is not certified with a trusted signature!
588 | gpg: There is no indication that the signature belongs to the owner.
589 | Primary key fingerprint: C75D C40A 11D7 AF88 9981 ED5B C86B A06A 517D 0F0E
590 | Applying patch-2.6.17.11.bz2
591 | Current directory renamed to /home/greg/linux/tmp/x/linux-2.6.17.11
592 |
593 | This shows that ketchup automatically determined that
594 | the newest stable version was 2.6.17.11, and downloaded the needed patch
595 | files in order to get to that version.
596 |
597 |
598 |
599 | It is highly recommended that you use ketchup if you
600 | want to download any Linux kernel source trees. It takes all of the work
601 | in finding where on the server the correct patch file is, and automatically
602 | will apply the patch in the properly format, after checking that the
603 | downloaded file is properly signed. Combine ketchup
604 | with quilt and you have a very powerful setup that
605 | contains everything that you need in order to deal effectively with
606 | kernel sources as a Linux kernel
607 | developer.
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
--------------------------------------------------------------------------------
/biblio.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bibliography
4 |
5 | Most of the information in this book has been extracted from the kernel
6 | documentation and source code. This is the best place for information on
7 | how to build and install the kernel, and is usually kept up to date when
8 | things in the build procedure change.
9 |
10 |
11 |
12 |
13 |
14 | Books
15 |
16 |
17 | There are a number of very good Linux kernel programming books availble,
18 | but only a few that deal with building and installing the kernel. Here is
19 | a list of books that the author has found useful when dealing with the
20 | Linux kernel.
21 |
22 |
23 |
24 | General Linux Books
25 |
26 |
27 |
28 |
29 | Ellen Siever, Aaron Weber, Stephen Figgins, Robert Love, Arnold Robbins.
30 | Linux in a Nutshell, Fifth Edition.
31 | O'Reilly & Associates, 2005
32 |
33 |
34 |
35 | This book can be has the most complete and authoritative command reference
36 | for Linux. It covers almost every different command that you will ever
37 | need to use.
38 |
39 |
40 |
41 |
42 |
43 |
44 | Yaghmour, Karim.
45 | Building Embedded Systems.
46 | O'Reilly & Associates, 2003.
47 |
48 |
49 |
50 | This book, although mainly oriented toward the embedded Linux developer,
51 | has a great section on how to build up a cross-compiler toolchain and
52 | kernel. It is highly recommended for that, as well as other portions of
53 | this book that are very relevant for people wishing to learn more about
54 | how to customise a Linux kernel and the rest of the system.
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Linux Kernel Books
65 |
66 |
67 | Most of these books are oriented toward the programmer who is interested
68 | in learning how to program within the kernel. They are much more
69 | technically oriented than this book, but are a great place to start if
70 | you wish to learn more about the code that controls the kernel.
71 |
72 |
73 |
74 |
75 |
76 |
77 | Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman.
78 | Linux Device Drivers, Third Edition.
79 | O'Reilly & Associates, 2005.
80 |
81 |
82 |
83 | This book covers thow the different kernel device driver subsystems
84 | work, and provides lots of examples of working drivers. It is
85 | recommended for anyone wanting to work with Linux kernel drivers. It is
86 | also available online for free at
87 | http://lwn.net/Kernel/LDD3/.
88 |
89 |
90 |
91 |
92 |
93 |
94 | Love, Robert.Linux Kernel Development, Second Edition.
95 | Novell Press Publishing, 2005.
96 |
97 |
98 |
99 | Robert Love's book covers almost all areas of the Linux kernel, showing
100 | how everything works together. It is a great place to start learning
101 | about the different portions of the kernel internals.
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | Bovet, Daniel P. and Cesate, Marco.
110 | Understanding the Linux Kernel, Third Edition.
111 | O'Reilly & Associates, 2005.
112 |
113 |
114 | This book goes into the design and implementation of the core Linux
115 | kernel. It is a great reference for understanding the algorithms used
116 | within the different portions of the kernel. It is highly recommended
117 | for anyone wanting to understand the details of how the kernel works.
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | Tool locations
128 |
129 |
130 | A lot of different tools were mentioned in this book. Here are links to
131 | where the source code for these tools can be found on the internet.
132 |
133 |
134 |
135 |
136 |
137 |
138 | Linux kernel
139 |
140 |
141 |
142 |
143 |
144 | http://www.kernel.org and
145 | ftp://ftp.kernel.org contain all of
146 | the different versions of the Linux kernel source code.
147 | http://www.kernel.org/git/ contains
148 | a listing of all git trees in use by the different
149 | kernel developers.
150 |
151 |
152 |
153 |
154 |
155 |
156 | gcc
157 |
158 |
159 |
160 | http://gcc.gnu.org/ is the main site
161 | for everything related to the Gnu C Compiler.
162 |
163 |
164 |
165 |
166 |
167 |
168 | binutils
169 |
170 |
171 |
172 | http://www.gnu.org/software/binutils/
173 | is the main site for all information about binutils.
174 |
175 |
176 |
177 |
178 |
179 |
180 | make
181 |
182 |
183 |
184 | http://www.gnu.org/software/make/
185 | is the main site for all information about make.
186 |
187 |
188 |
189 |
190 |
191 |
192 | util-linux
193 |
194 |
195 |
196 | http://www.kernel.org/pub/linux/utils/util-linux/
197 | is the directory for where all versions of util-linux
198 | can be downloaded.
199 |
200 |
201 |
202 |
203 |
204 |
205 | module-init-tools
206 |
207 |
208 |
209 | http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/
210 | is the directory for where all versions of
211 | module-init-tools can be downloaded.
212 |
213 |
214 |
215 |
216 |
217 |
218 | e2fsprogs
219 |
220 |
221 |
222 | http://e2fsprogs.sourceforge.net/ is
223 | the main project page for the e2fsprogs package.
224 |
225 |
226 |
227 |
228 |
229 |
230 | jfsutils
231 |
232 |
233 |
234 | http://jfs.sourceforge.net/ is the
235 | main project page for the jfsutils package.
236 |
237 |
238 |
239 |
240 |
241 |
242 | reiserfsprogs
243 |
244 |
245 |
246 | http://www.namesys.com/download.html
247 | is the main project page for the reiserfsprogs
248 | package.
249 |
250 |
251 |
252 |
253 |
254 |
255 | xfsprogs
256 |
257 |
258 |
259 | http://oss.sgi.com/projects/xfs/ is
260 | the main project page for the xfsprogs package.
261 |
262 |
263 |
264 |
265 |
266 |
267 | quota-tools
268 |
269 |
270 |
271 | http://sourceforge.net/projects/linuxquota/
272 | is the main project page for the quota-tools package.
273 |
274 |
275 |
276 |
277 |
278 |
279 | nfs-utils
280 |
281 |
282 |
283 | http://nfs.sf.net/ is the main
284 | project page for the nfs-utils package.
285 |
286 |
287 |
288 |
289 |
290 |
291 | udev
292 |
293 |
294 |
295 | http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
296 | is the directory for where all versions of udev can
297 | be downloaded.
298 |
299 |
300 |
301 |
302 |
303 |
304 | procfs
305 |
306 |
307 |
308 | http://procps.sourceforge.net/ is
309 | the main project page for the procfs package.
310 |
311 |
312 |
313 |
314 |
315 |
316 | patchutils
317 |
318 |
319 |
320 | http://cyberelk.net/tim/patchutils
321 | is the location for all of the patchutils releases.
322 |
323 |
324 |
325 |
326 |
327 |
328 | git
329 |
330 |
331 |
332 | http://git.or.cz/ is the main site
333 | for the git project.
334 |
335 |
336 |
337 |
338 |
339 |
340 | ketchup
341 |
342 |
343 |
344 | http://www.selenic.com/ketchup/ is
345 | the main project page for the ketchup program.
346 |
347 |
348 |
349 |
350 |
351 |
352 | quilt
353 |
354 |
355 |
356 | http://savannah.nongnu.org/projects/quilt is
357 | the main project page for the quilt program.
358 |
359 |
360 |
361 |
362 |
363 |
364 | distcc
365 |
366 |
367 |
368 | http://distcc.samba.org/ is
369 | the main project page for the distcc program.
370 |
371 |
372 |
373 |
374 |
375 |
376 | ccache
377 |
378 |
379 |
380 | http://ccache.samba.org/ is
381 | the main project page for the ccache program.
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
--------------------------------------------------------------------------------
/book.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ]>
20 |
21 |
22 | Linux Kernel in a Nutshell
23 |
24 |
25 | First
26 | X-XXXXX-XXX-X
27 |
28 |
29 | Greg
30 | Kroah-Hartman
31 |
32 |
33 |
34 |
35 | ????
36 | ??????
37 |
38 |
39 | 300 pages (est.)
40 | (TBA)
41 |
42 |
43 |
44 | &ch00;
45 | &ch01;
46 | &ch02;
47 | &ch03;
48 | &ch04;
49 | &ch05;
50 | &ch06;
51 | &ch07;
52 | &ch08;
53 | &ch09;
54 | &ch10;
55 | &ch11;
56 | &appa;
57 | &biblio;
58 | &license;
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ch00.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Preface
4 |
5 |
6 | When the topic of this book was first presented to me, I dismissed it as
7 | something that was already covered by the plentiful documentation about the
8 | Linux kernel. Surely someone had already written down all of the basics
9 | needed in order to build, install, and customize the Linux kernel, as it
10 | seemed to be a very simple task to me.
11 |
12 |
13 | Disclaimer: I'm a Linux kernel developer by trade, so things that seem
14 | basic and simple to me at times are completely incomprehensible by most
15 | people, as my family continues to remind me at times.
16 |
17 |
18 |
19 |
20 |
21 | After digging through the different HOWTOs and the Linux kernel
22 | Documentation directory, I came to the conclusion that
23 | there was not any one place where all of this information could be found.
24 | It could be gleaned by referencing a few files here, and a few outdated
25 | websites there, but this was not acceptable for anyone who did not know
26 | exactly what they were looking in the first place.
27 |
28 |
29 |
30 | So this book was created with the goal of consolidating all of the existing
31 | information already scattered around the Internet about building the Linux
32 | kernel, as well as adding a lot of new and useful information that was not written
33 | down anywhere but had been learned by trial and error over my years of
34 | doing kernel development.
35 |
36 |
37 |
38 | My secret goal of this book is to bring more people into the Linux kernel
39 | development fold. The act of building a customized kernel for your machine
40 | is one of the basic tasks needed to become a Linux kernel developer. The
41 | more people that try this out, and realize that there is not any real magic
42 | behind the whole Linux kernel process, the more people will be willing to
43 | jump in and help out in making the kernel the best that it can be.
44 |
45 |
46 |
47 | Audience for the book
48 |
49 |
53 |
54 | This book is intended to cover everything that is needed to know in order
55 | to properly build, customize, and install the Linux kernel. No programming
56 | experience is needed to understand and use this book.
57 |
58 |
59 |
60 | Some familiarity with how to use Linux, and some basic command-line usage
61 | is expected of the reader.
62 |
63 |
64 |
65 | This book is not intended to go into the programming aspects of the Linux
66 | kernel; there are many other good books listed in the Bibliography that
67 | already cover this topic.
68 |
69 |
70 |
71 |
72 |
73 | Organization of the material
74 |
75 |
76 | There are three major parts to this book. The first part is composed of
77 | Chapters 1 through 6, which cover everything you need to know about
78 | retrieving, building, installing, and upgrading the Linux kernel, in
79 | more or less step-by-step fashion.
80 |
81 |
82 |
83 | The second part consists of Chapters 7 and 8, which describe how to properly
84 | configure the kernel based on the hardware present in the system, and
85 | provides a number of different "recipes" for common configurations.
86 |
87 |
88 |
89 | The final part consists of Chapters 9 through 11. These chapters provide
90 | a reference to the different kernel command line options, the kernel build
91 | options, and a select few of the different kernel configuration options.
92 |
93 |
94 |
95 | Chapter 1, Introduction, explains when and why
96 | you would want to build the kernel.
97 |
98 |
99 |
100 | Chapter 2, Requirements For Building and Using the
101 | Kernel, covers the different programs and tools that are needed
102 | in order to properly build the kernel. It also covers a number of
103 | different programs that are tied very closely to the kernel, how to
104 | determine the needed version of the programs, and where to find them.
105 |
106 |
107 |
108 | Chapter 3, Retrieving the kernel source discusses how
109 | the different Linux kernel versions relate to each other, where to retrieve
110 | the Linux kernel source code from, and how to download it properly.
111 |
112 |
113 |
114 | Chapter 4, Configuring and Building explains how to
115 | configure and properly build the Linux kernel.
116 |
117 |
118 |
119 | Chapter 5, Installing and Booting from a Kernel shows
120 | how to install the kernel that has been built properly, and then boot into
121 | that kernel version.
122 |
123 |
124 |
125 | Chapter 6, Upgrading a Kernel explains how to upgrade a
126 | kernel that was previously built to a newer version without having to start
127 | over from nothing.
128 |
129 |
130 |
131 | Chapter 7, Customizing a Kernel discusses how to
132 | customize the kernel for the hardware that is present on the system. It
133 | goes over a variety of different ways to determine what options should be
134 | selected and provides some simple scripts to help with the task.
135 |
136 |
137 |
138 | Chapter 8, Kernel Configuration Recipes explains how to
139 | configure the kernel for a variety of common situations.
140 |
141 |
142 |
143 | Chapter 9, Kernel boot command-line parameter reference
144 | details all of the different command-line options that can be passed to the
145 | kernel, and what the different options do.
146 |
147 |
148 |
149 | Chapter 10, Kernel build command line reference
150 | describes the different command line options that are available when
151 | building the kernel and how to use them.
152 |
153 |
154 |
155 | Chapter 11, Kernel Configuration Option Reference
156 | focuses on a few of the more popular and important Linux kernel
157 | configuration options.
158 |
159 |
160 |
161 | Appendix A, Helpful Utilities introduces a number of
162 | very good and handy tools that everyone who wishes to track the latest
163 | Linux kernel version should use.
164 |
165 |
166 |
167 |
168 |
169 |
170 | Online Version and License
171 |
172 |
173 | This book is freely available under the Creative Commons
174 | "Attribution-ShareAlike" license, Version 2.5. This license can be seen in
175 | its entirety in . The full book is also
176 | available online at
177 | http://www.kroah.com/lkn.
178 |
179 |
180 |
181 |
182 | Conventions Used in This Book
183 |
184 |
185 | This book uses the following typographical conventions:
186 |
187 |
188 |
189 | Italic
190 |
191 |
192 |
200 | Indicates commands and command options, files, directories, usernames, and
201 | hostnames. Also indicates nomenclature that we've not previously used,
202 | emphasized words, and new terms.
203 |
204 |
205 |
206 |
207 |
208 | Constant Width
209 |
210 |
211 | Indicates strings used for kernel configuration, as well as a few
212 | special terms such as device names and distribution packages. Also
213 | used to show the command output, and the contents of text
214 | and program files.
215 |
216 |
217 |
218 |
219 |
220 | Constant Width Bold
221 |
222 |
223 | Used in examples to indicate commands or other text that should be typed
224 | literally by the user.
225 |
226 |
227 |
228 |
229 |
230 | Constant Width Italic
231 |
232 |
233 | Indicates text that you should replace with your own values; for example,
234 | your own name or password. When this appears as part of text that you
235 | should type in, it is shown as
236 | Constant Width Italic Bold.
237 |
238 |
239 |
240 |
241 |
242 | #, $
243 |
244 |
245 | Used in some examples as the root shell prompt
246 | (#) and as the user prompt
247 | ($) under the Bourne or
248 | bash shell.
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 | Indicates a warning or caution.
259 |
260 |
261 |
262 |
263 |
264 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Contact Information
276 |
277 |
278 | Standard O'Reilly contact information goes here...
279 |
280 |
281 |
282 |
283 |
284 |
285 | Acknowledgments
286 |
287 |
288 | Thanks first go to my wonderful wife Shannon and my beautiful children
289 | Madeline and Griffin for their understanding and patience while I took the
290 | time to work on this book. Without their support and prodding, this book
291 | would have never been completed. Special thanks to Shannon for getting me
292 | into Linux kernel development in the first place. Without her effort, I
293 | would be still doing some odd embedded programming job, and would have
294 | never discovered this great community in which to work in.
295 |
296 |
297 |
298 | My editor, Andy Oram, is the driving force behing this book, shaping it
299 | into something that is both readable and informative. His editing skills
300 | and patience as deadlines flew by were instrumental in the creation and
301 | completion of this book.
302 |
303 |
304 |
305 | Also a big thanks go to the original editor of this book, David Brickner,
306 | for giving me the chance to work on this project and believing that I could
307 | complete it, despite the first version weighing in at over 1000 pages.
308 |
309 |
310 |
311 | The technical reviewers for this book were amazing, catching all of the
312 | numerous mistakes and pointing out ommisions that needed to be filled. The
313 | reviewers were (in alphabetic order by first name),
314 | Christian Benvenuti,
315 | Christian Morgner,
316 | Golden G. Richard III,
317 | Jean Delvare,
318 | Jerry Cooperstein,
319 | Michael Boerner,
320 | Rik van Riel, and
321 | Robert Day.
322 |
325 | Any remaining problems are due to me, and not their excellent skills.
326 |
327 |
328 |
329 | A special thanks to Randy Dunlap for going over the kernel boot parameters
330 | with a fine tooth comb and pointing out issues in that chapter. Also to
331 | Kay Sievers, who helped immensely with all of the chapter on customizing
332 | the kernel, and who provided the script at the end of that same chapter.
333 | Without his sysfs help and knowledge, that chapter would
334 | not have been feasible.
335 |
336 |
337 |
338 | And a final special thanks to my 6th grade English teacher, Ms. Gruber, for
339 | teaching me that writing was something that was possible to do, and showing
340 | me the enjoyment in doing it. Without that start, none of this would have
341 | been attainable.
342 |
343 |
344 |
345 |
346 |
347 |
348 |
--------------------------------------------------------------------------------
/ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Introduction
4 |
5 |
6 | Despite its large code base (over 7 million lines of code), the Linux
7 | kernel is the most flexible operating system that has ever been created.
8 | It can be tuned for a wide range of different systems, running on
9 | everything from a radio-controlled model helicoptor, to a cellphone, to the
10 | majority of the largest supercomputers in the world. By customizing the
11 | kernel for your specific environment, it is possible to create something
12 | that is both smaller and faster than the kernel provided by most Linux
13 | distributions. This book will go into how to build and install a custom
14 | kernel, and provide some hints on how to enable specific options that you
15 | will probably wish to use for different situations.
16 |
17 |
18 |
26 |
27 |
28 | No Linux distribution provides the exact kernel most of its users want.
29 | Modern distributions have gotten very accommodating, compiling in support
30 | for every known device, for sound, and even for power conservation. But
31 | you will likely have a need that's different from the majority of users
32 | (and every distribution has to try to meet the needs of the majority). You
33 | may just have different hardware. And when a new kernel comes out, you may
34 | want to start using it without waiting for a distribution to be built
35 | around it.
36 |
37 |
38 |
39 | For a host of reasons, you will want during your Linux career to sometimes
40 | build a kernel, or to tweak the parameters of one you are running. This
41 | book gives you the information you need to understand the kernel from a
42 | user's point of view, and to make the most common changes.
43 |
44 |
45 |
46 | There are also good reasons to take features out of the kernel,
47 | particularly if you are running it on an embedded system or one with a
48 | small form factor.
49 |
50 |
51 |
52 | When tweaking, it's helpful to understand the internals of kernel behavior.
53 | These are beyond the scope of this book, except for brief summaries that
54 | appear with certain options. The bibliography includes references to other
55 | books and material that can give you more background.
56 |
57 |
58 |
59 | Using this book
60 |
61 |
62 |
63 | Do not configure or build your kernel with superuser permissions enabled!
64 |
65 |
66 |
67 |
68 | The previous warning is the most important thing to remember while working through the steps in
69 | this book.
70 | Everything in this book, from downloading the kernel source code,
71 | uncompressing it, configuring the kernel, and building it should be done as
72 | a normal user on the machine. Only the two or three commands it takes to
73 | install a new kernel should be done as the superuser (root).
74 |
75 |
76 |
77 | There have been bugs in the kernel build process in the past, causing some
78 | special files in the /dev directory to be deleted if
79 | the user had superuser permissions while building the Linux kernel.
80 |
81 |
82 | This took quite a while to fix, as none of the primary kernel
83 | developers build kernels as root, so they did not suffer from the bug.
84 | A number of weeks went by before it was finally determined that the act of
85 | building the kernel was the problem.
86 | A number of kernel developers half-jokingly suggested that the bug remain
87 | in, to help prevent anyone from building the kernel as root, but calmer
88 | heads prevailed and the bug in the build system was fixed.
89 |
90 |
91 | There are also issues that can easily arise when uncompressing the Linux
92 | kernel with superuser rights, as some of the files in the kernel
93 | source package will not end up with the proper permissions and will cause build
94 | errors later.
95 |
96 |
97 |
98 | The kernel source code should also never be placed in the
99 | /usr/src/linux/ directory, as that is the location of
100 | the kernel that the system libraries were built against, not your new
101 | custom kernel. Do not do any kernel development under the
102 | /usr/src/ directory tree at all, but only in a local
103 | user directory where nothing bad can happen to the system.
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Requirements for building and using the kernel
4 |
5 |
6 | This chapter describes the programs you need
7 | to configure a kernel, build it, and successfully
8 | boot it. It's a smart idea to consult the file
9 | Documentation/Changes to verify the specific
10 | version number you should have of each
11 | tool described in this chapter. This chapter was based on the 2.6.18
12 | kernel, and describes the versions of tools that work with that
13 | kernel.
14 | If you are using a different kernel, please verify that you
15 | have the required versions as specified in this file, or things
16 | might not work properly and it can be very hard to determine what went
17 | wrong.
18 |
19 |
20 |
44 |
45 |
46 | Tools to build the kernel
47 |
48 |
49 | Most Linux distributions offer an installation option to install a
50 | range of Kernel Hacking packages. If your distribution
51 | offers this option, it is easiest to install this instead of
52 | trying to track down all of the individual programs that are needed for
53 | this task.
54 |
55 |
56 |
57 | Only three packages that are needed in order to
58 | successfully build a kernel: a compiler, a linker, and a make
59 | utility. This section describes the contents of each package.
60 |
61 |
62 |
63 | Compiler
64 |
65 |
66 | The Linux kernel is written in the C programming language, with a small
67 | amount of assembly language in some places. To build the kernel, the GCC C compiler must be
68 | used. Most Linux distributions have a package entitiled
69 | gcc that should be installed. If you wish to download
70 | the compiler and build it yourself, you can find it at
71 | http://gcc.gnu.org.
72 |
73 |
74 |
75 | As of the 2.6.18 kernel release, the 3.2 version of GCC is the oldest that can
76 | properly build a working kernel. Be warned that getting
77 | the most recent GCC version is not always a good idea. Some of the newest GCC
78 | releases don't build the kernel properly, so unless you wish to
79 | help debug compiler bugs, it is not recommended that you try them out.
80 |
81 |
82 |
83 | To determine which version of gcc you have on your system, run the following command:
84 |
85 | $ gcc --version
86 |
87 |
88 |
89 |
90 |
91 |
92 | Linker
93 |
94 |
95 | The C compiler, gcc, does not do all of the compiling on
96 | its own. It needs an additional set of tools known as
97 | binutils to do the linking and assembling of source
98 | files. The binutils package also contains useful
99 | utilities that can manipulate object files in lots of useful ways,
100 | such as to view the contents of a library.
101 |
102 |
103 |
104 | binutils can usually be found in a distribution package
105 | called (not surprisingly) binutils. If you wish to download
106 | and install the package yourself, you can find it at
107 | http://www.gnu.org/software/binutils.
108 |
109 |
110 |
111 | As of the 2.6.18 kernel release, the 2.12 release of
112 | binutils is the oldest that can
113 | successfully link the kernel.
114 | To determine which version of binutils you have on your system, run the following command:
115 |
116 | $ ld -v
117 |
118 |
119 |
120 |
121 |
122 |
123 | Make
124 |
125 |
126 | make is a tool that walks the kernel source tree to
127 | determine which files need to be compiled, and then calls the compiler and
128 | other build tools to do the work in building the kernel. The kernel
129 | requires the GNU version of make, which can usually be found in a package
130 | called make for your distribution.
131 |
132 |
133 |
134 | If you wish to download and install make youself,
135 | you can find it at
136 | http://www.gnu.org/software/make.
137 |
138 |
139 |
140 | As of the 2.6.18 kernel release, the 3.79.1 release of make is the oldest that can
141 | properly build the kernel. It is recommended that you install
142 | the latest stable version of make, because newer versions are known
143 | to work faster at processing the build files.
144 |
145 |
146 |
147 | To determine which version of make you have on your system, run the following command:
148 |
149 | $ make --version
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 | Tools to use the kernel
159 |
160 |
161 | While the version of the kernel that is running does not usually affect any user
162 | application, there are a small number of program for which the kernel
163 | version is important.
164 | This section describes a number of tools that are probably
165 | already installed on your Linux system. If you upgrade your
166 | kernel to a version different from the one that came with your distribution, some
167 | of these packages may also need to be upgraded in order for the system to
168 | work properly.
169 |
170 |
171 |
172 | util-linux
173 |
174 | The util-linux package is a collection of small
175 | utilities that do a wide range of different tasks. Most of these utilities
176 | handle the mounting and creation of disk partitions and manipulation of the
177 | hardware clock in the system.
178 |
184 |
185 |
186 |
187 |
188 | If you wish to download and install the util-linux
189 | package yourself, you can find it at
190 | http://www.kernel.org/pub/linux/utils/util-linux.
191 |
192 |
193 |
194 | As of the 2.6.18 kernel release, the 2.10o release of
195 | util-linux is the oldest that works properly .
196 | It is recommended that you install the latest version of this package,
197 | because new version support new features added to the kernel.
198 | Bind mounts are one example of an
199 | option in newer kernels, and a newer version of
200 | util-linux is needed in order to have them work
201 | properly.
202 |
203 |
204 |
205 | To determine which version of the util-linux package you
206 | have on your system, run the following command:
207 |
208 | $ fdformat --version
209 |
210 |
211 |
212 |
213 |
214 | module-init-tools
215 |
216 |
217 | The module-init-tools package is needed if you wish to
218 | use Linux kernel modules. A kernel module is a loadable chunk of code that
219 | can be added to or removed from the kernel while the kernel is running. It
220 | is useful to compile device drivers as modules and then load only the
221 | ones that correspond to the hardware present in the system. All Linux distributions
222 | use modules in order to load only the needed drivers and options for the
223 | system based on the hardware present, instead of being forced to build all
224 | possible drivers and options in the kernel in one large chunk. By
225 | using modules, memory is saved by loading just the code that is needed to
226 | control the machine properly.
227 |
228 |
229 |
230 | The kernel module loading process underwent a radical change in the 2.6
231 | kernel release. The linker for the module
232 | (the code that resolves all symbols and figures out how to put the pieces
233 | together in memory) is now built into the kernel, which makes the userspace
234 | tools quite small. Older distributions have a package called
235 | modutils that does not work properly with the 2.6
236 | kernel. The module-init-tools package is what you need
237 | to get the 2.6 kernel to work properly with modules.
238 |
239 |
240 |
241 | If you wish to download and install the module-init-tools
242 | package yourself, you can find it at
243 | http://www.kernel.org/pub/linux/utils/kernel/module-init-tools.
244 |
245 |
246 |
247 | As of the 2.6.18 kernel release, the 0.9.10
248 | release of
249 | module-init-tools is the oldest version that works properly . It is recommended that the latest version of this package be
250 | installed, as new features added to the kernel can be used
251 | by newer versions of this package. Blacklisting modules to prevent them
252 | from being automatically loaded by the udev package is
253 | one such option that is present in newer versions of
254 | module-init-tools, but not older ones.
255 |
256 |
257 |
258 | To determine which version of the module-init-tools
259 | package you have on your system, run the following command:
260 |
261 | $ depmod -V
262 |
263 |
264 |
265 |
266 |
267 | Filesystem-specific tools
268 |
269 |
270 | A wide range of tools specific to particular filesystems are necessary to
271 | create, format, configure, and fix disk partitions. The
272 | util-linux package has a few of these utilities, but
273 | some of the more popular filesystems have separate packages that contain the
274 | necessary programs.
275 |
276 |
277 |
278 | ext2/ext3/ext4
279 |
280 |
281 | The ext3 and experimental ext4
282 | filesystems are upgrades of ext2 and can be
283 | managed with the same tools; any recent version of an
284 | ext2-based tool can work with the other two
285 | filesystems as well.
286 |
287 |
288 |
289 | To work with any of these filesystems, you must have the
290 | e2fsprogs package.
291 | If you wish to download and install this package yourself, you can find it at
292 | http://e2fsprogs.sourceforge.net.
293 |
294 |
295 |
296 | As of the 2.6.18 kernel release, the
297 | 1.29 release of
298 | e2fsprogs is the oldest that works properly with the kernel. It is highly recommended that you use the newest version
299 | in order to take advantage of newer features in the ext3 and ext4
300 | filesystems.
301 |
302 |
303 |
304 | To determine which version of e2fsprogs you have
305 | on your system, run the following command:
306 |
307 | $ tune2fs
308 |
309 |
310 |
311 |
312 |
313 | JFS
314 |
315 | To use the JFS filesystem from IBM, you must have the jfsutils pacakge.
316 | If you wish to download and install this package yourself, you can find it at
317 | http://jfs.sourceforge.net.
318 |
319 |
320 |
321 | As of the 2.6.18 kernel release, the 1.1.3 release of
322 | jfsutils is the oldest that works properly with the kernel.
323 | To determine which version of jfsutils you have
324 | on your system, run the following command:
325 |
326 | $ fsck.jfs -V
327 |
328 |
329 |
330 |
331 |
332 | ReiserFS
333 |
334 | To use the ReiserFS filesystem, you must have the reiserfsprogs package.
335 | If you wish to download and install this package yourself, you can find it at
336 | http://www.namesys.com/download.html.
337 |
338 |
339 |
340 | As of the 2.6.18 kernel release, the 3.6.3 release of
341 | reiserfsprogs is the oldest that works properly with the kernel.
342 | To determine which version of reiserfsprogs you have
343 | on your system, run the following command:
344 |
345 | $ reiserfsck -V
346 |
347 |
348 |
349 |
350 |
351 | XFS
352 |
353 |
354 | To use the XFS filesystem from SGI, you must have the
355 | xfsprogs package.
356 | If you wish to download and install this package yourself, you can find it at
357 | http://oss.sgi.com/projects/xfs.
358 |
359 |
360 |
361 | As of the 2.6.18 kernel release, the 2.6.0 release of
362 | xfsprogs is the oldest that works properly with the kernel.
363 | To determine which version of xfsprogs you have
364 | on your system, run the following command:
365 |
366 | $ xfs_db -V
367 |
368 |
369 |
370 |
371 |
372 | Quotas
373 |
374 | To use the quota functionality of the kernel, you must have the
375 | quota-tools package.
376 |
377 |
378 | Some distributions, notably Debian, call this package quota
379 | instead of quota-tools.
380 |
381 |
382 | This package includes programs that let you set quotas on users, provide
383 | statistics on the amount of quota being used by different users, and issue
384 | warnings when people get too close to using up their available filesystem
385 | quota.
386 |
387 |
388 |
389 | If you wish to download and install this package yourself, you can find it at
390 | http://sourceforge.net/projects/linuxquota.
391 |
392 |
393 |
394 | As of the 2.6.18 kernel release, the 3.09 release of
395 | quota-tools is the oldest that works properly with the kernel.
396 | To determine which version of quota-tools you have
397 | on your system, run the following command:
398 |
399 | $ quota -V
400 |
401 |
402 |
403 |
404 |
405 |
406 | NFS
407 |
408 | To use the NFS filesystem properly, you must have the
409 | nfs-utils package.
410 |
411 |
412 | Some distributions, notably Debian, call this package
413 | nfs-common instead of nfs-utils.
414 |
415 |
416 | This package includes programs that let you mount NFS partitions as a
417 | client, and run an NFS server.
418 |
419 |
420 |
421 | If you wish to download and install this package yourself, you can find it at
422 | http://nfs.sf.net.
423 |
424 |
425 |
426 | As of the 2.6.18 kernel release, the 1.0.5 release of
427 | nfs-utils is the oldest that works properly with the kernel
428 | To determine which version of nfs-utils you have
429 | on your system, run the following command:
430 |
431 | $ showmount --version
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 | Other tools
440 |
441 |
442 | There are a few other important programs that are closely tied to the
443 | kernel version. These programs are not usually required in order for the
444 | kernel to work properly, but they enable access to different types of
445 | hardware and functions.
446 |
447 |
448 |
449 | udev
450 |
451 |
452 | udev is a program that enables Linux to provide a
453 | persistent device naming system in the /dev directory.
454 | It also provides a dynamic /dev, much like the
455 | one provided by the older
456 | (and now removed) devfs filesystem.
457 | Almost all Linux distributions use udev to manage the
458 | /dev directory, so it is required in order to properly
459 | boot the machine.
460 |
461 |
462 |
463 | Unfortunately, udev relies on the structure of
464 | /sys, which has been known to change from time to time
465 | with kernel releases. Some of these changes in the past have been known to
466 | break udev, so that your machine will not boot properly.
467 | If you have the latest version of udev recommended
468 | by your kernel kernel, and have problems with it working properly, please
469 | contact the udev developers on the mailing list
470 | available at
471 |
476 | linux-hotplug-devel@lists.sourceforge.net.
477 |
478 |
479 |
480 | It is highly recommended that you use the version of
481 | udev that comes with your Linux distribution, as it is
482 | tied into the distribution specific boot process very tightly. But if you
483 | wish to upgrade udev on your own, you can find it at
484 | http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html.
485 |
486 |
487 |
488 | As of the 2.6.18 kernel release, the 081 release of
489 | udev is the oldest that works properly with the kernel.
490 | It is recommended that you use the latest version of
491 | udev, because
492 | it will work better with newer kernels, due to changes
493 | in how udev and the kernel communicate.
494 |
495 |
496 |
497 | To determine which version of udev you have
498 | on your system, run the following command:
499 |
500 | $ udevinfo -V
501 |
502 |
503 |
504 |
505 |
506 | Process tools
507 |
508 |
509 | The package procps includes the commonly used tools
510 | ps and top, as well as many other
511 | handy tools for managing and monitoring processes running on the system.
512 |
513 |
514 |
515 | If you wish to download and install this package yourself, you can find it at
516 | http://procps.sourceforge.net.
517 |
518 |
519 |
520 | As of the 2.6.18 kernel release, the 3.2.0 release of
521 | procps is the oldest that works properly with the kernel.
522 | To determine which version of procps you have
523 | on your system, run the following command:
524 |
525 | $ ps --version
526 |
527 |
528 |
529 |
530 |
531 | PCMCIA tools
532 |
533 |
534 | In order to properly use PCMCIA devices with Linux, a userspace helper
535 | program must be used to set up the devices. For older kernel versions,
536 | this program was called pcmcia-cs, but that has been
537 | replaced with a much simpler system called pcmciautils.
538 | If you wish to use PCMCIA devices, you must have this package installed for
539 | them to work properly.
540 |
541 |
542 |
543 | If you wish to download and install this package yourself, you can find it at
544 | ftp://ftp.kernel.org/pub/linux/utils/kernel/pcmcia.
545 |
546 |
547 |
548 | As of the 2.6.18 kernel release, the 004 release of
549 | pcmciautils is the oldest that works properly with the kernel. But the latest version is recommended in
550 | order to take advantage of newer features in the PCMCIA subsystem, such as
551 | automatic driver loading when new devices are found.
552 |
553 |
554 |
555 | To determine which version of pcmciautils you have
556 | on your system, run the following command:
557 |
558 | $ pccardctl -V
559 |
560 |
561 |
562 |
563 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
--------------------------------------------------------------------------------
/ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Retrieving the kernel source
5 |
6 |
14 |
15 |
16 |
17 | When you're building your own kernel, you want the latest stable
18 | release. Many distributions provide their own packages of kernel
19 | sources, but these are rarely the most cutting-enge, recent
20 | versions. The distribution packages have the advantage of being built
21 | to be compatible with the compiler and other tools provided by the
22 | distribution
23 | ( explains the importance
24 | of their being compatible) but they may not end up providing the
25 | functionality or performance you want. If you can create your own
26 | environment with the latest kernel, compiler, and other tools, you
27 | will be able to build exactly what you want. This chapter focuses on
28 | determining which kernel sources to download, and how to obtain them.
29 |
30 |
31 |
32 |
33 | What tree to use
34 |
35 |
36 | In the past, the Linux kernel was split into only two trees, the
37 | "development" branch and the "stable" branch. The development branch was
38 | denoted by an odd number for the second release number, while the
39 | stable branch used even numbers. So, as an example, the 2.5.25 release was
40 | a development kernel, while the 2.4.25 release is a stable release.
41 |
42 |
43 |
44 | But after the 2.6 series was created, the kernel developers decided to
45 | abandon this method of having two separate trees, and declared that all
46 | 2.6 kernel releases would be considered "stable", no matter how quickly
47 | development was happening. The few months between the major 2.6
48 | releases would allow kernel developers the time to add new features and
49 | then stabilize them in time for the next release. Combined with this, a
50 | "-stable" kernel branch has been created that releases bugfixes and
51 | security updates for the past kernel release, before the next major 2.6
52 | release happens.
53 |
54 |
55 |
56 | This is all best explained with some examples, illustrated in .
58 | The kernel team released the 2.6.17 kernel as a stable release. Then the
59 | developers started working on new features and started releasing the
60 | -rc versions as development kernels so that people could
61 | help test and debug the changes. After everyone agreed that the
62 | development release was stable enough, it was released as the 2.6.18 kernel.
63 | This whole cycle usually takes about two to three months, depending on a
64 | variety of factors.
65 |
66 |
67 |
68 | Kernel development release cycle
69 |
70 |
71 |
72 |
73 | While the development of the new features was happening, the
74 | 2.6.17.1, 2.6.17.2, and other stable kernel versions were released,
75 | containing bug fixes and security updates.
76 |
77 |
78 |
79 | If you wish to just use the latest kernel for your work, it is recommended that
80 | you use the stable kernel releases. If you wish to help the kernel
81 | developers test the features of the next kernel release and give them
82 | feedback, use the development kernel release. For the purpose of this
83 | chapter, we will assume that you are using a stable kernel release.
84 |
85 |
86 |
87 |
88 | Where to find the kernel source
89 |
90 |
91 | All of the source code for the Linux kernel can be found on one of the
92 | kernel.org sites, a worldwide network of servers that mirror the Linux
93 | source code, enabling everyone to find a local server
94 | close to him. This allows the main kernel servers to be
95 | responsive to the mirror sites, and lets users download the needed files as
96 | quickly as possible.
97 |
98 |
99 |
100 | The main http://www.kernel.org.
101 | site shows all of the current kernel versions for the various different
102 | kernel trees, as shown in .
103 |
104 |
105 | The main kernel.org web site
106 |
107 |
108 |
109 |
110 |
111 | To download the latest stable kernel version, click on the
112 | F character on the line for the kernel version. This
113 | will download the full source tree. Or you can navigate to the proper
114 | subdirectory for all of the 2.6 kernel versions,
115 | http://www.us.kernel.org/pub/linux/kernel/v2.6/,
117 | shown in .
118 |
119 |
120 | The 2.6 kernel source directory
121 |
122 |
123 |
124 |
125 |
126 | It is also possible to download the kernel source from the command line,
127 | using the wget or curl utilities,
128 | both of which should come with your Linux distribution.
129 |
130 |
131 |
132 | To download the 2.6.17.8 kernel version using wget,
133 | enter:
134 |
135 | $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz
136 | --17:44:55-- http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz
137 | => `linux-2.6.17.8.tar.gz'
138 | Resolving www.kernel.org... 204.152.191.5, 204.152.191.37
139 | Connecting to www.kernel.org|204.152.191.5|:80... connected.
140 | HTTP request sent, awaiting response... 200 OK
141 | Length: 51,707,742 (49M) [application/x-gzip]
142 |
143 | 100%[=============================================>] 51,707,742 35.25K/s ETA 00:00
144 |
145 | 18:02:48 (47.12 KB/s) - `linux-2.6.17.8.tar.gz' saved [51707742/51707742]
146 |
147 |
148 | To download it using curl:
149 |
150 | $ curl http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.8.tar.gz -o linux-2.6.17.8.tar.gz
151 | % Total % Received % Xferd Average Speed Time Time Time Current
152 | Dload Upload Total Spent Left Speed
153 | 100 49.3M 100 49.3M 0 0 50298 0 0:17:08 0:17:08 --:--:-- 100k
154 |
155 |
156 |
157 |
158 | For a quick and easy way to determine the latest kernel versions, use
159 | the information available at
160 | http://www.kernel.org/kdist/finger_banner,
162 | illustrated by .
163 |
164 |
165 | Latest kernel version
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 | What to do with the source
174 |
175 |
184 | Now that you have downloaded the proper kernel source, where is it supposed
185 | to go? We suggest creating a local directory in your home directory called
186 | linux/ to hold all of the different kernel source
187 | files:
188 |
189 | $ mkdir ~/linux
190 |
191 | Now move the source code into this directory:
192 |
193 | $ mv ~/linux-2.6.17.8.tar.gz ~/linux/
194 |
195 | And go into the linux/ directory:
196 |
197 | $ cd ~/linux
198 | $ ls
199 | linux-2.6.17.8.tar.gz
200 |
201 | Now that the source code is in the proper directory, we need to uncompress
202 | the tree:
203 |
204 | $ tar -xzvf linux-2.6.17.8.tar.gz
205 |
206 | The screen will be filled with files that are uncompressed, and you
207 | will be left with the following in the linux/
208 | directory:
209 |
210 | $ ls
211 | linux-2.6.17.8.tar.gz
212 | linux-2.6.17.8/
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
--------------------------------------------------------------------------------
/ch05.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Installing and Booting From a Kernel
5 |
6 |
7 |
8 | Previous chapters showed you how to download and build your
9 | kernel. Now that you have an executable file -- along with any
10 | modules you built -- it is time to install the kernel and
11 | attempt to boot it. In this chapter, unlike earlier ones, all of the
12 | commands need to be run as the root user. This can be done by
13 | prefixing each command with sudo, by using the
14 | su command to become root, or actually by logging
15 | in as root.
16 |
17 |
18 |
19 | To see if you have sudo installed and the proper access
20 | set up, do the following:
21 |
22 | $ sudo ls ~/linux/linux-2.6.17.11/Makefile
23 | Password:
24 | Makefile
25 |
26 | Enter either your own password at the password prompt, or the password of
27 | the system administrator (root). The choice depends on how the
28 | sudo command is set up. If
29 | this is successful, and you see the line containing:
30 |
31 | Makefile
32 |
33 | then you can skip to the next section.
34 |
35 |
36 |
37 | If sudo is not installed or giving you the proper
38 | rights, then try using the su command:
39 |
40 | $ su
41 | Password:
42 | # exit
43 | exit
44 | $
45 |
46 | At the password prompt, enter the password of the system administrator
47 | (root). When the su program successfully accepts the
48 | password, you are transferred to running everything with full root
49 | privileges. Be very careful while as root, and do only the minimum needed; then exit the program to continue back as your normal user account.
50 |
51 |
52 |
53 | Using a Distribution's Installation Scripts
54 |
55 | Almost all distributions come with a script called
56 | installkernel that can be used by the kernel build
57 | system to automatically install a built kernel into the proper location and
58 | modify the bootloader so that nothing extra needs to be done by the
59 | developer.
60 |
61 |
62 | Notable exceptions to this rule are Gentoo and other "from scratch" types
63 | distributions, which expect users to know how to install kernels on
64 | their own. These types of distributions include documentation on
65 | how to install a new kernel, so consult it for the exact method
66 | required.
67 |
68 |
69 |
70 |
71 | Distributions that offer installkernel usually put it in a
72 | package called mkinitrd, so try install that package if you
73 | cannot find the script on your machine.
74 |
75 |
76 | If you have built any modules and want to use use this method to install a kernel, first enter:
77 |
78 | # make modules_install
79 |
80 | This will install all the modules that you have built and place them in
81 | the proper location in the filesystem for the new kernel to properly find.
82 | Modules are placed in the /lib/modules/KERNEL_VERSION
83 | directory, where KERNEL_VERSION is the kernel version of
84 | the new kernel you have just built.
85 |
86 |
87 |
88 | After the modules have been successfully installed, the main kernel image
89 | must be installed:
90 |
91 | # make install
92 |
93 | This will kick off the following process:
94 |
95 |
96 |
97 | The kernel build system will verify that the kernel has been successfully
98 | built properly.
99 |
100 |
101 |
102 |
103 | The build system will install the static kernel portion into the /boot
104 | directory and name this executable file based on the kernel version of the built kernel.
105 |
106 |
107 |
108 |
109 |
110 |
116 | Any needed initial ramdisk images will be automatically created, using the
117 | modules that have just been installed during the
118 | modules_install phase.
119 |
120 |
121 |
122 |
123 |
124 | The bootloader program will be properly notified that a new kernel is
125 | present, and it will be added to the appropriate menu so the user can
126 | select it the
127 | next the machine is booted.
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | After this is finished, the kernel is successfully installed, and you can
136 | safely reboot and try out your new kernel image. Note that this
137 | installation does not overwrite any older kernel images, so if there is a
138 | problem with your new kernel image, the old kernel can be selected at boot
139 | time.
140 |
141 |
142 |
143 |
144 |
145 | Installing By Hand
146 |
147 |
148 | If your distributtion does not have a installkernel command, or
149 | you wish to just do the work by hand to understand the steps involved, here
150 | are the steps involved.
151 |
152 |
153 |
154 |
155 |
156 | The modules must be installed:
157 |
158 | # make modules_install
159 |
160 |
161 |
162 |
163 |
164 |
165 | The static kernel image must be copied into the /boot
166 | directory. For an i386-based kernel, do the
167 | following:
168 |
169 | # make kernelversion
170 | 2.6.17.11
171 |
172 | Note that the kernel version will probably be different for your kernel.
173 | Use this value in place of the text KERNEL_VERSION in
174 | all of the following steps:
175 |
176 | # cp arch/i386/boot/bzImage /boot/bzImage-KERNEL_VERSION
177 | # cp System.map /boot/System.map-KERNEL_VERSION
178 |
179 |
180 |
181 |
182 |
183 |
184 | Modify the bootloader so it knows about the new kernel. This involves
185 | editing a configuration file for the bootloader you use, and is
186 | covered later in for the
187 | GRUB and LILO bootloaders.
188 |
189 |
190 |
191 |
192 |
193 | If the boot process does not work properly, it's usually because an initial ramdisk image is needed. To create this properly, use
194 | the steps in the beginning of this chapter for installing a kernel
195 | automatically, because the distribution install scripts know how to properly
196 | create the ramdisk using the needed scripts and tools. Because each
197 | distribution does this differently, it is beyond the scope of this book to
198 | cover all of the different methods of building the ramdisk image.
199 |
200 |
201 |
202 | Here is a handy script that can be used to install the kernel automatically
203 | instead of having to type the previous commands all the time:
204 |
205 | #!/bin/sh
206 | #
207 | # installs a kernel
208 | #
209 | make modules_install
210 |
211 | # find out what kernel version this is
212 | for TAG in VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION ; do
213 | eval `sed -ne "/^$TAG/s/ //gp" Makefile`
214 | done
215 | SRC_RELEASE=$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION
216 |
217 | # figure out the architecture
218 | ARCH=`grep "CONFIG_ARCH " include/linux/autoconf.h | cut -f 2 -d "\""`
219 |
220 | # copy the kernel image
221 | cp arch/$ARCH/boot/bzImage /boot/bzImage-"$SRC_RELEASE"
222 |
223 | # copy the System.map file
224 | cp System.map /boot/System.map-"$SRC_RELEASE"
225 |
226 | echo "Installed $SRC_RELEASE for $ARCH"
227 |
228 |
229 |
230 |
231 |
232 |
233 | Modifying the Bootloader For the New Kernel
234 |
235 |
236 | There are two common Linux kernel bootloaders: GRUB and LILO. GRUB
237 | is the one more commonly used
238 | in modern distributions, and does some things a little more easily than
239 | LILO, but LILO is still seen as well. We'll cover both in this section.
240 |
241 |
242 |
243 | To determine which bootloader your system uses, look in the
244 | /boot/ directory. If there is a
245 | grub subdirectory:
246 |
247 | $ ls -F /boot | grep grub
248 | grub/
249 |
250 | then you are using the GRUB program to boot with. If
251 | this directory is not present, look for the presence of the
252 | /etc/lilo.conf file:
253 |
254 | $ ls /etc/lilo.conf
255 | /etc/lilo.conf
256 |
257 | If this is present, you are using the LILO program
258 | to boot with.
259 |
260 |
261 |
262 | The steps involved in adding a new kernel to each of these programs are
263 | different, so follow only the section that corrisponds to the program you
264 | are using.
265 |
266 |
267 |
268 | GRUB
269 |
270 |
271 | To let GRUB know that a new kernel is present, all you need
272 | to do is modify the /boot/grub/menu.lst file.
273 | For full details on the structure of this file, and all of the different
274 | options available, please see the GRUB info pages:
275 |
276 | $ info grub
277 |
278 |
279 |
280 |
281 | The easiest way to add a new kernel entry to the
282 | /boot/grub/menu.lst file is to copy an existing
283 | entry. For example, consider the following menu.lst
284 | file from a Gentoo system:
285 |
286 | timeout 300
287 | default 0
288 |
289 | splashimage=(hd0,0)/grub/splash.xpm.gz
290 |
291 | title 2.6.16.11
292 | root (hd0,0)
293 | kernel /bzImage-2.6.16.11 root=/dev/sda2 vga=0x0305
294 |
295 | title 2.6.16
296 | root (hd0,0)
297 | kernel /bzImage-2.6.16 root=/dev/sda2 vga=0x0305
298 |
299 | The line starting with the word title defines a new
300 | kernel entry, so this file contains two entries. Simply copy the lines from one instance of the
301 | title word to the next one, such as :
302 |
303 | title 2.6.16.11
304 | root (hd0,0)
305 | kernel /bzImage-2.6.16.11 root=/dev/sda2 vga=0x0305
306 |
307 | to the end of the file, and edit the version number to contain the version
308 | number of the new kernel you just installed.
309 |
314 | The title does not matter, so long as it is unique, but it is
315 | displayed in the boot menu, so you should make it something meaningful. In our example, we installed
316 | the 2.6.17.11 kernel, so the final copy of the file
317 | looks like:
318 |
319 | timeout 300
320 | default 0
321 |
322 | splashimage=(hd0,0)/grub/splash.xpm.gz
323 |
324 | title 2.6.16.11
325 | root (hd0,0)
326 | kernel /bzImage-2.6.16.11 root=/dev/sda2 vga=0x0305
327 |
328 | title 2.6.16
329 | root (hd0,0)
330 | kernel /bzImage-2.6.16 root=/dev/sda2 vga=0x0305
331 |
332 | title 2.6.17.11
333 | root (hd0,0)
334 | kernel /bzImage-2.6.17.11 root=/dev/sda2 vga=0x0305
335 |
336 |
337 |
338 |
339 | After you save the file, reboot the system and ensure that the new
340 | kernel image's title comes up in the boot menu. Use the down arrow to
341 | highlight the new kernel version, and press Enter to
342 | boot the new kernel image.
343 |
344 |
345 |
355 |
356 |
357 |
358 |
359 |
360 | LILO
361 |
362 |
363 | To let LILO know that a new kernel is present, you must modify the
364 | /etc/lilo.conf configuration file and then run the
365 | lilo command to apply the changes made to
366 | the configuration file. For full details on the structure of the
367 | LILO configuration file, please see the
368 | LILO man page:
369 |
370 | $ man lilo
371 |
372 |
373 |
374 |
375 | The easiest way to add a new kernel entry to the
376 | /etc/lilo.conf file is to copy an existing
377 | entry. For example, consider the following LILO
378 | configuration file from a Gentoo system:
379 |
380 | boot=/dev/hda
381 | prompt
382 | timeout=50
383 | default=2.6.12
384 |
385 | image=/boot/bzImage-2.6.15
386 | label=2.6.15
387 | read-only
388 | root=/dev/hda2
389 |
390 | image=/boot/bzImage-2.6.12
391 | label=2.6.12
392 | read-only
393 | root=/dev/hda2
394 |
395 | The line starting with the word image= defines a new
396 | kernel entry, so this file contains two entries. Simply copy the lines from one instance of the
397 | image= word to the next one, such as:
398 |
399 | image=/boot/bzImage-2.6.15
400 | label=2.6.15
401 | read-only
402 | root=/dev/hda2
403 |
404 | to the end of the file, and edit the version number to contain the version
405 | number of the new kernel you just installed. The label does not matter, so long as it is unique, but it is
406 | displayed in the boot menu, so you should make it something meaningful. In our example, we installed
407 | the 2.6.17.11 kernel, so the final copy of the file
408 | looks like:
409 |
410 | boot=/dev/hda
411 | prompt
412 | timeout=50
413 | default=2.6.12
414 |
415 | image=/boot/bzImage-2.6.15
416 | label=2.6.15
417 | read-only
418 | root=/dev/hda2
419 |
420 | image=/boot/bzImage-2.6.12
421 | label=2.6.12
422 | read-only
423 | root=/dev/hda2
424 |
425 | image=/boot/bzImage-2.6.17
426 | label=2.6.17
427 | read-only
428 | root=/dev/hda2
429 |
430 |
431 |
432 |
433 | After you save the file, run the /sbin/lilo program
434 | to write the configuration changes out to the boot section of
435 | the disk:
436 |
437 | # /sbin/lilo
438 |
439 | Now the system can be safely rebooted. The new kernel choice can be seen
440 | in the list of kernels that are available at boot time. Use the down arrow
441 | to highlight the new kernel version, and press Enter to
442 | boot the new kernel image.
443 |
444 |
445 |
455 |
456 |
457 |
458 |
459 |
468 |
469 |
470 |
471 |
472 |
473 |
--------------------------------------------------------------------------------
/ch06.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Upgrading a kernel
5 |
6 |
7 |
8 | Inevitably it happens, you have a custom built kernel, working just
9 | wonderfully except for one little thing that you know is fixed in the
10 | latest release from the kernel developers. Or a security problem is found,
11 | and a new stable kernel release is made public. Either way, you are faced
12 | with the issue of upgrading the kernel and you do not want to lose all the
13 | time and effort that went into making that perfect kernel configuration.
14 |
15 |
16 |
17 | This chapter is going to show how easy it is to update a kernel from an
18 | older versions, while still retaining all of the configuration options from
19 | the previous one.
20 |
21 |
22 |
23 | First off, please back up the .config file in the
24 | kernel source directory. You have spent some time and effort into
25 | creating it, and it should be saved in case something goes wrong when
26 | trying to upgrade.
27 |
28 | $ cd ~/linux/linux-2.6.17.11
29 | $ cp .config ../good_config
30 |
31 |
32 |
33 |
34 | There are only five simple steps that are needed to upgrade a kernel from a
35 | previously built one:
36 |
37 |
38 |
39 | Get the new source code.
40 |
41 |
42 |
43 |
44 | Apply the changes to the old source tree to bring it up to the newer level.
45 |
46 |
47 |
48 |
49 | Reconfigure the kernel based on the previous kernel configuration.
50 |
51 |
52 |
53 |
54 | Build the new kernel.
55 |
56 |
57 |
58 |
59 | Install the new kernel.
60 |
61 |
62 |
63 |
64 | The last two steps work the same as described before, so we will only
65 | discuss the first three steps in this chapter.
66 |
67 |
68 |
69 | In this chapter, we are going to assume that you have built a successful
70 | 2.6.17.9 kernel release, and want to upgrade to the 2.6.17.11 release.
71 |
72 |
73 |
74 | Download the new source
75 |
76 |
77 | The Linux kernel developers realize that all users do not wish to download
78 | the entire source code to the kernel for every update. That would be a
79 | waste of bandwidth and time. Because of this, they offer a patch
80 |
81 |
82 | It is called patch because the program
83 | patch takes the file and applies it to the original
84 | tree, creating the new tree. The patch file contains a representation of
85 | the changes that are necessary to reconstruct the new files, based on the
86 | old ones. Patch files are readable, and contain a list of the lines that
87 | are to be removed and the lines that are to be added, with some context
88 | within the file showing where the changes should be made.
89 |
90 |
91 | that can upgrade an older kernel release, to a newer one.
92 |
93 |
94 |
95 | On the main kernel.org website, you will remember that
96 | it contained a list of the current kernel versions that are available for
97 | download:
98 |
99 | The main kernel.org web site
100 |
101 |
102 |
103 |
104 |
105 | Previously, you used the link pointed to you by the F to
106 | download the entire source code for the kernel. However, if you click on
107 | the name of the kernel release, it will download a patch file instead:
108 |
109 | Downloading a patch from kernel.org
110 |
111 |
112 | This is what we want to do when upgrading. But we need to figure out what
113 | patch to download.
114 |
115 |
116 |
117 | Which patch applies to which release?
118 |
119 |
120 | A kernel patch file only will upgrade the source code from one specific
121 | release to another specific release. Here is how the different patch files
122 | can be applied:
123 |
124 |
125 |
126 | Stable kernel patches apply to the base kernel version. This means that
127 | the 2.6.17.10 patch will only apply to the 2.6.17 kernel release. The
128 | 2.6.17.10 kernel patch will not apply to the 2.6.17.9 kernel or any other
129 | release.
130 |
131 |
132 |
133 |
134 | Base kernel release patches only apply to the previous base kernel version.
135 | This means that the 2.6.18 patch will only apply to the 2.6.17 kernel
136 | release. It will not apply to the last 2.6.17.y kernel release, or any
137 | other release.
138 |
139 |
140 |
141 |
142 |
143 | Incremental patches upgrade from a specific release to the next release.
144 | This allows developers to not have to downgrade their kernel and then
145 | upgrade it, just to switch from the latest stable release to the next
146 | stable release (remember that the stable release patches are only against
147 | the base kernel, not the previous stable release.) Whenever possible, it
148 | is recommended that you use the incremental patches to make your life
149 | easier.
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 | Finding the patch
160 |
161 |
162 | As we want to go from the 2.6.17.9 kernel release, to the 2.6.17.11
163 | release, we will need to download two different patches. We will need a
164 | patch from the 2.6.17.9 release to the 2.6.17.10 release, and then from the
165 | 2.6.17.10 release to the 2.6.17.11 release.
166 |
167 |
168 | If you need to upgrade more than two versions, it is recommended as a way
169 | to save steps, to go backwards, and then upgrade forward. In this case, we
170 | could go backward from 2.6.17.9 to 2.6.17 and then forward from 2.6.17 to
171 | 2.6.17.11.
172 |
173 |
174 |
175 |
176 |
177 | The stable and base kernel patches are located in the same directory
178 | structure as the main source trees. All incremental patches can be found
179 | one level lower, in the incr subdirectory. So, to
180 | find the patch that goes from 2.6.17.9 to 2.6.17.10, we look in the
181 | /pub/linux/kernel/v2.6/incr directory to find the
182 | files we need:
183 |
184 |
185 | In this example, we use the very good lftp FTP program
186 | to download the patch files. Any ftp program or a web browser can be used
187 | to download the same files. The important thing here is to show where the
188 | files are located.
189 |
190 |
191 |
192 | $ cd ~/linux
193 | $ lftp ftp.kernel.org/pub/linux/kernel/v2.6/incr
194 | cd ok, cwd=/pub/linux/kernel/v2.6/incr
195 | lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr> ls *2.6.17.9*.bz2
196 | -rw-rw-r-- 1 536 536 2872 Aug 22 19:23 patch-2.6.17.9-10.bz2
197 | lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr> get patch-2.6.17.9-10.bz2
198 | 2872 bytes transferred
199 | lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr> get patch-2.6.17.10-11.bz2
200 | 7901 bytes transferred
201 | lftp ftp.kernel.org:/pub/linux/kernel/v2.6/incr> exit
202 | $ ls -F
203 | good_config linux-2.6.17.9/ patch-2.6.17.10-11.bz2 patch-2.6.17.9-10.bz2
204 |
205 |
206 |
207 |
208 |
209 |
210 | Applying the patch
211 |
212 |
213 | As the patches we have downloaded are compressed, the first thing to do is
214 | uncompress them with the bzip2 command:
215 |
216 | $ bzip2 -dv patch-2.6.17.9-10.bz2
217 | patch-2.6.17.9-10.bz2: done
218 | $ bzip2 -dv patch-2.6.17.10-11.bz2
219 | patch-2.6.17.10-11.bz2: done
220 | $ ls -F
221 | good_config linux-2.6.17.9/ patch-2.6.17.10-11 patch-2.6.17.9-10
222 |
223 |
224 |
225 |
226 | Now we need to apply the patch files to the kernel directory. Go into the
227 | directory:
228 |
229 | $ cd linux-2.6.17.9
230 |
231 | and run the patch program to apply the first patch
232 | moving the source tree from the 2.6.17.9 to the 2.6.17.10 release:
233 |
234 | $ patch -p1 < ../patch-2.6.17.9-10
235 | patching file Makefile
236 | patching file block/elevator.c
237 | patching file fs/udf/super.c
238 | patching file fs/udf/truncate.c
239 | patching file include/net/sctp/sctp.h
240 | patching file include/net/sctp/sm.h
241 | patching file net/sctp/sm_make_chunk.c
242 | patching file net/sctp/sm_statefuns.c
243 | patching file net/sctp/socket.c
244 |
245 | Verify that the patch really did work properly and that there are no errors
246 | or warnings in the output of the patch program. It is also a good idea to
247 | look at the Makefile of the kernel to see the kernel
248 | version:
249 |
250 | $ $ head -n 5 Makefile
251 | VERSION = 2
252 | PATCHLEVEL = 6
253 | SUBLEVEL = 17
254 | EXTRAVERSION = .10
255 | NAME=Crazed Snow-Weasel
256 |
257 |
258 |
259 |
260 | Now that the kernel is at the 2.6.17.10 release level, do the same thing as
261 | before and apply the patch to bring it up to the 2.6.17.11 level:
262 |
263 | $ patch -p1 < ../patch-2.6.17.10-11
264 | patching file Makefile
265 | patching file arch/ia64/kernel/sys_ia64.c
266 | patching file arch/sparc/kernel/sys_sparc.c
267 | patching file arch/sparc64/kernel/sys_sparc.c
268 | patching file drivers/char/tpm/tpm_tis.c
269 | patching file drivers/ieee1394/ohci1394.c
270 | patching file drivers/md/dm-mpath.c
271 | patching file drivers/md/raid1.c
272 | patching file drivers/net/sky2.c
273 | patching file drivers/pci/quirks.c
274 | patching file drivers/serial/Kconfig
275 | patching file fs/befs/linuxvfs.c
276 | patching file fs/ext3/super.c
277 | patching file include/asm-generic/mman.h
278 | patching file include/asm-ia64/mman.h
279 | patching file include/asm-sparc/mman.h
280 | patching file include/asm-sparc64/mman.h
281 | patching file kernel/timer.c
282 | patching file lib/spinlock_debug.c
283 | patching file mm/mmap.c
284 | patching file mm/swapfile.c
285 | patching file net/bridge/netfilter/ebt_ulog.c
286 | patching file net/core/dst.c
287 | patching file net/core/rtnetlink.c
288 | patching file net/ipv4/fib_semantics.c
289 | patching file net/ipv4/netfilter/arp_tables.c
290 | patching file net/ipv4/netfilter/ip_tables.c
291 | patching file net/ipv4/netfilter/ipt_ULOG.c
292 | patching file net/ipv4/route.c
293 | patching file net/ipx/af_ipx.c
294 | patching file net/netfilter/nfnetlink_log.c
295 |
296 | Again verify that the output of the patch program did not show any errors
297 | and look at the Makefile:
298 |
299 | $ head -n 5 Makefile
300 | VERSION = 2
301 | PATCHLEVEL = 6
302 | SUBLEVEL = 17
303 | EXTRAVERSION = .11
304 | NAME=Crazed Snow-Weasel
305 |
306 |
307 |
308 |
309 | Now that the source code is successfully updated to the version you wish to
310 | use, it is a good idea to go back and change the directory name to refer to
311 | the kernel version number so that confusion does not occur at a later time:
312 |
313 | $ cd ..
314 | $ mv linux-2.6.17.9 linux-2.6.17.11
315 | $ ls -F
316 | good_config linux-2.6.17.11/ patch-2.6.17.10-11 patch-2.6.17.9-10
317 |
318 |
319 |
320 |
321 |
322 |
323 | Reconfigure the kernel
324 |
325 |
326 | Previously, we used the make menuconfig or
327 | gconfig or xconfig method to change
328 | different configuration options. But once you have a working
329 | configuration, the only thing that is necessary is to update it with any
330 | new options that have been added to the kernel since the last release. To
331 | do this, the make oldconfig and
332 | make silentoldconfig options should be used.
333 |
334 |
335 |
336 | make oldconfig takes the current kernel configuration in
337 | the .config file, and updates it based on the new
338 | kernel release. To do this, it prints out all configuration questions, and
339 | provides an answer for them if the option is already handled in the
340 | configuration file. If there is a new option, the program stops and asks
341 | the user what the new configuration value should be set to. After
342 | answering the prompt, the program continues on until the whole kernel
343 | configuration is finished.
344 |
345 |
346 |
347 | make silentoldconfig works exactly the same way as
348 | oldconfig does, but it does not print anything to the
349 | screen, unless it needs to ask a question about a new configuration option.
350 |
351 |
352 |
353 | Usually, when upgrading between different versions of the stable releases,
354 | no new configuration options are added, as this is supposed to be a
355 | stable kernel series. If this happens, there are no new
356 | questions that need to be answered for the kernel configuration, so the
357 | program continues successfully without any need for user intervention. An
358 | example of this is moving from the 2.6.17.9 to 2.6.17.11 release:
359 |
360 | $ cd linux-2.6.17.11
361 | $ make silentoldconfig
362 | scripts/kconfig/conf -s arch/i386/Kconfig
363 | #
364 | # using defaults found in .config
365 | #
366 |
367 |
368 |
369 |
370 | An example for where a new kernel option shows up in a new release is the
371 | following. The kernel option to enable Mutex debugging
372 | is a new one when switching between certain kernel releases. Here is the
373 | output when this happened:
374 |
375 | $ make silentoldconfig
376 | scripts/kconfig/conf -s arch/i386/Kconfig
377 | #
378 | # using defaults found in .config
379 | #
380 | *
381 | * Restart config...
382 | *
383 | *
384 | * Kernel hacking
385 | *
386 | Show timing information on printks (PRINTK_TIME) [Y/n/?] y
387 | Magic SysRq key (MAGIC_SYSRQ) [Y/n/?] y
388 | Kernel debugging (DEBUG_KERNEL) [Y/n/?] y
389 | Kernel log buffer size (16 => 64KB, 17 => 128KB) (LOG_BUF_SHIFT) [16] 16
390 | Detect Soft Lockups (DETECT_SOFTLOCKUP) [Y/n/?] y
391 | Collect scheduler statistics (SCHEDSTATS) [N/y/?] n
392 | Debug slab memory allocations (DEBUG_SLAB) [Y/n/?] y
393 | Memory leak debugging (DEBUG_SLAB_LEAK) [Y/n] y
394 | Mutex debugging, deadlock detection (DEBUG_MUTEXES) [N/y/?] (NEW) y
395 |
396 | The configuration program stopped at this option and asked for the user to
397 | choose an option. Then press y and the program
398 | continues on:
399 |
400 | Spinlock debugging (DEBUG_SPINLOCK) [Y/n/?] y
401 | Sleep-inside-spinlock checking (DEBUG_SPINLOCK_SLEEP) [Y/n/?] y
402 | kobject debugging (DEBUG_KOBJECT) [N/y/?] n
403 | Highmem debugging (DEBUG_HIGHMEM) [N/y/?] n
404 | Compile the kernel with debug info (DEBUG_INFO) [N/y/?] n
405 | Debug Filesystem (DEBUG_FS) [Y/?] y
406 | Debug VM (DEBUG_VM) [N/y/?] n
407 | Compile the kernel with frame pointers (FRAME_POINTER) [N/y/?] n
408 | Compile the kernel with frame unwind information (UNWIND_INFO) [N/y/?] n
409 | Force gcc to inline functions marked 'inline' (FORCED_INLINING) [N/y/?] n
410 | torture tests for RCU (RCU_TORTURE_TEST) [N/m/y/?] n
411 | Check for stack overflows (DEBUG_STACKOVERFLOW) [N/y/?] n
412 | Stack utilization instrumentation (DEBUG_STACK_USAGE) [N/y/?] n
413 | Stack backtraces per line (STACK_BACKTRACE_COLS) [2] 2
414 | *
415 | * Page alloc debug is incompatible with Software Suspend on i386
416 | *
417 | Write protect kernel read-only data structures (DEBUG_RODATA) [N/y/?] n
418 | Use 4Kb for kernel stacks instead of 8Kb (4KSTACKS) [N/y/?] n
419 |
420 |
421 |
422 |
423 | So upgrading the kernel configuration for a new release is as simple as
424 | using a different configuration option to make. With
425 | this method, you do not need to use the graphical or text oriented
426 | configuration programs for any new kernel update.
427 |
428 |
429 |
430 |
431 |
432 | Can't this be automated?
433 |
434 |
435 | The whole process of downloading the proper patch file, uncompressing it,
436 | and then applying it seems to be ripe for automating. Kernel developers
437 | being the type that like to automate repetitive tasks, the program
438 | ketchup has been created to handle all of this
439 | automatically. See for more details on how
440 | this program works and how to use it.
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
--------------------------------------------------------------------------------
/ch10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Kernel build command line reference
5 |
6 |
7 |
8 | As discussed in , the tool that
9 | ties together kernel builds is the make program, to
10 | which you pass a target that specifies what you want to build. went over the basic targets needed
12 | to build the kernel properly, but the kernel build system also has a
13 | wide range of other targets. This chapter details these targets, and
14 | what they can be used for.
15 |
16 |
17 |
18 | All of these targets are passed to the make program on
19 | the command line, and a number of them can be grouped together if
20 | desired. For example:
21 |
22 | $ make mrproper xconfig
23 |
24 |
25 | The targets are broken down into different types in the following
26 | sections.
27 |
28 |
29 |
30 | You can get a summary of most of these targets by running, within the build directory:
31 |
32 | $ make help
33 |
34 | This target prints out a lot of the common make
35 | targets that are described in the rest of this chapter.
36 |
37 |
38 |
39 | Informational Targets
40 |
41 | These targets print the kernel version, based on a number of different
42 | options. They are commonly used by scripts to determine the
43 | version of the kernel being built.
44 |
45 |
46 |
47 | Informational targets
48 |
49 |
50 |
51 | Target
52 | Description
53 |
54 |
55 |
56 |
57 | kernelrelease
58 | Displays the current kernel version, as determined by the build
59 | system.
60 |
61 |
62 | kernelversion
63 | Displays the current kernel version, as told by the main Makefile. This differs from the
64 | kernelrelease target in that it doesn't use
65 | any additional version
66 | information based on configuration options or localversion files.
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Cleaning Targets
75 |
76 |
77 | These targets simply remove files from previous builds. Their use is
78 | highly recommended to make sure you don't contaminate new builds with
79 | files left over that may have been built with different options. They
80 | differ in how much they remove; sometimes you want to keep around
81 | files you've changed.
82 |
83 |
84 |
85 | Cleaning targets
86 |
87 |
88 |
89 | Target
90 | Description
91 |
92 |
93 |
94 |
95 | clean
96 | Removes most of the files generated by the kernel build
97 | system, but keep the kernel configuration.
98 |
99 |
100 | mrproper
101 | Removes all of the generated files by the kernel build
102 | system, including the configuration and some
103 | various backup files.
104 |
105 |
106 | distclean
107 | Does everything mrproper does and removes some
108 | editor backup and patch leftover files.
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | Configuration Targets
117 |
118 |
119 | These targets allow the kernel to be configured in a wide range of different ways.
120 |
121 |
122 |
123 | Configuration targets
124 |
125 |
126 |
127 | Target
128 | Description
129 |
130 |
131 |
132 |
133 | config
134 | Updates the current kernel configuration by using a
135 | line-oriented program.
136 |
137 |
138 | menuconfig
139 | Updates the current kernel configuration by using a text
140 | based menu program.
141 |
142 |
143 | xconfig
144 | Updates the current kernel configuration by using a QT-based graphical program.
145 |
146 |
147 | gconfig
148 | Updates the current kernel configuration by using a GTK+-based graphical program.
149 |
150 |
151 | oldconfig
152 | Updates the current kernel configuration by using the
153 | current .config file and prompting for any new options that have been
154 | added to the kernel.
155 |
156 |
157 | silentoldconfig
158 | Just like oldconfig, but prints nothing to the screen except when a question needs to be
159 | answered.
160 |
161 |
162 | randconfig
163 | Generates a new kernel configuration with random answers
164 | to all of the different options.
165 |
166 |
167 | defconfig
168 | Generates a new kernel configuration with the default
169 | answer being used for all options. The default
170 | values are taken from a file located in the
171 | arch/$ARCH/defconfig file, where
172 | $ARCH refers to the specific architecture
173 | for which
174 | the kernel is being built.
175 |
176 |
177 | allmodconfig
178 | Generates a new kernel configuration in which modules
179 | are enabled whenever possible.
180 |
181 |
182 | allyesconfig
183 | Generates a new kernel configuration with all options
184 | set to yes.
185 |
186 |
187 | allnoconfig
188 | Generates a new kernel configuration with all options
189 | set to no.
190 |
191 |
192 |
193 |
194 |
195 |
196 | Note that the allyesconfig,
197 | allmodconfig,
198 | allnoconfig, and
199 | randconfig targets also take advantage of the
200 | environment variable KCONFIG_ALLCONFIG. If that
201 | variable points to a file, that file will be used as a list of
202 | configuration values that you require to be set to a specific
203 | value. In other words, the file overrides the normal behavior of the
204 | make targets.
205 |
206 |
207 |
208 | For example, if the file ~/linux/must_be_set contains
209 | the following variables:
210 |
211 | $ cat ~/linux/must_be_set
212 | CONFIG_SWAP=y
213 | CONFIG_DEBUG_FS=y
214 |
215 | and you enter make allnoconfig with the proper
216 | KCONFIG_ALLCONFIG environment variable in effect:
217 |
218 | $ KCONFIG_ALLCONFIG=../must_be_set make allnoconfig
219 | $ grep CONFIG_SWAP .config
220 | CONFIG_SWAP=y
221 |
222 | then the results include:
223 |
224 | $ grep CONFIG_DEBUG_FS .config
225 | CONFIG_DEBUG_FS=y
226 |
227 | This variable would not have normally been set to y
228 | otherwise.
229 |
230 |
231 |
232 | If the KCONFIG_ALLCONFIG variable is not set, the build
233 | system checks for files in the top-level build directory named:
234 |
235 |
236 |
237 |
238 |
239 | allmod.config
240 |
241 |
242 |
243 |
244 |
245 | allno.config
246 |
247 |
248 |
249 |
250 |
251 | allrandom.config
252 |
253 |
254 |
255 |
256 |
257 | allyes.config
258 |
259 |
260 |
261 |
262 |
263 | If any of those files are present, the build uses them as lists of configuration values that must be
264 | forced to the specified values. If none of those files are found, the build
265 | system finally looks for a file called all.config for a
266 | list of forced configuration values.
267 |
268 |
269 |
270 | You can use these different files to set up a known good base
271 | configuration that will always work. Then the other configuration options
272 | can be used to generate different testing configurations for the needed
273 | situation.
274 |
275 |
276 |
277 |
278 |
279 |
280 | Build Targets
281 |
282 | These targets build the kernel itself in a variety of ways.
283 |
284 |
285 |
286 | Build targets
287 |
288 |
289 |
290 | Target
291 | Description
292 |
293 |
294 |
295 |
296 | all
297 | Builds all of the different targets needed for
298 | this kernel to be able to be used. This includes both the modules and
299 | the static portion of the kernel.
300 |
301 |
302 |
303 | vmlinux
304 | Builds just the static portion of the kernel,
305 | not any loadable modules.
306 |
307 |
308 |
309 | modules
310 | Builds all of the loadable kernel modules for
311 | this configuration.
312 |
313 |
314 |
315 | modules_install
316 | Installs all of the modules into the specified
317 | location. If no location is specified with the
318 | INSTALL_MODULE_PATH environment variable, they are
319 | installed in the default root directory of the machine.
320 |
321 |
322 |
323 | dir/
324 | Builds all of the files in the specified
325 | directory and in all subdirectories below it.
326 |
327 |
328 |
329 | dir/file.[o|i|s]
330 | Builds only the specified file.
331 |
332 |
333 |
334 | dir/file.ko
335 | Builds all of the needed files and links
336 | them together to form the specified module.
337 |
338 |
339 |
340 |
348 | tags
349 | Builds all of the needed tags that most common
350 | text editors can use while editing the source code.
351 |
352 |
353 |
354 | TAGS
355 | Builds all of the needed tags that most common
356 | text editors can use while editing the source code.
357 |
358 |
359 |
360 | cscope
361 | Builds a cscope image, useful
362 | in source tree searches, of the source tree for
363 | the architecture specified by the configuration file (not all
364 | of the kernel source files).
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 | You can also pass a number of environment variables to make
373 | that will change the build. These can be specified for
374 | almost any target.
375 |
376 |
377 |
378 | Environment variables
379 |
380 |
381 |
382 | Variable
383 | Value
384 | Description
385 |
386 |
387 |
388 |
389 | V
390 | 0
391 | This tells the build system to run in a quiet manner,
392 | showing only the file that is currently being built, and not the entire
393 | command that is running in order to build that file. This is the
394 | default option for the build system.
395 |
396 |
397 |
398 | V
399 | 1
400 | This tells the build system to operate in a verbose way,
401 | showing the full command that is being used to generate each of the
402 | specific files.
403 |
404 |
405 |
406 | O
407 | dir
408 | This tells the build system to locate all output files in
409 | the dir directory, including the kernel
410 | configuration files. This allows the kernel to be built from a
411 | read-only filesystem and have the output placed in another location.
412 |
413 |
414 |
415 | C
416 | 1
417 | This checks all C files that are about to be built with
418 | the sparse tool, which detects common programming errors in the kernel
419 | source files.
420 | sparse can be downloaded using
421 | git from
422 | git://git.kernel.org/pub/scm/devel/sparse/sparse.git.
423 | Nightly snapshots can be found at
424 | http://www.codemonkey.org.uk/projects/git-snapshots/sparse/.
425 | More information on how to use sparse can be
426 | found in the Documentation/sparse.txt file in
427 | the kernel source tree.
428 |
429 |
430 |
431 | C
432 | 2
433 | This forces all C files to be checked with the
434 | sparse tool, even if they did not need to be built.
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 | Packaging Targets
444 |
445 | These targets package up a built kernel into a stand-alone package that can be
446 | installed on a wide range of different machines.
447 |
448 |
449 |
450 | Packaging targets
451 |
452 |
453 |
454 | Target
455 | Description
456 |
457 |
458 |
459 |
460 | rpm
461 | Builds the kernel first and then packages
462 | it up as a RPM package that can be installed.
463 |
464 |
465 |
466 | rpm-pkg
467 | Builds a source RPM package containing the base kernel.
468 |
469 |
470 |
471 | binrpm-pkg
472 | Builds a RPM package that contains a compiled kernel and modules.
473 |
474 |
475 |
476 | deb-pkg
477 | Builds a Debian package that contains the compiled kernel and modules.
478 |
479 |
480 |
481 | tar-pkg
482 | Builds a tarball that contains the compiled kernel and modules.
483 |
484 |
485 |
486 | targz-pkg
487 | Builds a gzip-compressed tarball that contains the compiled kernel and modules.
488 |
489 |
490 |
491 | tarbz2-pkg
492 | Builds a bzip2-compressed tarball that contains the compiled kernel and modules.
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 | Documentation Targets
502 |
503 | These targets build the internal kernel documentation in a variety of
504 | different formats.
505 |
506 |
507 |
508 | Documentation targets
509 |
510 |
511 |
512 | Target
513 | Description
514 |
515 |
516 |
517 |
518 | xmldocs
519 | Builds the kernel documentation as XML DocBook files.
520 |
521 |
522 |
523 | psdocs
524 | Builds the kernel documentation as PostScript files.
525 |
526 |
527 |
528 | pdfdocs
529 | Builds the kernel documentation as PDF files.
530 |
531 |
532 |
533 | htmldocs
534 | Builds the kernel documentation as HTML files.
535 |
536 |
537 |
538 | mandocs
539 | Builds the kernel documentation as a set of man
540 | pages, which can then be installed with the installmandocs target.
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 | Architecture-Specific Targets
550 |
551 | Each kernel architecture has a set of specific targets unique to it. The
552 | 32-bit Intel architecture has the following targets available.
553 |
554 |
555 | 32-bit Intel Architecture-Specific Targets
556 |
557 |
558 |
559 | Target
560 | Description
561 |
562 |
563 |
564 |
565 | bzImage
566 | Creates a compressed kernel image and places it in
567 | the arch/i386/boot/bzImage file. This is the
568 | default target for the i386 kernel build.
569 |
570 |
571 |
572 | install
573 | Installs the kernel image using the distribution-specific /sbin/installkernel program. Note that
574 | this does not install the kernel modules; that must be done with the
575 | modules_install target.
576 |
577 |
578 |
579 | bzdisk
580 | Creates a boot floppy image and writes it to the
581 | /dev/fd0 device.
582 |
583 |
584 |
585 | fdimage
586 | Creates a boot floppy image and places it in the
587 | file arch/i386/boot/fdimage. The
588 | mtools package must be present on your system in
589 | order for this to work properly.
590 |
591 |
592 |
593 | isoimage
594 | Creates a CD-ROM boot image and places it in the
595 | file arch/i396/boot/image.iso. The
596 | syslinux package must be present on your system in
597 | order for this to work properly.
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 | Analysis Targets
607 |
608 | These targets are good for trying to find problem code in the kernel.
609 |
616 | It's a good idea to create a
617 | stack space list when creating new code to determine that your
618 | changes are not taking up too much kernel stack space. The
619 | namespacecheck target is useful for determining whether your
620 | changes can safely add its symbols to the kernel's global namespace.
621 |
622 |
623 |
624 | Analysis targets
625 |
626 |
627 |
628 | Target
629 | Description
630 |
631 |
632 |
633 |
634 | checkstack
635 | Generate a list of the functions that use the most of the kernel stack space.
636 |
637 |
638 |
639 | namespacecheck
640 | Generate a list of all of the kernel symbols and
641 | their namespaces. This will be a large list.
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
--------------------------------------------------------------------------------
/images/config_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/config_search.png
--------------------------------------------------------------------------------
/images/config_search_found.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/config_search_found.png
--------------------------------------------------------------------------------
/images/config_search_pl2303.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/config_search_pl2303.png
--------------------------------------------------------------------------------
/images/config_search_pl2303_found.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/config_search_pl2303_found.png
--------------------------------------------------------------------------------
/images/gconfig_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/gconfig_1.png
--------------------------------------------------------------------------------
/images/gconfig_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/gconfig_2.png
--------------------------------------------------------------------------------
/images/gconfig_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/gconfig_3.png
--------------------------------------------------------------------------------
/images/kernel.org.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel.org.png
--------------------------------------------------------------------------------
/images/kernel.org.v2.6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel.org.v2.6.png
--------------------------------------------------------------------------------
/images/kernel.org_finger_banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel.org_finger_banner.png
--------------------------------------------------------------------------------
/images/kernel.org_patch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel.org_patch.png
--------------------------------------------------------------------------------
/images/kernel_releases.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel_releases.dia
--------------------------------------------------------------------------------
/images/kernel_releases.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/kernel_releases.png
--------------------------------------------------------------------------------
/images/menuconfig_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_1.png
--------------------------------------------------------------------------------
/images/menuconfig_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_2.png
--------------------------------------------------------------------------------
/images/menuconfig_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_3.png
--------------------------------------------------------------------------------
/images/menuconfig_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_4.png
--------------------------------------------------------------------------------
/images/menuconfig_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_5.png
--------------------------------------------------------------------------------
/images/menuconfig_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/menuconfig_6.png
--------------------------------------------------------------------------------
/images/xconfig_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/xconfig_1.png
--------------------------------------------------------------------------------
/images/xconfig_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/xconfig_2.png
--------------------------------------------------------------------------------
/images/xconfig_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregkh/lkn/e844c3a470a3c463361d92e6242c4391e519ef57/images/xconfig_3.png
--------------------------------------------------------------------------------
/license.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | License
4 |
5 |
6 | The following is the full text of the "Attribution-ShareAlike 2.5" license,
7 | which this book is licensed under.
8 |
9 |
10 |
11 |
12 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
13 | COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
14 | COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
15 | AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
16 |
17 |
18 |
19 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO
20 | BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS
21 | CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
22 | CONDITIONS.
23 |
24 |
25 |
26 | Definitions
27 |
28 |
29 |
30 |
31 |
32 |
33 | "Collective Work" means a work, such as a periodical issue, anthology or
34 | encyclopedia, in which the Work in its entirety in unmodified form, along
35 | with a number of other contributions, constituting separate and independent
36 | works in themselves, are assembled into a collective whole. A work that
37 | constitutes a Collective Work will not be considered a Derivative Work (as
38 | defined below) for the purposes of this License.
39 |
40 |
41 |
42 |
43 |
44 | "Derivative Work" means a work based upon the Work or upon the Work and
45 | other pre-existing works, such as a translation, musical arrangement,
46 | dramatization, fictionalization, motion picture version, sound recording,
47 | art reproduction, abridgment, condensation, or any other form in which the
48 | Work may be recast, transformed, or adapted, except that a work that
49 | constitutes a Collective Work will not be considered a Derivative Work for
50 | the purpose of this License. For the avoidance of doubt, where the Work is
51 | a musical composition or sound recording, the synchronization of the Work
52 | in timed-relation with a moving image ("synching") will be considered a
53 | Derivative Work for the purpose of this License.
54 |
55 |
56 |
57 |
58 |
59 | "Licensor" means the individual or entity that offers the Work under the
60 | terms of this License.
61 |
62 |
63 |
64 |
65 |
66 | "Original Author" means the individual or entity who created the Work.
67 |
68 |
69 |
70 |
71 |
72 | "Work" means the copyrightable work of authorship offered under the terms
73 | of this License.
74 |
75 |
76 |
77 |
78 |
79 | "You" means an individual or entity exercising rights under this License
80 | who has not previously violated the terms of this License with respect to
81 | the Work, or who has received express permission from the Licensor to
82 | exercise rights under this License despite a previous violation.
83 |
84 |
85 |
86 |
87 |
88 | "License Elements" means the following high-level license attributes as
89 | selected by Licensor and indicated in the title of this License:
90 | Attribution, ShareAlike.
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | Fair Use Rights
100 |
101 |
102 | Nothing in this license is intended to reduce, limit, or restrict any
103 | rights arising from fair use, first sale or other limitations on the
104 | exclusive rights of the copyright owner under copyright law or other
105 | applicable laws.
106 |
107 |
108 |
109 |
110 |
111 | License Grant
112 |
113 |
114 | Subject to the terms and conditions of this License, Licensor hereby grants
115 | You a worldwide, royalty-free, non-exclusive, perpetual (for the duration
116 | of the applicable copyright) license to exercise the rights in the Work as
117 | stated below:
118 |
119 |
120 |
121 |
122 |
123 | to reproduce the Work, to incorporate the Work into one or more Collective
124 | Works, and to reproduce the Work as incorporated in the Collective Works;
125 |
126 |
127 |
128 |
129 |
130 | to create and reproduce Derivative Works;
131 |
132 |
133 |
134 |
135 |
136 | to distribute copies or phonorecords of, display publicly, perform
137 | publicly, and perform publicly by means of a digital audio transmission the
138 | Work including as incorporated in Collective Works;
139 |
140 |
141 |
142 |
143 |
144 | to distribute copies or phonorecords of, display publicly, perform
145 | publicly, and perform publicly by means of a digital audio transmission
146 | Derivative Works.
147 |
148 |
149 |
150 |
151 |
152 | For the avoidance of doubt, where the work is a musical composition:
153 |
154 |
155 |
156 | Performance Royalties Under Blanket Licenses. Licensor waives the exclusive
157 | right to collect, whether individually or via a performance rights society
158 | (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public
159 | digital performance (e.g. webcast) of the Work.
160 |
161 |
162 |
163 |
164 |
165 | Mechanical Rights and Statutory Royalties. Licensor waives the exclusive
166 | right to collect, whether individually or via a music rights society or
167 | designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You
168 | create from the Work ("cover version") and distribute, subject to the
169 | compulsory license created by 17 USC Section 115 of the US Copyright Act
170 | (or the equivalent in other jurisdictions).
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | Webcasting Rights and Statutory Royalties. For the avoidance of doubt,
180 | where the Work is a sound recording, Licensor waives the exclusive right to
181 | collect, whether individually or via a performance-rights society (e.g.
182 | SoundExchange), royalties for the public digital performance (e.g. webcast)
183 | of the Work, subject to the compulsory license created by 17 USC Section
184 | 114 of the US Copyright Act (or the equivalent in other jurisdictions).
185 |
186 |
187 |
188 |
189 |
190 |
191 | The above rights may be exercised in all media and formats whether now
192 | known or hereafter devised. The above rights include the right to make such
193 | modifications as are technically necessary to exercise the rights in other
194 | media and formats. All rights not expressly granted by Licensor are hereby
195 | reserved.
196 |
197 |
198 |
199 |
200 |
201 | Restrictions
202 |
203 |
204 | The license granted in Section 3 above is expressly made subject to and
205 | limited by the following restrictions:
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 | You may distribute, publicly display, publicly perform, or publicly
214 | digitally perform the Work only under the terms of this License, and You
215 | must include a copy of, or the Uniform Resource Identifier for, this
216 | License with every copy or phonorecord of the Work You distribute, publicly
217 | display, publicly perform, or publicly digitally perform. You may not offer
218 | or impose any terms on the Work that alter or restrict the terms of this
219 | License or the recipients' exercise of the rights granted hereunder. You
220 | may not sublicense the Work. You must keep intact all notices that refer to
221 | this License and to the disclaimer of warranties. You may not distribute,
222 | publicly display, publicly perform, or publicly digitally perform the Work
223 | with any technological measures that control access or use of the Work in a
224 | manner inconsistent with the terms of this License Agreement. The above
225 | applies to the Work as incorporated in a Collective Work, but this does not
226 | require the Collective Work apart from the Work itself to be made subject
227 | to the terms of this License. If You create a Collective Work, upon notice
228 | from any Licensor You must, to the extent practicable, remove from the
229 | Collective Work any credit as required by clause 4(c), as requested. If You
230 | create a Derivative Work, upon notice from any Licensor You must, to the
231 | extent practicable, remove from the Derivative Work any credit as required
232 | by clause 4(c), as requested.
233 |
234 |
235 |
236 |
237 |
238 | You may distribute, publicly display, publicly perform, or publicly
239 | digitally perform a Derivative Work only under the terms of this License, a
240 | later version of this License with the same License Elements as this
241 | License, or a Creative Commons iCommons license that contains the same
242 | License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan).
243 | You must include a copy of, or the Uniform Resource Identifier for, this
244 | License or other license specified in the previous sentence with every copy
245 | or phonorecord of each Derivative Work You distribute, publicly display,
246 | publicly perform, or publicly digitally perform. You may not offer or
247 | impose any terms on the Derivative Works that alter or restrict the terms
248 | of this License or the recipients' exercise of the rights granted
249 | hereunder, and You must keep intact all notices that refer to this License
250 | and to the disclaimer of warranties. You may not distribute, publicly
251 | display, publicly perform, or publicly digitally perform the Derivative
252 | Work with any technological measures that control access or use of the Work
253 | in a manner inconsistent with the terms of this License Agreement. The
254 | above applies to the Derivative Work as incorporated in a Collective Work,
255 | but this does not require the Collective Work apart from the Derivative
256 | Work itself to be made subject to the terms of this License.
257 |
258 |
259 |
260 |
261 |
262 | If you distribute, publicly display, publicly perform, or publicly
263 | digitally perform the Work or any Derivative Works or Collective Works, You
264 | must keep intact all copyright notices for the Work and provide, reasonable
265 | to the medium or means You are utilizing: (i) the name of the Original
266 | Author (or pseudonym, if applicable) if supplied, and/or (ii) if the
267 | Original Author and/or Licensor designate another party or parties (e.g. a
268 | sponsor institute, publishing entity, journal) for attribution in
269 | Licensor's copyright notice, terms of service or by other reasonable means,
270 | the name of such party or parties; the title of the Work if supplied; to
271 | the extent reasonably practicable, the Uniform Resource Identifier, if any,
272 | that Licensor specifies to be associated with the Work, unless such URI
273 | does not refer to the copyright notice or licensing information for the
274 | Work; and in the case of a Derivative Work, a credit identifying the use of
275 | the Work in the Derivative Work (e.g., "French translation of the Work by
276 | Original Author," or "Screenplay based on original Work by Original
277 | Author"). Such credit may be implemented in any reasonable manner;
278 | provided, however, that in the case of a Derivative Work or Collective
279 | Work, at a minimum such credit will appear where any other comparable
280 | authorship credit appears and in a manner at least as prominent as such
281 | other comparable authorship credit.
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 | Representations, Warranties and Disclaimer
290 |
291 |
292 | UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE
293 | WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
294 | CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
295 | INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
296 | FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT
297 | OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER
298 | OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF
299 | IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
300 |
301 |
302 |
303 |
304 |
305 | Limitation on Liability
306 |
307 |
308 | EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR
309 | BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL,
310 | CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR
311 | THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY
312 | OF SUCH DAMAGES.
313 |
314 |
315 |
316 |
317 | Termination
318 |
319 |
320 |
321 |
322 |
323 |
324 | This License and the rights granted hereunder will terminate automatically
325 | upon any breach by You of the terms of this License. Individuals or
326 | entities who have received Derivative Works or Collective Works from You
327 | under this License, however, will not have their licenses terminated
328 | provided such individuals or entities remain in full compliance with those
329 | licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of
330 | this License.
331 |
332 |
333 |
334 |
335 |
336 | Subject to the above terms and conditions, the license granted here is
337 | perpetual (for the duration of the applicable copyright in the Work).
338 | Notwithstanding the above, Licensor reserves the right to release the Work
339 | under different license terms or to stop distributing the Work at any time;
340 | provided, however that any such election will not serve to withdraw this
341 | License (or any other license that has been, or is required to be, granted
342 | under the terms of this License), and this License will continue in full
343 | force and effect unless terminated as stated above.
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 | Miscellaneous
353 |
354 |
355 |
356 |
357 |
358 |
359 | Each time You distribute or publicly digitally perform the Work or a
360 | Collective Work, the Licensor offers to the recipient a license to the Work
361 | on the same terms and conditions as the license granted to You under this
362 | License.
363 |
364 |
365 |
366 |
367 |
368 | Each time You distribute or publicly digitally perform a Derivative Work,
369 | Licensor offers to the recipient a license to the original Work on the same
370 | terms and conditions as the license granted to You under this License.
371 |
372 |
373 |
374 |
375 |
376 | If any provision of this License is invalid or unenforceable under
377 | applicable law, it shall not affect the validity or enforceability of the
378 | remainder of the terms of this License, and without further action by the
379 | parties to this agreement, such provision shall be reformed to the minimum
380 | extent necessary to make such provision valid and enforceable.
381 |
382 |
383 |
384 |
385 |
386 | No term or provision of this License shall be deemed waived and no breach
387 | consented to unless such waiver or consent shall be in writing and signed
388 | by the party to be charged with such waiver or consent.
389 |
390 |
391 |
392 |
393 |
394 | This License constitutes the entire agreement between the parties with
395 | respect to the Work licensed here. There are no understandings, agreements
396 | or representations with respect to the Work not specified here. Licensor
397 | shall not be bound by any additional provisions that may appear in any
398 | communication from You. This License may not be modified without the mutual
399 | written agreement of the Licensor and You.
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
--------------------------------------------------------------------------------
/lkn_outline:
--------------------------------------------------------------------------------
1 | Proposed Linux Kernel in a Nutshell chapter outline:
2 |
3 | 1 - Introduction or Foreword from some other kernel developer
4 | 2 - Kernel History and Background (just a few pages)
5 | 3 - Requirements to build a kernel
6 | 4 - Retrieving the kernel source
7 | 5 - Building a kernel
8 | - use the the default configuration options
9 | - basic options to make (full coverage will be in later
10 | chapter).
11 | - building a kernel with the source in one place, and the output
12 | in another.
13 | - building only a portion of the kernel tree
14 | - building a kernel for a different architecture
15 | 6 - Installing a built kernel and booting with it
16 | - grub
17 | - lilo
18 | - other boot loaders
19 | 7 - Upgrading the kernel to the next version
20 | - retrieving the patch
21 | - applying the patch
22 | - updating the configuration
23 | - building the updated kernel
24 | 8 - Configuring a kernel
25 | - text methods
26 | - make config
27 | - make oldconfig
28 | - make menuconfig
29 | - graphical methods
30 | - make xconfig
31 | - make gconfig
32 | 9 - Recipies for creating configurations
33 | - Disks
34 | - USB storage
35 | - SATA
36 | - cdrom burning
37 | - Devices
38 | - USB
39 | - firewire / ieee1394
40 | - PCI hotplug
41 | - PCMCIA
42 | - Sound (ALSA)
43 | - CPU
44 | - processor types
45 | - suspend
46 | - cpu frequency scaling
47 | - ACPI
48 | - SMP
49 | - different memory models
50 | - Preemption
51 | - Network stuff
52 | - Netfilter
53 | - network drivers
54 | - Irda
55 | - wireless
56 | - Filesystems
57 | - RAID
58 | - LVM
59 | - DM
60 | - Samba
61 | - Journaling filesystems
62 | - OCFS2
63 | - Security
64 | - SELinux
65 | - BSD Secure Levels
66 | - Kernel debugging
67 | 10 - Customizing the initramfs / initrd image
68 | 11 - Kernel boot command line reference
69 | 12 - Kernel build command line reference
70 | 13 - Kernel configuration option reference
71 | - will be only the most "important" ones, and will be the bulk
72 | of the book (although the previous chapters will not be
73 | "light".)
74 |
75 | Appendixes:
76 | - Becoming a kernel programmer
77 | - basics of creating a patch
78 | - how to submit a valid patch and to whom
79 | - kernelnewbies
80 | - kernel janitor project
81 | - Managing changes made to a kernel source tree
82 | - based on the ideas presented at
83 | http://www.linuxjournal.com/article/6183
84 | - Creating useful bug reports
85 | - decoding a oops message
86 | - what a kernel developer wants to see in a bug report.
87 | - who to send the report to.
88 | - email
89 | - bugzilla.kernel.org
90 |
--------------------------------------------------------------------------------
/lkn_proposal:
--------------------------------------------------------------------------------
1 |
2 | "Linux Kernel in a Nutshell" book proposal.
3 |
4 | This book would provide a full reference for how to build a customized
5 | version of the Linux kernel. It will cover all of the needed basics,
6 | and go into full detail with all of the different kernel configuration,
7 | build, and boot options that are available.
8 |
9 | The book will only cover the 2.6 kernel, and hopefully the most recent
10 | version possible.
11 |
12 | It will not cover any programming topics, and no programming experience
13 | will be needed to understand and use the book. However some additional
14 | information in the appendix will be present to help people out in
15 | becoming kernel developers, if they so wish.
16 |
17 | The book will be released under the Creative Commons
18 | Attibution-ShareAlike License, as defined at
19 | http://creativecommons.org/licenses/by-sa/2.0/
20 | and also be available in full online, in the same formats as the book
21 | "Linux Device Drivers".
22 |
23 |
24 | Proposed chapter outline:
25 |
26 | - Introduction or Foreword from some other kernel developer
27 | - Kernel History and Background (just a few pages)
28 | - Requirements to build a kernel
29 | - Retrieving the kernel source
30 | - Building a kernel
31 | - use the the default configuration options
32 | - basic options to make (full coverage will be in later
33 | chapter).
34 | - building a kernel with the source in one place, and the output
35 | in another.
36 | - building only a portion of the kernel tree
37 | - building a kernel for a different architecture
38 | - Installing a built kernel and booting with it
39 | - grub
40 | - lilo
41 | - other boot loaders
42 | - Upgrading the kernel to the next version
43 | - retrieving the patch
44 | - applying the patch
45 | - updating the configuration
46 | - building the updated kernel
47 | - Configuring a kernel
48 | - customizing it for the hardware on your machine
49 | - building modules
50 | - Common configuration options
51 | - USB
52 | - power management
53 | - acpi
54 | - filesystems
55 | - firewire
56 | - other common things that users need.
57 | - Customizing the initramfs / initrd image
58 | - Kernel boot command line reference
59 | - Kernel build command line reference
60 | - Kernel configuration option reference
61 | - will be only the most "important" ones, and will be the bulk
62 | of the book (although the previous chapters will not be
63 | "light".)
64 |
65 | Appendixes:
66 | - Becoming a kernel programmer
67 | - basics of creating a patch
68 | - how to submit a valid patch and to whom
69 | - kernelnewbies
70 | - kernel janitor project
71 | - Managing changes made to a kernel source tree
72 | - based on the ideas presented at
73 | http://www.linuxjournal.com/article/6183
74 | - Creating useful bug reports
75 | - decoding a oops message
76 | - what a kernel developer wants to see in a bug report.
77 | - who to send the report to.
78 | - email
79 | - bugzilla.kernel.org
80 |
81 |
82 | About the author:
83 |
84 | Greg Kroah-Hartman is the Linux kernel maintainer of more subsystems
85 | that he wants to admit (USB, PCI, I2C, and the driver core being a few
86 | of them.) He is also one of the co-authors of the book, "Linux Device
87 | Drivers", and is a contributing editor for Linux Journal Magazine,
88 | publishing a bi-monthly column about Linux driver development. He
89 | has worked as a Linux kernel engineer for the past 5 years, and been
90 | involved in the Linux kernel community for much longer.
91 |
92 |
--------------------------------------------------------------------------------
/rst/.gitignore:
--------------------------------------------------------------------------------
1 | _build
2 |
--------------------------------------------------------------------------------
/rst/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | PAPER =
8 | BUILDDIR = _build
9 |
10 | # Internal variables.
11 | PAPEROPT_a4 = -D latex_paper_size=a4
12 | PAPEROPT_letter = -D latex_paper_size=letter
13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
14 |
15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
16 |
17 | help:
18 | @echo "Please use \`make ' where is one of"
19 | @echo " html to make standalone HTML files"
20 | @echo " dirhtml to make HTML files named index.html in directories"
21 | @echo " singlehtml to make a single large HTML file"
22 | @echo " pickle to make pickle files"
23 | @echo " json to make JSON files"
24 | @echo " htmlhelp to make HTML files and a HTML help project"
25 | @echo " qthelp to make HTML files and a qthelp project"
26 | @echo " devhelp to make HTML files and a Devhelp project"
27 | @echo " epub to make an epub"
28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
29 | @echo " latexpdf to make LaTeX files and run them through pdflatex"
30 | @echo " text to make text files"
31 | @echo " man to make manual pages"
32 | @echo " changes to make an overview of all changed/added/deprecated items"
33 | @echo " linkcheck to check all external links for integrity"
34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)"
35 |
36 | clean:
37 | -rm -rf $(BUILDDIR)/*
38 |
39 | html:
40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
41 | @echo
42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
43 |
44 | dirhtml:
45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
46 | @echo
47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
48 |
49 | singlehtml:
50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
51 | @echo
52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
53 |
54 | pickle:
55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
56 | @echo
57 | @echo "Build finished; now you can process the pickle files."
58 |
59 | json:
60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
61 | @echo
62 | @echo "Build finished; now you can process the JSON files."
63 |
64 | htmlhelp:
65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
66 | @echo
67 | @echo "Build finished; now you can run HTML Help Workshop with the" \
68 | ".hhp project file in $(BUILDDIR)/htmlhelp."
69 |
70 | qthelp:
71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
72 | @echo
73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \
74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LinuxKernelNutshell.qhcp"
76 | @echo "To view the help file:"
77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LinuxKernelNutshell.qhc"
78 |
79 | devhelp:
80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
81 | @echo
82 | @echo "Build finished."
83 | @echo "To view the help file:"
84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/LinuxKernelNutshell"
85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/LinuxKernelNutshell"
86 | @echo "# devhelp"
87 |
88 | epub:
89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
90 | @echo
91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
92 |
93 | latex:
94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
95 | @echo
96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \
98 | "(use \`make latexpdf' here to do that automatically)."
99 |
100 | latexpdf:
101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
102 | @echo "Running LaTeX files through pdflatex..."
103 | make -C $(BUILDDIR)/latex all-pdf
104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
105 |
106 | text:
107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
108 | @echo
109 | @echo "Build finished. The text files are in $(BUILDDIR)/text."
110 |
111 | man:
112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
113 | @echo
114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
115 |
116 | changes:
117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
118 | @echo
119 | @echo "The overview file is in $(BUILDDIR)/changes."
120 |
121 | linkcheck:
122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
123 | @echo
124 | @echo "Link check complete; look for any errors in the above output " \
125 | "or in $(BUILDDIR)/linkcheck/output.txt."
126 |
127 | doctest:
128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
129 | @echo "Testing of doctests in the sources finished, look at the " \
130 | "results in $(BUILDDIR)/doctest/output.txt."
131 |
132 | pdf:
133 | $(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) _build/pdf
134 | @echo
135 | @echo 'Build finished. The PDF files are in _build/pdf.'
136 |
--------------------------------------------------------------------------------
/rst/ch00.rst:
--------------------------------------------------------------------------------
1 | =======
2 | Preface
3 | =======
4 |
5 | When the topic of this book was first presented to me, I dismissed it as
6 | something that was already covered by the plentiful documentation about the
7 | Linux kernel. Surely someone had already written down all of the basics
8 | needed in order to build, install, and customize the Linux kernel, as it
9 | seemed to be a very simple task to me.
10 |
11 |
12 | Disclaimer: I'm a Linux kernel developer by trade, so things that seem
13 | basic and simple to me at times are completely incomprehensible by most
14 | people, as my family continues to remind me at times.
15 |
16 |
17 | After digging through the different HOWTOs and the Linux kernel
18 | Documentation directory, I came to the conclusion that
19 | there was not any one place where all of this information could be found.
20 | It could be gleaned by referencing a few files here, and a few outdated
21 | websites there, but this was not acceptable for anyone who did not know
22 | exactly what they were looking in the first place.
23 |
24 | So this book was created with the goal of consolidating all of the existing
25 | information already scattered around the Internet about building the Linux
26 | kernel, as well as adding a lot of new and useful information that was not written
27 | down anywhere but had been learned by trial and error over my years of
28 | doing kernel development.
29 |
30 | My secret goal of this book is to bring more people into the Linux kernel
31 | development fold. The act of building a customized kernel for your machine
32 | is one of the basic tasks needed to become a Linux kernel developer. The
33 | more people that try this out, and realize that there is not any real magic
34 | behind the whole Linux kernel process, the more people will be willing to
35 | jump in and help out in making the kernel the best that it can be.
36 |
37 | Audience for the book
38 | =====================
39 |
40 |
44 |
45 | This book is intended to cover everything that is needed to know in order
46 | to properly build, customize, and install the Linux kernel. No programming
47 | experience is needed to understand and use this book.
48 |
49 | Some familiarity with how to use Linux, and some basic command-line usage
50 | is expected of the reader.
51 |
52 | This book is not intended to go into the programming aspects of the Linux
53 | kernel; there are many other good books listed in the Bibliography that
54 | already cover this topic.
55 |
56 |
57 | Organization of the material
58 | ============================
59 |
60 | There are three major parts to this book. The first part is composed of
61 | Chapters 1 through 6, which cover everything you need to know about
62 | retrieving, building, installing, and upgrading the Linux kernel, in
63 | more or less step-by-step fashion.
64 |
65 | The second part consists of Chapters 7 and 8, which describe how to properly
66 | configure the kernel based on the hardware present in the system, and
67 | provides a number of different "recipes" for common configurations.
68 |
69 | The final part consists of Chapters 9 through 11. These chapters provide
70 | a reference to the different kernel command line options, the kernel build
71 | options, and a select few of the different kernel configuration options.
72 |
73 | Chapter 1, Introduction, explains when and why
74 | you would want to build the kernel.
75 |
76 | Chapter 2, Requirements For Building and Using the
77 | Kernel, covers the different programs and tools that are needed
78 | in order to properly build the kernel. It also covers a number of
79 | different programs that are tied very closely to the kernel, how to
80 | determine the needed version of the programs, and where to find them.
81 |
82 | Chapter 3, Retrieving the kernel source discusses how
83 | the different Linux kernel versions relate to each other, where to retrieve
84 | the Linux kernel source code from, and how to download it properly.
85 |
86 | Chapter 4, Configuring and Building explains how to
87 | configure and properly build the Linux kernel.
88 |
89 | Chapter 5, Installing and Booting from a Kernel shows
90 | how to install the kernel that has been built properly, and then boot into
91 | that kernel version.
92 |
93 | Chapter 6, Upgrading a Kernel explains how to upgrade a
94 | kernel that was previously built to a newer version without having to start
95 | over from nothing.
96 |
97 | Chapter 7, Customizing a Kernel discusses how to
98 | customize the kernel for the hardware that is present on the system. It
99 | goes over a variety of different ways to determine what options should be
100 | selected and provides some simple scripts to help with the task.
101 |
102 | Chapter 8, Kernel Configuration Recipes explains how to
103 | configure the kernel for a variety of common situations.
104 |
105 | Chapter 9, Kernel boot command-line parameter reference
106 | details all of the different command-line options that can be passed to the
107 | kernel, and what the different options do.
108 |
109 | Chapter 10, Kernel build command line reference
110 | describes the different command line options that are available when
111 | building the kernel and how to use them.
112 |
113 |
114 |
115 | Chapter 11, Kernel Configuration Option Reference
116 | focuses on a few of the more popular and important Linux kernel
117 | configuration options.
118 |
119 |
120 | Appendix A, Helpful Utilities introduces a number of
121 | very good and handy tools that everyone who wishes to track the latest
122 | Linux kernel version should use.
123 |
124 |
125 | Online Version and License
126 | ==========================
127 |
128 | This book is freely available under the Creative Commons
129 | "Attribution-ShareAlike" license, Version 2.5. This license can be seen in
130 | its entirety in . The full book is also
131 | available online at
132 | http://www.kroah.com/lkn.
133 |
134 |
135 | Conventions Used in This Book
136 | =============================
137 |
138 | This book uses the following typographical conventions:
139 |
140 |
141 |
142 | Italic
143 |
144 |
145 |
153 | Indicates commands and command options, files, directories, usernames, and
154 | hostnames. Also indicates nomenclature that we've not previously used,
155 | emphasized words, and new terms.
156 |
157 |
158 |
159 |
160 |
161 | Constant Width
162 |
163 |
164 | Indicates strings used for kernel configuration, as well as a few
165 | special terms such as device names and distribution packages. Also
166 | used to show the command output, and the contents of text
167 | and program files.
168 |
169 |
170 |
171 |
172 |
173 | Constant Width Bold
174 |
175 |
176 | Used in examples to indicate commands or other text that should be typed
177 | literally by the user.
178 |
179 |
180 |
181 |
182 |
183 | Constant Width Italic
184 |
185 |
186 | Indicates text that you should replace with your own values; for example,
187 | your own name or password. When this appears as part of text that you
188 | should type in, it is shown as
189 | Constant Width Italic Bold.
190 |
191 |
192 |
193 |
194 |
195 | #, $
196 |
197 |
198 | Used in some examples as the root shell prompt
199 | (#) and as the user prompt
200 | ($) under the Bourne or
201 | bash shell.
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 | Indicates a warning or caution.
212 |
213 |
214 |
215 |
216 |
217 |
222 |
223 |
224 |
225 |
226 |
227 |
228 | Contact Information
229 |
230 |
231 | Standard O'Reilly contact information goes here...
232 |
233 |
234 |
235 |
236 |
237 | Acknowledgments
238 | ===============
239 |
240 | Thanks first go to my wonderful wife Shannon and my beautiful children
241 | Madeline and Griffin for their understanding and patience while I took the
242 | time to work on this book. Without their support and prodding, this book
243 | would have never been completed. Special thanks to Shannon for getting me
244 | into Linux kernel development in the first place. Without her effort, I
245 | would be still doing some odd embedded programming job, and would have
246 | never discovered this great community in which to work in.
247 |
248 | My editor, Andy Oram, is the driving force behing this book, shaping it
249 | into something that is both readable and informative. His editing skills
250 | and patience as deadlines flew by were instrumental in the creation and
251 | completion of this book.
252 |
253 | Also a big thanks go to the original editor of this book, David Brickner,
254 | for giving me the chance to work on this project and believing that I could
255 | complete it, despite the first version weighing in at over 1000 pages.
256 |
257 | The technical reviewers for this book were amazing, catching all of the
258 | numerous mistakes and pointing out ommisions that needed to be filled. The
259 | reviewers were (in alphabetic order by first name),
260 | Christian Benvenuti,
261 | Christian Morgner,
262 | Golden G. Richard III,
263 | Jean Delvare,
264 | Jerry Cooperstein,
265 | Michael Boerner,
266 | Rik van Riel, and
267 | Robert Day.
268 |
271 | Any remaining problems are due to me, and not their excellent skills.
272 |
273 | A special thanks to Randy Dunlap for going over the kernel boot parameters
274 | with a fine tooth comb and pointing out issues in that chapter. Also to
275 | Kay Sievers, who helped immensely with all of the chapter on customizing
276 | the kernel, and who provided the script at the end of that same chapter.
277 | Without his sysfs help and knowledge, that chapter would
278 | not have been feasible.
279 |
280 | And a final special thanks to my 6th grade English teacher, Ms. Gruber, for
281 | teaching me that writing was something that was possible to do, and showing
282 | me the enjoyment in doing it. Without that start, none of this would have
283 | been attainable.
284 |
285 |
286 |
--------------------------------------------------------------------------------
/rst/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # Linux Kernel Development Process documentation build configuration file, created by
4 | # sphinx-quickstart on Fri Mar 25 15:56:03 2011.
5 | #
6 | # This file is execfile()d with the current directory set to its containing dir.
7 | #
8 | # Note that not all possible configuration values are present in this
9 | # autogenerated file.
10 | #
11 | # All configuration values have a default; values that are commented out
12 | # serve to show the default.
13 |
14 | import sys, os
15 |
16 | # If extensions (or modules to document with autodoc) are in another directory,
17 | # add these directories to sys.path here. If the directory is relative to the
18 | # documentation root, use os.path.abspath to make it absolute, like shown here.
19 | #sys.path.insert(0, os.path.abspath('.'))
20 |
21 | # -- General configuration -----------------------------------------------------
22 |
23 | # If your documentation needs a minimal Sphinx version, state it here.
24 | #needs_sphinx = '1.0'
25 |
26 | # Add any Sphinx extension module names here, as strings. They can be extensions
27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
28 | extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']
29 |
30 | # Add any paths that contain templates here, relative to this directory.
31 | templates_path = ['_templates']
32 |
33 | # The suffix of source filenames.
34 | source_suffix = '.rst'
35 |
36 | # The encoding of source files.
37 | #source_encoding = 'utf-8-sig'
38 |
39 | # The master toctree document.
40 | master_doc = 'index'
41 |
42 | # General information about the project.
43 | project = u'Linux Kernel in a Nutshell'
44 | copyright = u'2011, Greg Kroah-Hartman'
45 |
46 | # The version info for the project you're documenting, acts as replacement for
47 | # |version| and |release|, also used in various other places throughout the
48 | # built documents.
49 | #
50 | # The short X.Y version.
51 | version = '0'
52 | # The full version, including alpha/beta/rc tags.
53 | release = '1'
54 |
55 | # The language for content autogenerated by Sphinx. Refer to documentation
56 | # for a list of supported languages.
57 | #language = None
58 |
59 | # There are two options for replacing |today|: either, you set today to some
60 | # non-false value, then it is used:
61 | #today = ''
62 | # Else, today_fmt is used as the format for a strftime call.
63 | #today_fmt = '%B %d, %Y'
64 |
65 | # List of patterns, relative to source directory, that match files and
66 | # directories to ignore when looking for source files.
67 | exclude_patterns = ['_build']
68 |
69 | # The reST default role (used for this markup: `text`) to use for all documents.
70 | #default_role = None
71 |
72 | # If true, '()' will be appended to :func: etc. cross-reference text.
73 | #add_function_parentheses = True
74 |
75 | # If true, the current module name will be prepended to all description
76 | # unit titles (such as .. function::).
77 | #add_module_names = True
78 |
79 | # If true, sectionauthor and moduleauthor directives will be shown in the
80 | # output. They are ignored by default.
81 | #show_authors = False
82 |
83 | # The name of the Pygments (syntax highlighting) style to use.
84 | pygments_style = 'sphinx'
85 |
86 | # A list of ignored prefixes for module index sorting.
87 | #modindex_common_prefix = []
88 |
89 |
90 | # -- Options for HTML output ---------------------------------------------------
91 |
92 | # The theme to use for HTML and HTML Help pages. See the documentation for
93 | # a list of builtin themes.
94 | html_theme = 'epub'
95 |
96 | # Theme options are theme-specific and customize the look and feel of a theme
97 | # further. For a list of options available for each theme, see the
98 | # documentation.
99 | #html_theme_options = {}
100 |
101 | # Add any paths that contain custom themes here, relative to this directory.
102 | #html_theme_path = []
103 |
104 | # The name for this set of Sphinx documents. If None, it defaults to
105 | # " v documentation".
106 | html_title = "Linux Kernel in a Nutshell"
107 |
108 | # A shorter title for the navigation bar. Default is the same as html_title.
109 | #html_short_title = None
110 |
111 | # The name of an image file (relative to this directory) to place at the top
112 | # of the sidebar.
113 | #html_logo = None
114 |
115 | # The name of an image file (within the static path) to use as favicon of the
116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
117 | # pixels large.
118 | #html_favicon = None
119 |
120 | # Add any paths that contain custom static files (such as style sheets) here,
121 | # relative to this directory. They are copied after the builtin static files,
122 | # so a file named "default.css" will overwrite the builtin "default.css".
123 | html_static_path = ['_static']
124 |
125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
126 | # using the given strftime format.
127 | #html_last_updated_fmt = '%b %d, %Y'
128 |
129 | # If true, SmartyPants will be used to convert quotes and dashes to
130 | # typographically correct entities.
131 | #html_use_smartypants = True
132 |
133 | # Custom sidebar templates, maps document names to template names.
134 | #html_sidebars = {}
135 |
136 | # Additional templates that should be rendered to pages, maps page names to
137 | # template names.
138 | #html_additional_pages = {}
139 |
140 | # If false, no module index is generated.
141 | #html_domain_indices = True
142 |
143 | # If false, no index is generated.
144 | html_use_index = False
145 |
146 | # If true, the index is split into individual pages for each letter.
147 | #html_split_index = False
148 |
149 | # If true, links to the reST sources are added to the pages.
150 | #html_show_sourcelink = True
151 |
152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
153 | html_show_sphinx = False
154 |
155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
156 | html_show_copyright = False
157 |
158 | # If true, an OpenSearch description file will be output, and all pages will
159 | # contain a tag referring to it. The value of this option must be the
160 | # base URL from which the finished HTML is served.
161 | #html_use_opensearch = ''
162 |
163 | # This is the file name suffix for HTML files (e.g. ".xhtml").
164 | #html_file_suffix = None
165 |
166 | # Output file base name for HTML help builder.
167 | htmlhelp_basename = 'LinuxKernelNutshelldoc'
168 |
169 |
170 | # -- Options for LaTeX output --------------------------------------------------
171 |
172 | # The paper size ('letter' or 'a4').
173 | #latex_paper_size = 'letter'
174 |
175 | # The font size ('10pt', '11pt' or '12pt').
176 | #latex_font_size = '10pt'
177 |
178 | # Grouping the document tree into LaTeX files. List of tuples
179 | # (source start file, target name, title, author, documentclass [howto/manual]).
180 | latex_documents = [
181 | ('index', 'LinuxKernelNutshell.tex', u'Linux Kernel in a Nutshell',
182 | u'Greg Kroah-Hartman', 'manual'),
183 | ]
184 |
185 | # The name of an image file (relative to this directory) to place at the top of
186 | # the title page.
187 | #latex_logo = None
188 |
189 | # For "manual" documents, if this is true, then toplevel headings are parts,
190 | # not chapters.
191 | #latex_use_parts = False
192 |
193 | # If true, show page references after internal links.
194 | #latex_show_pagerefs = False
195 |
196 | # If true, show URL addresses after external links.
197 | #latex_show_urls = False
198 |
199 | # Additional stuff for the LaTeX preamble.
200 | #latex_preamble = ''
201 |
202 | # Documents to append as an appendix to all manuals.
203 | #latex_appendices = []
204 |
205 | # If false, no module index is generated.
206 | #latex_domain_indices = True
207 |
208 | # jake
209 | latex_elements = {
210 | 'classoptions' : ',oneside',
211 | 'babel': '\\usepackage[english]{babel}',
212 | }
213 |
214 | # -- Options for manual page output --------------------------------------------
215 |
216 | # One entry per manual page. List of tuples
217 | # (source start file, name, description, authors, manual section).
218 | man_pages = [
219 | ('index', 'linuxkernelnutshell', u'Linux Kernel in a Nutshell',
220 | [u'Greg Kroah-Hartman'], 1)
221 | ]
222 |
223 |
224 | # -- Options for Epub output ---------------------------------------------------
225 |
226 | # Bibliographic Dublin Core info.
227 | epub_title = u'Linux Kernel in a Nutshell'
228 | epub_author = u'Greg Kroah-Hartman'
229 | epub_publisher = u'LWN Press'
230 | epub_copyright = u'2011, Greg Kroah-Hartman'
231 |
232 | epub_cover = ( 'cover.html' )
233 | # The language of the text. It defaults to the language option
234 | # or en if the language is not set.
235 | #epub_language = ''
236 |
237 | # The scheme of the identifier. Typical schemes are ISBN or URL.
238 | #epub_scheme = ''
239 |
240 | # The unique identifier of the text. This can be a ISBN number
241 | # or the project homepage.
242 | #epub_identifier = ''
243 |
244 | # A unique identification for the text.
245 | #epub_uid = ''
246 |
247 | # HTML files that should be inserted before the pages created by sphinx.
248 | # The format is a list of tuples containing the path and title.
249 | #epub_pre_files = []
250 |
251 | # HTML files shat should be inserted after the pages created by sphinx.
252 | # The format is a list of tuples containing the path and title.
253 | #epub_post_files = []
254 |
255 | # A list of files that should not be packed into the epub file.
256 | #epub_exclude_files = []
257 |
258 | # The depth of the table of contents in toc.ncx.
259 | #epub_tocdepth = 3
260 |
261 | # Allow duplicate toc entries.
262 | #epub_tocdup = True
263 |
264 | # -- Options for (rst2) PDF output --------------------------------------------------
265 |
266 | # Grouping the document tree into PDF files. List of tuples
267 | # (source start file, target name, title, author, options).
268 | #
269 | # If there is more than one author, separate them with \\.
270 | # For example: r'Guido van Rossum\\Fred L. Drake, Jr., editor'
271 | #
272 | # The options element is a dictionary that lets you override
273 | # this config per-document.
274 | # For example,
275 | # ('index', u'MyProject', u'My Project', u'Author Name',
276 | # dict(pdf_compressed = True))
277 | # would mean that specific document would be compressed
278 | # regardless of the global pdf_compressed setting.
279 |
280 | pdf_documents = [
281 | ('index', u'lkn', u'Linux Kernel in a Nutshell',
282 | u'Greg Kroah-Hartman'),
283 | ]
284 |
285 | # A comma-separated list of custom stylesheets. Example:
286 | pdf_stylesheets = ['sphinx','kerning','lkn','serif']
287 |
288 | # Create a compressed PDF
289 | # Use True/False or 1/0
290 | # Example: compressed=True
291 | #pdf_compressed = False
292 |
293 | # A colon-separated list of folders to search for fonts. Example:
294 | # pdf_font_path = ['/usr/share/fonts', '/usr/share/texmf-dist/fonts/']
295 |
296 | # Language to be used for hyphenation support
297 | #pdf_language = "en_US"
298 |
299 | # Mode for literal blocks wider than the frame. Can be
300 | # overflow, shrink or truncate
301 | #pdf_fit_mode = "shrink"
302 |
303 | # Section level that forces a break page.
304 | # For example: 1 means top-level sections start in a new page
305 | # 0 means disabled
306 | pdf_break_level = 2
307 |
308 | # When a section starts in a new page, force it to be 'even', 'odd',
309 | # or just use 'any'
310 | #pdf_breakside = 'any'
311 |
312 | # Insert footnotes where they are defined instead of
313 | # at the end.
314 | #pdf_inline_footnotes = True
315 |
316 | # verbosity level. 0 1 or 2
317 | #pdf_verbosity = 1
318 |
319 | # If false, no index is generated.
320 | #pdf_use_index = True
321 |
322 | # If false, no modindex is generated.
323 | #pdf_use_modindex = True
324 |
325 | # If false, no coverpage is generated.
326 | pdf_use_coverpage = True
327 |
328 | # Name of the cover page template to use
329 | #pdf_cover_template = 'sphinxcover.tmpl'
330 |
331 | # Documents to append as an appendix to all manuals.
332 | #pdf_appendices = []
333 |
334 | # Enable experimental feature to split table cells. Use it
335 | # if you get "DelayedTable too big" errors
336 | #pdf_splittables = False
337 |
338 | # Set the default DPI for images
339 | #pdf_default_dpi = 72
340 |
341 | # Enable rst2pdf extension modules (default is only vectorpdf)
342 | # you need vectorpdf if you want to use sphinx's graphviz support
343 | #pdf_extensions = ['vectorpdf']
344 |
345 | # Page template name for "regular" pages
346 | #pdf_page_template = 'cutePage'
347 |
348 | # Show Table Of Contents at the beginning?
349 | #pdf_use_toc = True
350 |
351 | # How many levels deep should the table of contents be?
352 | pdf_toc_depth = 3
353 |
354 | # Add section number to section references
355 | pdf_use_numbered_links = True
356 |
357 | # Background images fitting mode
358 | pdf_fit_background_mode = 'scale'
359 |
--------------------------------------------------------------------------------
/rst/index.rst:
--------------------------------------------------------------------------------
1 | .. Linux Kernel Nutshell master file.
2 | You can adapt this file completely to your liking, but it should at least
3 | contain the root `toctree` directive.
4 |
5 | Linux Kernel Nutshell
6 | =====================
7 |
8 | .. toctree::
9 | :maxdepth: 2
10 | :numbered:
11 |
12 | ch00
13 |
--------------------------------------------------------------------------------
/rst/lkn.style:
--------------------------------------------------------------------------------
1 | #
2 | # Local rst2pdf stylesheet to try to get things looking the way I'd like.
3 | #
4 | styles:
5 | base:
6 | fontSize: 10
7 | bodytext:
8 | alignment: TA_LEFT
9 | code:
10 | backColor: null
11 | borderColor: null
12 | borderWidth: 0.0
13 | borderPadding: 0
14 | spaceBefore: 12
15 | leftIndent: 6
16 | fontSize: 80%
17 | heading1:
18 | backColor: null
19 | borderColor: null
20 | heading2:
21 | backColor: null
22 | borderColor: null
23 | heading3:
24 | backColor: null
25 | borderColor: null
26 | fontName: stdBold
27 | heading4:
28 | backColor: null
29 | borderColor: null
30 | fontName: stdBold
31 | table:
32 | spaceBefore: 2
33 | spaceAfter: 2
34 | commands: []
35 | [ROWBACKGROUNDS, [0, 0], [-1, -1], [white,#EEEEEE]]
36 | #
37 | # Aim toward an amazon book size; this needs tweaking still.
38 | #
39 | pageSetup:
40 | size: null
41 | width: 6in
42 | height: 9in
43 | margin-top: 2cm
44 | margin-bottom: 2cm
45 | margin-left: 2cm
46 | margin-right: 15mm
47 | spacing-header: 5mm
48 | spacing-footer: 5mm
49 | margin-gutter: 1cm
50 | #
51 | # TODO: check out wordaxe for hyphenation
52 | #
53 |
--------------------------------------------------------------------------------
/schedule:
--------------------------------------------------------------------------------
1 | old one:
2 | Aug 31 1/2 kernel option material
3 | Sep 19 2/2 kernel option material
4 | Oct 10 1/2 non-kernel option chapters
5 | Nov 7 2/2 non-kernel option chapters
6 | Nov 21 final copy ready for technical review
7 |
8 | New one:
9 |
10 |
11 | May 1 - start
12 | 2 recipes / 5 config options a day @ 26 recipes and 100 options == 4 weeks.
13 | June 1 - all done with config and recipies
14 | different chapters/sections, 1 wk each:
15 | - command line options
16 | - build options
17 | - history
18 | - building kernel
19 | - installing
20 | - upgrading
21 | - configuring
22 | - initramfs/initrd (2 wks, might be tough)
23 |
24 | + OLS time off (1 1/2 weeks)
25 |
26 | August 31 - done
27 |
--------------------------------------------------------------------------------
/src/count_symbols.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | grep -v "#" gregkh_symbols.txt | grep -v "^$" | wc
4 |
5 |
--------------------------------------------------------------------------------
/src/find_all_modules.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | for i in `find /sys/ -name modalias -exec cat {} \;`; do
3 | /sbin/modprobe --config /dev/null --show-depends $i ;
4 | done | rev | cut -f 1 -d '/' | rev | sort -u
5 |
6 |
--------------------------------------------------------------------------------
/src/get-driver.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Find all modules and drivers for a given class device.
4 | #
5 |
6 | if [ $# != "1" ] ; then
7 | echo
8 | echo "Script to display the drivers and modules for a specified sysfs class device"
9 | echo "usage: $0 "
10 | echo
11 | echo "example usage:"
12 | echo " $0 sda"
13 | echo "Will show all drivers and modules for the sda block device."
14 | echo
15 | exit 1
16 | fi
17 |
18 | DEV=$1
19 |
20 | if test -e "$1"; then
21 | DEVPATH=$1
22 | else
23 | # find sysfs device directory for device
24 | DEVPATH=$(find /sys/class -name "$1" | head -1)
25 | test -z "$DEVPATH" && DEVPATH=$(find /sys/block -name "$1" | head -1)
26 | test -z "$DEVPATH" && DEVPATH=$(find /sys/bus -name "$1" | head -1)
27 | if ! test -e "$DEVPATH"; then
28 | echo "no device found"
29 | exit 1
30 | fi
31 | fi
32 |
33 | echo "looking at sysfs device: $DEVPATH"
34 |
35 | if test -L "$DEVPATH"; then
36 | # resolve class device link to device directory
37 | DEVPATH=$(readlink -f $DEVPATH)
38 | echo "resolve link to: $DEVPATH"
39 | fi
40 |
41 | if test -d "$DEVPATH"; then
42 | # resolve old-style "device" link to the parent device
43 | PARENT="$DEVPATH";
44 | while test "$PARENT" != "/"; do
45 | if test -L "$PARENT/device"; then
46 | DEVPATH=$(readlink -f $PARENT/device)
47 | echo "follow 'device' link to parent: $DEVPATH"
48 | break
49 | fi
50 | PARENT=$(dirname $PARENT)
51 | done
52 | fi
53 |
54 | while test "$DEVPATH" != "/"; do
55 | DRIVERPATH=
56 | DRIVER=
57 | MODULEPATH=
58 | MODULE=
59 | if test -e $DEVPATH/driver; then
60 | DRIVERPATH=$(readlink -f $DEVPATH/driver)
61 | DRIVER=$(basename $DRIVERPATH)
62 | echo -n "found driver: $DRIVER"
63 | if test -e $DRIVERPATH/module; then
64 | MODULEPATH=$(readlink -f $DRIVERPATH/module)
65 | MODULE=$(basename $MODULEPATH)
66 | echo -n " from module: $MODULE"
67 | fi
68 | echo
69 | fi
70 |
71 | DEVPATH=$(dirname $DEVPATH)
72 | done
73 |
--------------------------------------------------------------------------------
/src/series:
--------------------------------------------------------------------------------
1 | xml-config.patch
2 |
--------------------------------------------------------------------------------
/src/xml-config.patch:
--------------------------------------------------------------------------------
1 | arch/i386/Kconfig | 4
2 | scripts/kconfig/Makefile | 2
3 | scripts/kconfig/conf.c | 1
4 | scripts/kconfig/expr.c | 6
5 | scripts/kconfig/lkc.h | 1
6 | scripts/kconfig/zconf.y | 338 +++++++++++++++++++++++++++++++++++++++++++++++
7 | 6 files changed, 348 insertions(+), 4 deletions(-)
8 |
9 | --- linux-2.6.17.orig/arch/i386/Kconfig
10 | +++ linux-2.6.17/arch/i386/Kconfig
11 | @@ -3,7 +3,7 @@
12 | # see Documentation/kbuild/kconfig-language.txt.
13 | #
14 |
15 | -mainmenu "Linux Kernel Configuration"
16 | +menu "Linux Kernel Configuration"
17 |
18 | config X86_32
19 | bool
20 | @@ -1130,3 +1130,5 @@ config X86_TRAMPOLINE
21 | config KTIME_SCALAR
22 | bool
23 | default y
24 | +
25 | +endmenu
26 | --- linux-2.6.17.orig/scripts/kconfig/Makefile
27 | +++ linux-2.6.17/scripts/kconfig/Makefile
28 | @@ -231,7 +231,7 @@ $(obj)/lkc_defs.h: $(src)/lkc_proto.h
29 | # The following requires flex/bison/gperf
30 | # By default we use the _shipped versions, uncomment the following line if
31 | # you are modifying the flex/bison src.
32 | -# LKC_GENPARSER := 1
33 | +LKC_GENPARSER := 1
34 |
35 | ifdef LKC_GENPARSER
36 |
37 | --- linux-2.6.17.orig/scripts/kconfig/conf.c
38 | +++ linux-2.6.17/scripts/kconfig/conf.c
39 | @@ -542,6 +542,7 @@ int main(int ac, char **av)
40 | }
41 | conf_parse(name);
42 | //zconfdump(stdout);
43 | + gregkh_confdump(stdout);
44 | switch (input_mode) {
45 | case set_default:
46 | if (!defconfig_file)
47 | --- linux-2.6.17.orig/scripts/kconfig/expr.c
48 | +++ linux-2.6.17/scripts/kconfig/expr.c
49 | @@ -1026,7 +1026,8 @@ void expr_print(struct expr *e, void (*f
50 | if (e->left.sym->name)
51 | fn(data, e->left.sym->name);
52 | else
53 | - fn(data, "");
54 | +// fn(data, "");
55 | + fn(data, "choice");
56 | break;
57 | case E_NOT:
58 | fn(data, "!");
59 | @@ -1049,7 +1050,8 @@ void expr_print(struct expr *e, void (*f
60 | break;
61 | case E_AND:
62 | expr_print(e->left.expr, fn, data, E_AND);
63 | - fn(data, " && ");
64 | +// fn(data, " && ");
65 | + fn(data, " and ");
66 | expr_print(e->right.expr, fn, data, E_AND);
67 | break;
68 | case E_CHOICE:
69 | --- linux-2.6.17.orig/scripts/kconfig/lkc.h
70 | +++ linux-2.6.17/scripts/kconfig/lkc.h
71 | @@ -50,6 +50,7 @@ struct kconf_id {
72 |
73 | int zconfparse(void);
74 | void zconfdump(FILE *out);
75 | +void gregkh_confdump(FILE *out);
76 |
77 | extern int zconfdebug;
78 | void zconf_starthelp(void);
79 | --- linux-2.6.17.orig/scripts/kconfig/zconf.y
80 | +++ linux-2.6.17/scripts/kconfig/zconf.y
81 | @@ -673,6 +673,344 @@ void zconfdump(FILE *out)
82 | }
83 | }
84 |
85 | +static void gkh_print_string(FILE *out, int len, const char *str)
86 | +{
87 | + while (len) {
88 | + if (*str == '<')
89 | + fputs("<", out);
90 | + else if (*str == '>')
91 | + fputs(">", out);
92 | + else if (*str == '&')
93 | + fputs("&", out);
94 | + else putc(*str, out);
95 | + --len;
96 | + ++str;
97 | + }
98 | +}
99 | +
100 | +static void gkh_print_quoted_string(FILE *out, const char *str)
101 | +{
102 | + const char *p;
103 | + int len;
104 | +
105 | +// putc('"', out);
106 | + while ((p = strchr(str, '"'))) {
107 | + len = p - str;
108 | + if (len)
109 | + gkh_print_string(out, len, str);
110 | +// fprintf(out, "%.*s", len, str);
111 | + fputs("\\\"", out);
112 | + str = p + 1;
113 | + }
114 | + //fputs(str, out);
115 | + gkh_print_string(out, strlen(str), str);
116 | +// putc('"', out);
117 | +}
118 | +
119 | +static void gkh_output_help(FILE *out, char *string)
120 | +{
121 | + char *current = string;
122 | +
123 | + fprintf(out, "\t");
124 | + while (*current) {
125 | + if ((current[0] == '\n') && (current[1] == '\n')) {
126 | + fprintf(out, "\n\t\n\n\t\n\t");
127 | + current++;
128 | + } else if (*current == '\n')
129 | + fprintf(out, "\n\t");
130 | + else if ((*current == '<') || (*current == '>'))
131 | + ;
132 | + else if (*current == '&')
133 | + fprintf(out, "and");
134 | + else
135 | + fprintf(out, "%c", *current);
136 | + current++;
137 | + }
138 | + fprintf(out, "\n");
139 | +}
140 | +
141 | +static int gregkh_good_symbol(const char *name)
142 | +{
143 | + static char buffer[256];
144 | + char *buf;
145 | + FILE *symbol_file;
146 | + int retval = -1;
147 | + int len;
148 | + int i;
149 | +
150 | + if (!name)
151 | + return -1;
152 | +
153 | + symbol_file = fopen("../gregkh_symbols.txt", "r");
154 | + if (symbol_file == NULL) {
155 | + printf("can't find gregkh_symbols.txt\n");
156 | + exit(-1);
157 | + }
158 | +
159 | + while (1) {
160 | + buf = fgets(buffer, 256, symbol_file);
161 | + if (buf == NULL)
162 | + break;
163 | + len = strlen(buffer);
164 | + if (len < 7)
165 | + continue;
166 | + if (buf[0] == '#')
167 | + continue;
168 | + buffer[len - 1] = 0x00;
169 | + for (i = 0; i < len; ++i)
170 | + if (buffer[i] == '=')
171 | + buffer[i] = 0x00;
172 | + buf = &buffer[7];
173 | +// printf("name='%s' buf='%s'\n", name, buf);
174 | + if (strcmp(buf, name) == 0) {
175 | + retval = 0;
176 | + break;
177 | + }
178 | + }
179 | + fclose(symbol_file);
180 | +
181 | + return retval;
182 | +}
183 | +
184 | +
185 | +void gkh_print_symbol(FILE *out, struct menu *menu)
186 | +{
187 | + struct symbol *sym = menu->sym;
188 | + struct property *prop;
189 | + int entrybody_start = 0;
190 | +
191 | + if (gregkh_good_symbol(sym->name))
192 | + return;
193 | +
194 | + if (sym->name)
195 | + fprintf(out, "\n", sym->name);
196 | + else
197 | + fprintf(out, "\n");
198 | + fprintf(out, "\n");
199 | + if (sym_is_choice(sym))
200 | + ; //fprintf(out, "choice\n");
201 | + else
202 | + fprintf(out, "\t%s\n", sym->name);
203 | +
204 | + for (prop = sym->prop; prop; prop = prop->next) {
205 | + if (prop->menu != menu)
206 | + continue;
207 | + switch (prop->type) {
208 | + case P_PROMPT:
209 | + case P_MENU:
210 | + fprintf(out, "\t");
211 | + gkh_print_quoted_string(out, prop->text);
212 | + fprintf(out, "\n");
213 | + break;
214 | + default:
215 | + break;
216 | + }
217 | + }
218 | + fprintf(out, "\n");
219 | +
220 | + fprintf(out, "\n");
221 | + for (prop = sym->prop; prop; prop = prop->next) {
222 | + if (prop->menu != menu)
223 | + continue;
224 | + switch (prop->type) {
225 | + case P_PROMPT:
226 | + case P_MENU:
227 | + entrybody_start = 1;
228 | + if (!expr_is_yes(prop->visible.expr)) {
229 | + fprintf(out, "\tDepends on ");
230 | + expr_fprint(prop->visible.expr, out);
231 | + fprintf(out, "\n");
232 | + }
233 | + break;
234 | + default:
235 | + break;
236 | + }
237 | + }
238 | +
239 | + for_all_properties(sym, prop, P_SELECT) {
240 | + fprintf(out, "\tSelects ");
241 | + expr_fprint(prop->expr, out);
242 | + fprintf(out, "\n");
243 | + }
244 | +
245 | + for_all_properties(sym, prop, P_RANGE) {
246 | + fprintf(out, "\tRange ");
247 | + expr_fprint(prop->expr, out);
248 | + fprintf(out, "\n");
249 | + }
250 | +
251 | + for_all_properties(sym, prop, P_DEFAULT) {
252 | + if ((prop->expr->type == E_SYMBOL) &&
253 | + ((strlen(prop->expr->left.sym->name) == 0) ||
254 | + (!prop->expr->left.sym->name)))
255 | + ;
256 | + else {
257 | + fprintf(out, "\tDefault Value ");
258 | + expr_fprint(prop->expr, out);
259 | + if (!expr_is_yes(prop->visible.expr)) {
260 | + fputs(" if ", out);
261 | + expr_fprint(prop->visible.expr, out);
262 | + }
263 | + fprintf(out, "\n");
264 | + }
265 | + }
266 | +
267 | +
268 | +#if 0
269 | + for (prop = sym->prop; prop; prop = prop->next) {
270 | + if (prop->menu != menu)
271 | + continue;
272 | + switch (prop->type) {
273 | + case P_PROMPT:
274 | + case P_MENU:
275 | + fprintf(out, "\t");
276 | + gkh_print_quoted_string(out, prop->text);
277 | + fprintf(out, "\n");
278 | + fprintf(out, "\n");
279 | + entrybody_start = 1;
280 | + if (!expr_is_yes(prop->visible.expr)) {
281 | + fprintf(out, "\n");
282 | + fprintf(out, "\tDepends on ");
283 | + expr_fprint(prop->visible.expr, out);
284 | + fprintf(out, "\n");
285 | + fprintf(out, "\tModule Name FIXME\n");
286 | + fprintf(out, "\n");
287 | + }
288 | + break;
289 | + case P_DEFAULT:
290 | +// fprintf(out, "\tDefault Value ");
291 | +// expr_fprint(prop->expr, out);
292 | +// if (!expr_is_yes(prop->visible.expr)) {
293 | +// fputs(" if ", out);
294 | +// expr_fprint(prop->visible.expr, out);
295 | +// }
296 | +// fprintf(out, "\n\n");
297 | + break;
298 | + case P_CHOICE:
299 | + //fputs(" #choice value\n", out);
300 | + break;
301 | + case P_SELECT:
302 | +// fprintf(out, "\tSelects ");
303 | +// expr_fprint(prop->expr, out);
304 | +// fprintf(out, "\n");
305 | + break;
306 | + case P_RANGE:
307 | +// fprintf(out, "\tRange ");
308 | +// expr_fprint(prop->expr, out);
309 | +// fprintf(out, "\n");
310 | + break;
311 | + default:
312 | + fprintf(out, " unknown prop %d!\n", prop->type);
313 | + break;
314 | + }
315 | + }
316 | +#endif
317 | + fprintf(out, "\tType ");
318 | + switch (sym->type) {
319 | + case S_BOOLEAN:
320 | + fputs("boolean", out);
321 | + break;
322 | + case S_TRISTATE:
323 | + fputs("tristate", out);
324 | + break;
325 | + case S_STRING:
326 | + fputs("string", out);
327 | + break;
328 | + case S_INT:
329 | + fputs("integer", out);
330 | + break;
331 | + case S_HEX:
332 | + fputs("hex", out);
333 | + break;
334 | + default:
335 | + fputs("???", out);
336 | + break;
337 | + }
338 | + fprintf(out, "\n");
339 | +
340 | +// fprintf(out, "\tModule Name FIXME\n");
341 | + fprintf(out, "\n");
342 | +
343 | +
344 | + fprintf(out, "\n");
345 | + fprintf(out, "\tDescription\n");
346 | +
347 | + if (sym->help) {
348 | + int len = strlen(sym->help);
349 | + while (sym->help[--len] == '\n')
350 | + sym->help[len] = 0;
351 | + fprintf(out, "\t\n");
352 | + // convert help paragraphs to xml paragraphs
353 | + gkh_output_help(out, sym->help);
354 | + fprintf(out, "\t\n\n");
355 | + }
356 | +
357 | + fprintf(out, "\n");
358 | + fprintf(out, "\n\n");
359 | +}
360 | +
361 | +void gregkh_confdump(FILE *out)
362 | +{
363 | + struct property *prop;
364 | + struct symbol *sym;
365 | + struct menu *menu;
366 | + int depth=1;
367 | +
368 | + menu = rootmenu.list;
369 | + while (menu) {
370 | + if ((sym = menu->sym))
371 | + gkh_print_symbol(out, menu);
372 | +#if 0
373 | +uncomment to get back the titles and sections
374 | + else if ((prop = menu->prompt)) {
375 | + switch (prop->type) {
376 | + case P_COMMENT:
377 | +// fputs("\ncomment ", out);
378 | +// gkh_print_quoted_string(out, prop->text);
379 | +// fputs("\n", out);
380 | + /* I don't think we want to print these at all... */
381 | + goto cont;
382 | + break;
383 | + case P_MENU:
384 | +// fputs("\nmenu ", out);
385 | + fprintf(out, "\n\n\t", depth);
386 | + gkh_print_quoted_string(out, prop->text);
387 | + fputs("\n", out);
388 | + fputs("\n", out);
389 | + ++depth;
390 | + break;
391 | + default:
392 | + ;
393 | + }
394 | + if (!expr_is_yes(prop->visible.expr)) {
395 | + fprintf(out, "\n\tdepends on\n\t");
396 | + expr_fprint(prop->visible.expr, out);
397 | + fprintf(out, "\n\t\n\n");
398 | + }
399 | + fputs("\n", out);
400 | + }
401 | +cont:
402 | +#endif
403 | + if (menu->list)
404 | + menu = menu->list;
405 | + else if (menu->next)
406 | + menu = menu->next;
407 | + else while ((menu = menu->parent)) {
408 | +#if 0
409 | + if (menu->prompt && menu->prompt->type == P_MENU) {
410 | +// fputs("\nendmenu\n", out);
411 | + --depth;
412 | + fprintf(out, "\n\n\n", depth);
413 | + }
414 | +#endif
415 | + if (menu->next) {
416 | + menu = menu->next;
417 | + break;
418 | + }
419 | + }
420 | + }
421 | +}
422 | +
423 | #include "lex.zconf.c"
424 | #include "util.c"
425 | #include "confdata.c"
426 |
--------------------------------------------------------------------------------
/status:
--------------------------------------------------------------------------------
1 | chapter status
2 |
3 | 0 needs editing from Andy.
4 | 2 needs editing from Andy.
5 | 3 finished
6 | 4 needs editing from Andy
7 | 5 needs editing from Andy
8 | 6 needs editing from Andy
9 | 7 needs editing from Andy
10 | 8 needs editing from Andy
11 | 9 finished
12 | 10 not done Going to not do due to time constraints
13 | 11 finished
14 | 12 finished
15 | 13 finished
16 | appendix A not done
17 | appendix B needs editing from Andy
18 | appendix C not done
19 | Bibliography finished for now.
20 | License finished
21 |
22 |
--------------------------------------------------------------------------------
/test_book.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | Linux Kernel in a Nutshell
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------