The Linux Kernel HOWTO
v5.7, 04 May 2003
Это детализированное руководство по конфигурации,компиляции,апгрэйду ядра ,
1. Введение
Для компиляции ядра нужны следующие причины:
Вы занимаетесь разработкой ядра
Вы добавили новую железяку
Вас не устраивает вариант ядра , скомпилированный по умолчанию
Безопасность
Компиляция ядра - основа для понимания и чтения его кода .
2. Quick Steps - Kernel Compile
Эта секция написана
Al Dev (alavoor[AT]yahoo.com)
последняя версия
документа -
"http://www.milkywaygalaxy.freeservers.com"
или здесь -
angelfire
,
geocities
.
2.1. Precautionary Preparations
Перед компиляцией ядра нужно сделать бэкап системы , хотя вообще-то это дело вкуса .
Можно использовать для этого коммерческую тулзу
BRS Backup-Recovery-Software
При компиляции старый конфиг нужно сохранить.
Например , вот так :
bash# mv /usr/src/linux/.config /usr/src/linux/.config.save
bash# cp /boot/config-2.4.18-19.8.0 /usr/src/linux/.config
|
Другой способ - скопировать конфиг из предыдущего каталога исходников ядра в новый каталог :
bash# ls -l /usr/src/lin* # You can see that /usr/src/linux is a soft link
bash# cd /usr/src/linux
bash# cp ../linux-old-tree/.config . # Example cp ../linux-2.4.19/.config .
|
или вот так - "make oldconfig"
2.3. For the Impatient
Распаковываем исходники из архива
Сохраняем старый конфиг
make clean; make mrproper
make xconfig
make dep
Даем уникальное имя для нового ядра - подправляем
/usr/src/linux/Makefile или меняем EXTRAVERSION
nohup make bzImage
'make modules' и 'make modules_install'
И можно идти на обед.
Прийдя с обеда , можно посмотреть 'less nohup.out'.
make install [num ] Физически при этом происходит следующее - use cp
/usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.myker
Конфигурируем GRUB или LILO.
Перезапуск
Создаем загрузочный диск - bzdisk или mkbootdisk
Создаем пакет - make rpm [num ]
Подчистим - make clean
2.4. Building New Kernel - Explanation of Steps
Все нижеследующее проверялось на Redhat Linux Kernel 2.4.7-10,
но с небольшими изминениями должно работать на предыдущих и будущих версиях.
Распаковка исходников с сидирома :
bash$ su - root
bash# cd /mnt/cdrom/RedHat/RPMS
bash# rpm -i kernel-headers*.rpm
bash# rpm -i kernel-source*.rpm
bash# rpm -i dev86*.rpm
|
assembler 'as86' извлекается из dev86*.rpm на сиди или с
bin86-mandrake
,
bin86-kondara
). Каталог /usr/src/linux должен быть линком .
bash# cd /usr/src
bash# ls -l # You should see that /usr/src/linux is soft link pointing to source
lrwxrwxrwx 1 root root 19 Jan 26 11:01 linux -> linux-2.4.18-19.8.0
drwxr-xr-x 17 root root 4096 Jan 25 21:08 linux-2.4.18-14
drwxr-xr-x 17 root root 4096 Mar 26 12:50 linux-2.4.18-19.8.0
drwxr-xr-x 7 root root 4096 Jan 14 16:32 redhat
|
Если это не линк , то нужно переименовать каталог /usr/src/linux в каталог
/usr/src/linux-2.4.yy и создать на него линк.
Вообще-то компиляцию новой версии ядра можно делать где угодно.
Сохраняем старый конфиг:
bash# mv /usr/src/linux/.config /usr/src/linux/.config.save
bash# cp /boot/config-2.4.18-19.8.0 /usr/src/linux/.config
|
Или копируем конфиг :
bash# ls -l /usr/src/lin* # You can see that /usr/src/linux is a soft link
bash# cd /usr/src/linux
bash# cp ../linux-old-tree/.config . # Example cp ../linux-2.4.19/.config .
|
или делаем "make oldconfig"
Clean :
bash# cd /usr/src/linux
bash# cp .config .config.save
bash# make clean
bash# make mrproper # Must do this if want to start clean
# slate or if you face lot of problems
|
Конфигурация:
Утилиты
"make xconfig" или"make menuconfig"
запускают интерактивный дружественный интерфейс . Команда
"make config"
запускает более детерминированный command-line консольный интерфейс.
ОЧЕНЬ ВАЖНО !!! :
Выбираем соответствующий тип CPU - Pentium 3, AMD K6, Cyrix, Pentium
4, Intel 386, DEC Alpha, PowerPC - в противном случае будут либо ошибки
при компиляции , либо новое ядро вообще не будет загружаться !!
Выбираем SMP support - один CPU или несколько
Выбираем Filesystems
Выбираем поддержку Loadable kernel modules !
Сохраняем и выходим из "make xconfig". Изменения сохранены в
/usr/src/linux/.config
Dep :
Теперь дадим уникальное имя новому ядру - пропишем это в Makefile:
bash# cd /usr/src/linux
bash# vi Makefile
|
Пусть системная переменная EXTRAVERSION = -19.8.0_Blah_Blah_Blah .
Меяем ее на что-то типа EXTRAVERSION = -19.8.0MyKernel.26Jan2003
make:
Сначала читаем :
bash# gvim -R /usr/src/linux/arch/i386/config.in
bash# man less
bash# less /usr/src/linux/arch/i386/config.in
Type 'h' for help and to navigate press i, j, k, l, h or arrow, page up/down keys.
|
Теперь запускаем make -
bash# cd /usr/src/linux
bash# man nohup
bash# nohup make bzImage &
bash# man tail
bash# tail -f nohup.out (.... to monitor the progress)
This will put the kernel in /usr/src/linux/arch/i386/boot/bzImage
|
Загружаемые модули: они находятся в /lib/modules.
# Bring up a new Xterm shell window and ...
bash# cd /usr/src/linux
# Redirect outputs such that you do not overwrite the nohup.out
# which is still running...
bash# nohup make modules 1> modules.out 2> modules.err &
bash# make modules_install
|
Копирует модули в /lib/modules .
Идем обедать .
Возвращаемся с обеда и смотрим лог .
bash# cd /usr/src/linux
bash# less nohup.out
bash# less modules.err
bash# less modules.out
If no errors then do:
bash# make modules_install
|
bzImage:
Копируем образ в каталог /boot , а также конфиг .
bash# cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.myker.26mar2001
# You MUST copy the config file to reflect the corresponding kernel image,
# for documentation purpose.
bash# cp /usr/src/linux/.config /boot/config-<your_kernelversion_date>
# Example: cp /usr/src/linux/.config /boot/config-2.4.18-19.8.0-26mar2001
|
Конфигурация GRUB или LILO :
Под Redhat Linux есть 2 загрузчика - GRUB и LILO.
GRUB:
GRUB поновее и покруче , чем LILO .
Загрузчик позволяет иметь на одном компе несколько разных осей.
Делаем перезапуск и в лило жмем на клавишу таб , после чего набираем 'myker'
Если все грузится , значит новое ядро удалось , в противном случае будет загружен
старый образ.
Создаем загрузочный флоппи :
bash# cd /usr/src/linux
bash# make bzdisk
See also mkbootdisk -
bash# rpm -i mkbootdisk*.rpm
bash# man mkbootdisk
|
Закатаем новый образ в RPM
make rpm # To build rpm packages
|
Clean:
опционально .
2.5. Troubleshooting
Проблемы? Смотри
Section 17
.
3. Loadable Modules
Загружаемые модули - это код , который напрямую не привязан к ядру .
Их можно произвольным образом компилировать и добавлять к ядру .
Многие драйвера устройств , такие как PCMCIA , являются загружаемыми модулями.
Смотри
"http://www.tldp.org/HOWTO/Module-HOWTO"
.
Информацию по загружаемым модулям можно взять в мане
bash# rpm -i /mnt/cdrom/Redhat/RPMS/modutils*.rpm
bash# man lsmod
bash# man insmod
bash# man rmmod
bash# man depmod
bash# man modprobe
|
Например для загрузки модуля
/lib/modules/2.4.2-2/kernel/drivers/block/loop.o
, нужно выполнить :
bash# man insmod
bash# modprobe loop
bash# insmod loop
bash# lsmod
|
При этом путь к модулю ищется в /etc/modules.conf.
3.1. Installing the module utilities
Можно инсталлировать модульные утилиты так :
bash# rpm -i /mnt/cdrom/Redhat/RPMS/modutils*.rpm
|
insmod
добавляет модуль к ядру , которое уже запущено.
Модули обычно имеют расширение
.o
. Для того , чтобы посмотреть , какие модули использует текущее ядро надо набрать
lsmod
. Вывод будет примерно такой : blah# lsmod Module: #pages: Used by:
drv_hello 1 ` . Для удаления модулей
используйте `
rmmod drv_hello
'. Обратите внимание , что
rmmod
требует
имя модуля,
а не имя файла; имя модуля можно получить с помощью
lsmod
'.
3.2. Modules distributed with the kernel
Начиная с версии 2.0.30, большинство модулей загружаемые .
Порядок компиляции следующий : откомпилировав ядро , презапуститесь через него .
Затем :
cd
to
/usr/src/linux
и выполняем `
make modules
'. Эта команда откомпилирует все модули , не определенные в конфигурации
и разместит линки на них в
/usr/src/linux/modules
. Затем выполняем `
make modules_install
', которая установит их в
/lib/modules/x.y.z
, где
x.y.z
есть номер релиза.
3.3. Howto Install Just A Single Module ?
Предположим , что вы захотели изменить код в одном из модулей и хотите перекомпилировать только его.
Можно откомпилировать единственный модуль и инсталлировать его.
Для этого в Makefile можно использовать SUBDIRS для добавления только тех директорий,
которые вас интересуют.
Например для модуля fs/autofs :
cd /usr/src/linux
cp Makefile Makefile.my
vi Makefile.my
# And comment out the line having 'SUBDIRS' and add the
# directory you are interested, for example like fs/autofs as below :
#SUBDIRS =kernel drivers mm fs net ipc lib abi crypto
SUBDIRS =fs/autofs
# Save the file Makefile.my and give -
make -f Makefile.my modules
# This will create module autofs.o
# Now, copy the module object file to destination /lib/modules
make -f Makefile.my modules_install
# And this will do 'cp autofs.o /lib/modules/2.4.18-19.8.0/kernel/fs/autofs'
|
О Makefile и make можно почитать здесь :
Для Makefile , который лежит в подкаталоге модулей , есть строка
modules: $(patsubst %, _mod_%, $(SUBDIRS))
|
Функция patsubst имеет синтаксис $(patsubst
pattern,replacement,text). Она использует символ процент ([percnt]) как
строку соответствующую шаблону .
В этот makefile входят шелл-функции , которые имеют синтаксис $(shell command).
4. Cloning of Linux Kernels
Для переноса нового образа на другие машины можно использовать редхатовские пакеты.
или дебиановские (DEB) пакеты или просто архивы tar.gz .
Пакет строится командой rpmbuild -ba kernel*.spec
Проверьте , что пакет имеет образ в виде файла /boot/initrd-2.x.x-y.img .
5. Important questions and their answers5.1. What does the kernel do, anyway?
Ядро управляет памятью всех процессов и обеспечивает портабельный интерфейс для
общения программ с железом.
5.2. Why would I want to upgrade my kernel?
Новые версии ядра могут общаться с большим количеством железа,лучше управляют памятью,
они просто быстрее старых.
5.3. What kind of hardware do the newer kernels support?
Смотрите
Hardware-HOWTO
. Можно посмотреть в `
config.in
' или просто набрать `
make config
'.
Будет показан полный список оборудования , поддерживаемого ядром.
5.4. What version of gcc and libc do I need?
Версию gcc можно посмотреть в
README
.
5.5. What's a loadable module?
Смотрите
Section 3
.
5.6. How much disk space do I need?
Это зависит от конфигурации . Исходники 2.2.9 весят 14 метров.
5.7. How long does it take?
На AMD K6-2/300 компиляция 2.2.x занимает около 4 минут .
На 486s, и 386s, это может занимать часы ...
Можно компилировать на быстрых машинах и потом переносить на медленные.
6. Patching the kernel6.1. Applying a patch
Незначительные изменения ядра называются патчами.
Например , если у вас Linux v1.1.45, и у вас есть
patch46.gz
' , это значит что вы можете проапгрэйдить версию до 1.1.46 с помощью этого патча.
Вначале можно сделать бэкап исходников : `
make clean
' и затем `
cd /usr/src; tar zcvf old-tree.tar.gz linux
' будет создан архив.
Итак , предположим , что у нас имеется `
patch46.gz
' в каталоге
/usr/src
.
Делаем cd
/usr/src
и затем `
zcat patch46.gz [verbar] patch -p0
' (or `
patch -p0 [lt ] patch46
' . После чего набираем
-s
вместе с командой
patch
, которая говорит
patch
вывести только ошибки . Затем идем в каталог
/usr/src/linux
и смотрим на файл
.rej
Если все нормально , делаем `
make clean
', `
config
', и `
dep
' .
patch -s
ничего не выводит , кроме ошибок .
6.2. If something goes wrong
Проблемы при патчах возникают после того , как изменяется
config.in
' . Но есть файл
config.in.rej
, с помощью которого можно посмотреть разницу. Изменения
маркируются `
+
' и `
-
' в начале линии.
Изменив в
config.in
y
' на `
n
' и `
n
' на `
y
' , можно добиться желаемого результата.
6.3. Getting rid of the .orig files
В результате патчей создаются файлы
.orig .
Команда find . -name '*.orig' -exec rm -f {} ';' удаляет их .
6.4. Other patches
Патчи от нестандартных дистрибутивов могут привести к проблемам .
9. Linux Kernel Textbooks and Documents
Книги из серии "The Linux Kernel"
Refer also to other relevant HOWTOs at:
10. Kernel Files Information
Краткий экскурс в Linux Kernel System.
10.1. vmlinuz and vmlinux
vmlinuz - исполняемый файл ядра . Находится в /boot/vmlinuz.
Часто это может быть линком на что-то типа /boot/vmlinuz-2.4.18-19.8.0
vmlinux - это несжатое ядро, vmlinuz - сжатое , создаваемое при запуске .
Еще есть bzImage, который хранится в arch/i386/boot.
10.2. Bootloader Files
Файлы с раширением .b - "bootloader" файлы. Необходимы для загрузки ядра в память.
ls -l /boot/*.b
-rw-r--r-- 1 root root 5824 Sep 5 2002 /boot/boot.b
-rw-r--r-- 1 root root 612 Sep 5 2002 /boot/chain.b
-rw-r--r-- 1 root root 640 Sep 5 2002 /boot/os2_d.b
|
10.3. Message File
Файлы 'message' включают сообщения , которые выводятся на экран.
ls -l /boot/message*
-rw-r--r-- 1 root root 23108 Sep 6 2002 /boot/message
-rw-r--r-- 1 root root 21282 Sep 6 2002 /boot/message.ja
|
10.5. bzImage
bzImage - сжатый образ ядра , созданный командой 'make bzImage' .
10.6. module-info
This file 'module-info' is created by anaconda/utils/modlist (specific
to Redhat Linux Anaconda installer). Other Linux distributions may be
having equivalent command. Refer to your Linux distributor's manual
pages.
See this script and search for "module-info"
updmodules
.
Below is a cut from this script:
#!/bin/bash
# updmodules.sh
MODLIST=$PWD/../anaconda/utils/modlist
-- snip cut
blah blah blah
-- snip cut
# create the module-info file
$MODLIST --modinfo-file $MODINFO --ignore-missing --modinfo \
$(ls *.o | sed 's/\.o$//') > ../modinfo
|
The program anaconda/utils/modlist is located in anaconda-runtime*.rpm
on the Redhat CDROM
cd /mnt/cdrom/RedHat/RPMS
rpm -i anaconda-8.0-4.i386.rpm
rpm -i anaconda-runtime-8.0-4.i386.rpm
ls -l /usr/lib/anaconda-runtime/modlist
|
Get the source code for anaconda/utils/modlist.c from
anaconda*.src.rpm at
"http://www.rpmfind.net/linux/rpm2html/search.php?query=anaconda"
Read online at
modlist.c
. .
The file 'module-info' is generated during the compile. It is an
information file that is at least used during filing proper kernel
OOPS reports. It is a list of the module entry points. It may also be
used by depmod in building the tables that are used by insmod and its
kith and kin. This includes dependancy information for other modules
needed to be loaded before any other given module, etc. "Don't remove
it."
Some points about module-info:
Is provided by the kernel rpms (built by anaconda-runtime*.rpm)
Is a link to module-info-[lcub ]kernel-version[rcub ]
Contains information about all available modules (at least those
included in the default kernel config.)
Important to anaconda - in anaconda/utils/modlist command.
Might be used by kudzu to determine default parameters for
modules when it creates entries in /etc/modules.conf. If you
move module-info out of the way, shut down, install a new
network card, and re-boot then kudzu would complain loudly. Look
at the kudzu source code.
10.7. config
Everytime you compile and install the kernel image in /boot, you
should also copy the corresponding config file to /boot area, for
documentation and future reference. Do NOT touch or edit these files!!
ls -l /boot/config-*
-rw-r--r-- 1 root root 42111 Sep 4 2002 /boot/config-2.4.18-14
-rw-r--r-- 1 root root 42328 Jan 26 01:29 /boot/config-2.4.18-19.8.0
-rw-r--r-- 1 root root 51426 Jan 25 22:21 /boot/config-2.4.18-19.8.0BOOT
-rw-r--r-- 1 root root 52328 Jan 28 03:22 /boot/config-2.4.18-19.8.0-26mar2003
|
10.8. grub
If you are using GRUB, then there will be 'grub' directory.
ls /boot/grub
device.map ffs_stage1_5 menu.lst reiserfs_stage1_5 stage2
e2fs_stage1_5 grub.conf minix_stage1_5 splash.xpm.gz vstafs_stage1_5
fat_stage1_5 jfs_stage1_5 stage1 xfs_stage1_5
|
See also
Section 15
file.
10.9. System.map
System.map is a "phone directory" list of function in a particular
build of a kernel. It is typically a symlink to the System.map of the
currently running kernel. If you use the wrong (or no) System.map,
debugging crashes is harder, but has no other effects. Without
System.map, you may face minor annoyance messages.
Do NOT touch the System.map files.
ls -ld /boot/System.map*
lrwxrwxrwx 1 root root 30 Jan 26 19:26 /boot/System.map -> System.map-2.4.18-19.8.0custom
-rw-r--r-- 1 root root 501166 Sep 4 2002 /boot/System.map-2.4.18-14
-rw-r--r-- 1 root root 510786 Jan 26 01:29 /boot/System.map-2.4.18-19.8.0
-rw-r--r-- 1 root root 331213 Jan 25 22:21 /boot/System.map-2.4.18-19.8.0BOOT
-rw-r--r-- 1 root root 503246 Jan 26 19:26 /boot/System.map-2.4.18-19.8.0custom
|
How The Kernel Symbol Table Is Created ?
System.map is produced by 'nm vmlinux' and irrelevant or uninteresting
symbols are grepped out, When you compile the kernel, this file
'System.map' is created at /usr/src/linux/System.map. Something like
below:
nm /boot/vmlinux-2.4.18-19.8.0 > System.map
# Below is the line from /usr/src/linux/Makefile
nm vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' |
sort > System.map
cp /usr/src/linux/System.map /boot/System.map-2.4.18-14 # For v2.4.18
|
From
"http://www.dirac.org/linux/systemmap.html"
10.9.1. System.map
There seems to be a dearth of information about the System.map file.
It's really nothing mysterious, and in the scheme of things, it's
really not that important. But a lack of documentation makes it
shady. It's like an earlobe; we all have one, but nobody really
knows why. This is a little web page I cooked up that explains the
why.
Note, I'm not out to be 100[percnt] correct. For instance, it's
possible for a system to not have /proc filesystem support, but most
systems do. I'm going to assume you "go with the flow" and have a
fairly typical system.
Some of the stuff on oopses comes from Alessandro Rubini's "Linux
Device Drivers" which is where I learned most of what I know about
kernel programming.
10.9.2. What Are Symbols?
In the context of programming, a symbol is the building block of a
program: it is a variable name or a function name. It should be of
no surprise that the kernel has symbols, just like the programs you
write. The difference is, of course, that the kernel is a very
complicated piece of coding and has many, many global symbols.
10.9.3. What Is The Kernel Symbol Table?
The kernel doesn't use symbol names. It's much happier knowing a
variable or function name by the variable or function's address.
Rather than using size_t BytesRead, the kernel prefers to refer to
this variable as (for example) c0343f20.
Humans, on the other hand, do not appreciate names like c0343f20. We
prefer to use something like size_t BytesRead. Normally, this
doesn't present much of a problem. The kernel is mainly written in
C, so the compiler/linker allows us to use symbol names when we code
and allows the kernel to use addresses when it runs. Everyone is
happy.
There are situations, however, where we need to know the address of
a symbol (or the symbol for an address). This is done by a symbol
table, and is very similar to how gdb can give you the function name
from a address (or an address from a function name). A symbol table
is a listing of all symbols along with their address. Here is an
example of a symbol table:
c03441a0 B dmi_broken
c03441a4 B is_sony_vaio_laptop
c03441c0 b dmi_ident
c0344200 b pci_bios_present
c0344204 b pirq_table
c0344208 b pirq_router
c034420c b pirq_router_dev
c0344220 b ascii_buffer
c0344224 b ascii_buf_bytes
|
You can see that the variable named dmi_broken is at the kernel
address c03441a0.
10.9.4. What Is The System.map File?
There are 2 files that are used as a symbol table:
/proc/ksyms
System.map
There. You now know what the System.map file is.
Every time you compile a new kernel, the addresses of various symbol
names are bound to change.
/proc/ksyms is a "proc file" and is created on the fly when a kernel
boots up. Actually, it's not really a file; it's simply a
representation of kernel data which is given the illusion of being a
disk file. If you don't believe me, try finding the filesize of
/proc/ksyms. Therefore, it will always be correct for the kernel
that is currently running..
However, System.map is an actual file on your filesystem. When you
compile a new kernel, your old System.map has wrong symbol
information. A new System.map is generated with each kernel compile
and you need to replace the old copy with your new copy.
10.9.5. What Is An Oops?
What is the most common bug in your homebrewed programs? The
segfault. Good ol' signal 11.
What is the most common bug in the Linux kernel? The segfault.
Except here, the notion of a segfault is much more complicated and
can be, as you can imagine, much more serious. When the kernel
dereferences an invalid pointer, it's not called a segfault -- it's
called an "oops". An oops indicates a kernel bug and should always
be reported and fixed.
Note that an oops is not the same thing as a segfault. Your program
cannot recover from a segfault. The kernel doesn't necessarily have
to be in an unstable state when an oops occurs. The Linux kernel is
very robust; the oops may just kill the current process and leave
the rest of the kernel in a good, solid state.
An oops is not a kernel panic. In a panic, the kernel cannot
continue; the system grinds to a halt and must be restarted. An oops
may cause a panic if a vital part of the system is destroyed. An
oops in a device driver, for example, will almost never cause a
panic.
When an oops occurs, the system will print out information that is
relevent to debugging the problem, like the contents of all the CPU
registers, and the location of page descriptor tables. In
particular, the contents of the EIP (instruction pointer) is
printed. Like this:
EIP: 0010:[<00000000>]
Call Trace: [<c010b860>]
|
10.9.6. What Does An Oops Have To Do With System.map?
You can agree that the information given in EIP and Call Trace is
not very informative. But more importantly, it's really not
informative to a kernel developer either. Since a symbol doesn't
have a fixed address, c010b860 can point anywhere.
To help us use this cryptic oops output, Linux uses a daemon called
klogd, the kernel logging daemon. klogd intercepts kernel oopses and
logs them with syslogd, changing some of the useless information
like c010b860 with information that humans can use. In other words,
klogd is a kernel message logger which can perform name-address
resolution. Once klogd tranforms the kernel message, it uses
whatever logger is in place to log system wide messages, usually
syslogd.
To perform name-address resolution, klogd uses System.map. Now you
know what an oops has to do with System.map.
Fine print:
There are actually two types of address resolution are performed by
klogd.
Static translation, which uses the System.map file.
Dynamic translation which is used with loadable modules,
doesn't use
System.map and is therefore not relevant to this discussion, but
I'll describe it briefly anyhow.
Klogd Dynamic Translation
Suppose you load a kernel module which generates an oops. An oops
message is generated, and klogd intercepts it. It is found that the
oops occured at d00cf810. Since this address belongs to a
dynamically loaded module, it has no entry in the System.map file.
klogd will search for it, find nothing, and conclude that a loadable
module must have generated the oops. klogd then queries the kernel
for symbols that were exported by loadable modules. Even if the
module author didn't export his symbols, at the very least, klogd
will know what module generated the oops, which is better than
knowing nothing about the oops at all.
There's other software that uses System.map, and I'll get into that
shortly.
10.9.7. Where Should System.map Be Located?
System.map should be located wherever the software that uses it
looks for it. That being said, let me talk about where klogd looks
for it. Upon bootup, if klogd isn't given the location of System.map
as an argument, it will look for System.map in 3 places, in the
following order:
/boot/System.map
/System.map
/usr/src/linux/System.map
System.map also has versioning information, and klogd intelligently
searches for the correct map file. For instance, suppose you're
running kernel 2.4.18 and the associated map file is
/boot/System.map. You now compile a new kernel 2.5.1 in the tree
/usr/src/linux. During the compiling process, the file
/usr/src/linux/System.map is created. When you boot your new kernel,
klogd will first look at /boot/System.map, determine it's not the
correct map file for the booting kernel, then look at
/usr/src/linux/System.map, determine that it is the correct map file
for the booting kernel and start reading the symbols.
A few nota bene's:
Somewhere during the 2.5.x series, the Linux kernel started to
untar into linux-version, rather than just linux (show of
hands -- how many people have been waiting for this to
happen?). I don't know if klogd has been modified to search in
/usr/src/linux-version/System.map yet. TODO: Look at the klogd
srouce. If someone beats me to it, please email me and let me
know if klogd has been modified to look in the new directory
name for the linux source code.
The man page doesn't tell the whole the story. Look at this:
# strace -f /sbin/klogd | grep 'System.map'
31208 open("/boot/System.map-2.4.18", O_RDONLY|O_LARGEFILE) = 2
|
Apparently, not only does klogd look for the correct version of the
map in the 3 klogd search directories, but klogd also knows to look
for the name "System.map" followed by "-kernelversion", like
System.map-2.4.18. This is undocumented feature of klogd.
A few drivers will need System.map to resolve symbols (since they're
linked against the kernel headers instead of, say, glibc). They will
not work correctly without the System.map created for the particular
kernel you're currently running. This is NOT the same thing as a
module not loading because of a kernel version mismatch. That has to
do with the kernel version, not the kernel symbol table which
changes between kernels of the same version!
10.9.8. What else uses the System.map
Don't think that System.map is only useful for kernel oopses.
Although the kernel itself doesn't really use System.map, other
programs such as klogd, lsof,
satan# strace lsof 2>&1 1> /dev/null | grep System
readlink("/proc/22711/fd/4", "/boot/System.map-2.4.18", 4095) = 23
|
and ps :
satan# strace ps 2>&1 1> /dev/null | grep System
open("/boot/System.map-2.4.18", O_RDONLY|O_NONBLOCK|O_NOCTTY) = 6
|
and many other pieces of software like dosemu require a correct
System.map.
10.9.9. What Happens If I Don't Have A Healthy System.map?
Suppose you have multiple kernels on the same machine. You need a
separate System.map files for each kernel! If boot a kernel that
doesn't have a System.map file, you'll periodically see a message
like: System.map does not match actual kernel Not a fatal error, but
can be annoying to see everytime you do a ps ax. Some software, like
dosemu, may not work correctly (although I don't know of anything
off the top of my head). Lastly, your klogd or ksymoops output will
not be reliable in case of a kernel oops.
10.9.10. How Do I Remedy The Above Situation?
The solution is to keep all your System.map files in /boot and
rename them with the kernel version. Suppose you have multiple
kernels like:
/boot/vmlinuz-2.2.14
/boot/vmlinuz-2.2.13
Then just rename your map files according to the kernel version and
put them in /boot, like:
/boot/System.map-2.2.14
/boot/System.map-2.2.13
|
Now what if you have two copies of the same kernel? Like:
The best answer would be if all software looked for the following
files:
/boot/System.map-2.2.14
/boot/System.map-2.2.14.nosound
|
You can also use symlinks:
System.map-2.2.14
System.map-2.2.14.sound
ln -s System.map-2.2.14.sound System.map # Here System.map -> System.map-2.2.14.sound
|
11. Advanced Topics - Linux Boot Process
This section may not be interesting for 'average Joe home PC user' but
will be more directed towards someone with computer science background.
The chain of events at boot are: CPU-> VGA-> Power-On-Self-Test-> SCSI->
Boot Manager-> Lilo boot loader-> kernel-> init-> bash. The firmware and
software programs output various messages as the computer and Linux come
to life.
A guided tour of a Linux Boot process:
The Motherboard BIOS Triggers the Video Display Card BIOS
Initialization
Motherboard BIOS Initializes Itself
SCSI Controller BIOS Initializes
Hardware Summary: The motherboard BIOS then displays the following
summary of its hardware inventory. And runs its Virus checking
code that looks for changed boot sectors.
BootManager Menu : The Master Boot Record (MBR) on the first hard
disk is read, by DOS tradition, into address 0x00007c00, and the
processor starts executing instructions there. This MBR boot code
loads the first sector of code on the active DOS partition.
Lilo is started: If the Linux selection is chosen and if Linux has
been installed with Lilo, Lilo is loaded into address 0x00007c00.
Lilo prints LILO with its progress revealed by individually
printing the letters. The first "L" is printed after Lilo moves
itself to a better location at 0x0009A000. The "I" is printed just
before it starts its secondary boot loader code. Lilo's secondary
boot loader prints the next "L", loads descriptors pointing to
parts of the kernel, and then prints the final "O". The
descriptors are placed at 0x0009d200. The boot message and a
prompt line, if specified, are printed. The pressing "Tab" at the
prompt, allows the user to specify a system and to provide
command-line specifications to the Linux Kernel, its drivers, and
the "init" program. Also, environment variables may be defined at
this point.
The following line is from /boot/message:
>
>
>
Press to list available boot image labels.
The following line is the prompt from /sbin/lilo:
boot:
Note: If Lilo is not used, then the boot code built into the head
of the Linux kernel, linux/arch/i386/boot/bootsect.S
prints "Loading" and continues.
Lilo displays the following as it loads the kernel code. It gets the
text "Linux-2.2.12" from the "label=..." specification in lilo.conf.
Loading linux-2.2.12..........
|
The kernel code in /linux/arch/i386/boot/setup.S arranges the
transition from the processor running in real mode (DOS mode) to
protected mode (full 32-bit mode). Blocks of code named
Trampoline.S and Trampoline32.S help with the transition. Small
kernel images (zImage) are decompressed and loaded at 0x00010000.
Large kernel images (bzImage) are loaded instead at 0x00100000.
This code sets up the registers, decompresses the compressed
kernel (which has linux/arch/i386/head.S at its start), printing
the following 2 lines from linux/arch/i386/boot/compressed/misc.c
Uncompressing Linux... Ok. Booting the kernel. The i386-specific
setup.S code has now completed its job and it jumps to 0x00010000
(or 0x00100000) to start the generic Linux kernel code.
Processor, Console, and Memory Initialization : This runs
linux/arch/i386/head.S which in turn jumps to
start_kernel(void) in linux/init/main.c where the interrupts
are redefined. linux/kernel/module.c then loads the drivers
for the console and pci bus. From this point on the kernel
messages are also saved in memory and available using
/bin/dmesg. They are then usually transferred to
/var/log/message for a permanent record.
PCI Bus Initialization : mpci_init() in linux/init/main.c
causes the following lines from
linux/arch/i386/kernel/bios32.c to be printed:
Network Initialization: socket_init() in linux/init/main.c
causes the following network initializations:
linux/net/socket.c prints:
Linux NET4.0 for Linux 2.2
Based upon Swansea University Computer Society NET3.039
linux/net/unix/af_unix.c prints:
NET4: Unix domain sockets 1.0 for Linux NET4.0.
linux/net/ipv4/af_inet.c prints:
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
linux/net/ipv4/ip_gre.c prints:
GRE over IPv4 tunneling driver
linux/net/core/dev.c prints:
early initialization of device gre0 is deferred
linux/net/core/rtnetlink.c prints:
Initializing RT netlink socket
|
The Kernel Idle Thread (Process 0) is Started : At this
point a kernel thread is started running init() which is one
of the routines defined in linux/init/main.c. This init()
must not be confused with the program /sbin/init that will
be run after the Linux kernel is up and running.
mkswapd_setup() in linux/init/main.c causes the following
line from linux/mm/vmscan.c to be printed: Starting kswapd v
1.5
Device Driver Initialization : The kernel routine
linux/arch/i386/kernel/setup.c then initializes devices and
file systems (built into the kernel??). It produces the
following lines and then forks to run /sbin/init:
Generic Parallel Port Initialization : The parallel
port initialization routine
linux/drivers/misc/parport_pc.c prints the following:
Character Device Initializations : The following 3
lines are from linux/drivers/char/serial.c:
Block Device Initializations :
linux/drivers/block/rd.c prints: RAM disk driver
initialized: 16 RAM disks of 8192K size
linux/drivers/block/loop.c prints: loop: registered
device at major 7 linux/drivers/block/floppy.c prints:
Floppy drive(s): fd0 is 1.44M, fd1 is 1.44M FDC 0 is a
post-1991 82077
SCSI Bus Initialization: The following lines are from
aic7xxx.c, scsi.c, sg.c, sd.c or sr.c in the
subdirectory linux/drivers/scsi:
Initialization of Kernel Support for Point-to-Point Protocol
: The following initialization is done by
linux/drivers/net/ppp.c.
Examination of Fixed Disk Arrangement : The following lines
are from linux/drivers/block/genhd.c:
Init Program (Process 1) Startup : The program /sbin/init is
started by the "idle" process (Process 0) code in
linux/init/main.c and becomes process 1. /sbin/init then completes
the initialization by running scripts and forking additional
processes as specified in /etc/inittab. It starts by printing:
INIT: version 2.76 booting and reads /etc/inittab.
The Bash Shell is Started : The bash shell, /bin/bash is then
started up. Bash initialization begins by executing script in
/etc/profile which set the system-wide environment variables:
11.1. References for Boot Process
Refer to following resources :
12. Other Formats of this Document
This section is written by
Al Dev
(at site
"http://www.milkywaygalaxy.freeservers.com"
mirrors at
angelfire
,
geocities
,
virtualave
,
Fortunecity
,
Freewebsites
,
Tripod
,
101xs
,
50megs
)
This document is published in 14 different formats namely - DVI,
Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text
Format), Plain-text, Unix man pages, single HTML file, SGML (Linuxdoc
format), SGML (Docbook format), MS WinHelp format.
This howto document is located at -
You can also find this document at the following mirrors sites -
The document is written using a tool called "SGML-Tools" which can be
got from -
"http://www.sgmltools.org"
Compiling the source you will get the following commands like
sgml2html xxxxhowto.sgml (to generate html file)
sgml2html -split 0 xxxxhowto.sgml (to generate a single page html
file)
sgml2rtf xxxxhowto.sgml (to generate RTF file)
sgml2latex xxxxhowto.sgml (to generate latex file)
12.1. Acrobat PDF format
PDF file can be generated from postscript file using either acrobat
distill
or
Ghostscript
. And postscript file is generated from DVI which in turn is generated
from LaTex file. You can download distill software from
"http://www.adobe.com"
. Given below is a sample session:
bash$ man sgml2latex
bash$ sgml2latex filename.sgml
bash$ man dvips
bash$ dvips -o filename.ps filename.dvi
bash$ distill filename.ps
bash$ man ghostscript
bash$ man ps2pdf
bash$ ps2pdf input.ps output.pdf
bash$ acroread output.pdf &
|
Or you can use Ghostscript command
ps2pdf
. ps2pdf is a work-alike for nearly all the functionality of Adobe's
Acrobat Distiller product: it converts PostScript files to Portable
Document Format (PDF) files.
ps2pdf
is implemented as a very small command script (batch file) that
invokes Ghostscript, selecting a special "output device" called
pdfwrite
. In order to use ps2pdf, the pdfwrite device must be included in the
makefile when Ghostscript was compiled; see the documentation on
building Ghostscript for details.
12.2. Convert Linuxdoc to Docbook format
This document is written in linuxdoc SGML format. The Docbook SGML
format supercedes the linuxdoc format and has lot more features than
linuxdoc. The linuxdoc is very simple and is easy to use. To convert
linuxdoc SGML file to Docbook SGML use the program
ld2db.sh
and some perl scripts. The ld2db output is not 100[percnt] clean and
you need to use the
clean_ld2db.pl
perl script. You may need to manually correct few lines in the
document.
The ld2db.sh is not 100[percnt] clean, you will get lot of errors when
you run
bash$ ld2db.sh file-linuxdoc.sgml db.sgml
bash$ cleanup.pl db.sgml > db_clean.sgml
bash$ gvim db_clean.sgml
bash$ docbook2html db.sgml
|
And you may have to manually edit some of the minor errors after
running the perl script. For e.g. you may need to put closing tag <
/Para> for each < Listitem>
12.3. Convert to MS WinHelp format
You can convert the SGML howto document to Microsoft Windows Help
file, first convert the sgml to html using:
bash$ sgml2html xxxxhowto.sgml (to generate html file)
bash$ sgml2html -split 0 xxxxhowto.sgml (to generate a single page html file)
|
Then use the tool
HtmlToHlp
. You can also use sgml2rtf and then use the RTF files for generating
winhelp files.
12.4. Reading various formats
In order to view the document in dvi format, use the xdvi program. The
xdvi program is located in tetex-xdvi*.rpm package in Redhat Linux
which can be located through ControlPanel [verbar] Applications
[verbar] Publishing [verbar] TeX menu buttons. To read dvi document
give the command -
xdvi -geometry 80x90 howto.dvi man xdvi
|
And resize the window with mouse. To navigate use Arrow keys, Page Up,
Page Down keys, also you can use 'f', 'd', 'u', 'c', 'l', 'r', 'p',
'n' letter keys to move up, down, center, next page, previous page
etc. To turn off expert menu press 'x'.
You can read postscript file using the program 'gv' (ghostview) or
'ghostscript'. The ghostscript program is in ghostscript*.rpm package
and gv program is in gv*.rpm package in Redhat Linux which can be
located through ControlPanel [verbar] Applications [verbar] Graphics
menu buttons. The gv program is much more user friendly than
ghostscript. Also ghostscript and gv are available on other platforms
like OS/2, Windows 95 and NT, you view this document even on those
platforms.
To read postscript document give the command -
gv howto.ps ghostscript howto.ps
|
You can read HTML format document using Netscape Navigator, Microsoft
Internet explorer, Redhat Baron Web browser or any of the 10 other web
browsers.
You can read the latex, LyX output using LyX a X-Windows front end to
latex.
13. Appendix A - Creating initrd.img file
The
initrd
is the "initial ramdisk". It is enough files stored in a ramdisk to
store needed drivers . You need the drivers so that the kernel can mount
/ and kick off init.
You can avoid this file 'initrd.img' and eliminate the need of
'initrd.img', if you build your scsi drivers right into the kernel,
instead of into modules. (Many persons recommend this).
13.1. Using mkinitrd
The mkinitrd utility creates an initrd image in a single command. This
is command is peculiar to RedHat. There may be equivalent command of
mkinitrd in other distributions of Linux. This is very convenient
utility.
You can read the mkinitrd man page.
/sbin/mkinitrd --help # Or simply type 'mkinitrd --help'
usage: mkinitrd [--version] [-v] [-f] [--preload <module>]
[--omit-scsi-modules] [--omit-raid-modules] [--omit-lvm-modules]
[--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]
[--builtin=<module>] [--nopivot] <initrd-image> <kernel-version>
(example: mkinitrd /boot/initrd-2.2.5-15.img 2.2.5-15)
# Read the online manual page with .....
man mkinitrd
su - root
# The command below creates the initrd image file
mkinitrd ./initrd-2.4.18-19.8.0custom.img 2.4.18-19.8.0custom
ls -l initrd-2.4.18-19.8.0custom.img
-rw-r--r-- 1 root root 127314 Mar 19 21:54 initrd-2.4.18-19.8.0custom.img
cp ./initrd-2.4.18-19.8.0custom.img /boot
|
See the following sections for the manual method of creating an initrd
image.
13.2. Kernel Docs
To create /boot/initrd.img see the documentation at
/usr/src/linux/Documentation/initrd.txt and see also
Loopback-Root-mini-HOWTO
.
13.3. Linuxman Book
A cut from
"http://www.linuxman.com.cy/rute/node1.html"
chapter 31.7.
SCSI Installation Complications and initrd
Some of the following descriptions may be difficult to understand
without knowledge of kernel modules explained in Chapter 42. You may
want to come back to it later.
Consider a system with zero IDE disks and one SCSI disk containing a
LINUX installation. There are BIOS interrupts to read the SCSI disk,
just as there were for the IDE, so LILO can happily access a kernel
image somewhere inside the SCSI partition. However, the kernel is
going to be lost without a kernel module [lsqb ]See Chapter 42. The
kernel doesn't support every possible kind of hardware out there all
by itself. It is actually divided into a main part (the kernel image
discussed in this chapter) and hundreds of modules (loadable parts
that reside in /lib/modules/) that support the many type of SCSI,
network, sound etc., peripheral devices.] that understands the
particular SCSI driver. So although the kernel can load and execute,
it won't be able to mount its root file system without loading a SCSI
module first. But the module itself resides in the root file system in
/lib/modules/. This is a tricky situation to solve and is done in one
of two ways: either (a) using a kernel with preenabled SCSI support or
(b) using what is known as an initrd preliminary root file system
image.
The first method is what I recommend. It's a straightforward (though
time-consuming) procedure to create a kernel with SCSI support for
your SCSI card built-in (and not in a separate module). Built-in SCSI
and network drivers will also autodetect cards most of the time,
allowing immediate access to the device--they will work without being
given any options [lsqb ]Discussed in Chapter 42.] and, most
importantly, without your having to read up on how to configure them.
This setup is known as compiled-in support for a hardware driver (as
opposed to module support for the driver). The resulting kernel image
will be larger by an amount equal to the size of module. Chapter 42
discusses such kernel compiles.
The second method is faster but trickier. LINUX supports what is known
as an initrd image ( initial rAM disk image). This is a small, +1.5
megabyte file system that is loaded by LILO and mounted by the kernel
instead of the real file system. The kernel mounts this file system as
a RAM disk, executes the file /linuxrc, and then only mounts the real
file system.
31.6 Creating an initrd Image
Start by creating a small file system. Make a directory [nbsp ]/initrd
and copy the following files into it.
drwxr-xr-x 7 root root 1024 Sep 14 20:12 initrd/
drwxr-xr-x 2 root root 1024 Sep 14 20:12 initrd/bin/
-rwxr-xr-x 1 root root 436328 Sep 14 20:12 initrd/bin/insmod
-rwxr-xr-x 1 root root 424680 Sep 14 20:12 initrd/bin/sash
drwxr-xr-x 2 root root 1024 Sep 14 20:12 initrd/dev/
crw-r--r-- 1 root root 5, 1 Sep 14 20:12 initrd/dev/console
crw-r--r-- 1 root root 1, 3 Sep 14 20:12 initrd/dev/null
brw-r--r-- 1 root root 1, 1 Sep 14 20:12 initrd/dev/ram
crw-r--r-- 1 root root 4, 0 Sep 14 20:12 initrd/dev/systty
crw-r--r-- 1 root root 4, 1 Sep 14 20:12 initrd/dev/tty1
crw-r--r-- 1 root root 4, 1 Sep 14 20:12 initrd/dev/tty2
crw-r--r-- 1 root root 4, 1 Sep 14 20:12 initrd/dev/tty3
crw-r--r-- 1 root root 4, 1 Sep 14 20:12 initrd/dev/tty4
drwxr-xr-x 2 root root 1024 Sep 14 20:12 initrd/etc/
drwxr-xr-x 2 root root 1024 Sep 14 20:12 initrd/lib/
-rwxr-xr-x 1 root root 76 Sep 14 20:12 initrd/linuxrc
drwxr-xr-x 2 root root 1024 Sep 14 20:12 initrd/loopfs/
|
On my system, the file initrd/bin/insmod is the statically linked
[lsqb ]meaning it does not require shared libraries.] version copied
from /sbin/insmod.static--a member of the modutils-2.3.13 package.
initrd/bin/sash is a statically linked shell from the sash-3.4
package. You can recompile insmod from source if you don't have a
statically linked version. Alternatively, copy the needed DLLs from
/lib/ to initrd/lib/. (You can get the list of required DLLs by
running ldd /sbin/insmod. Don't forget to also copy symlinks and run
strip -s [lcub ]lib[rcub ] to reduce the size of the DLLs.)
Now copy into the initrd/lib/ directory the SCSI modules you require.
For example, if we have an Adaptec AIC-7850 SCSI adapter, we would
require the aic7xxx.o module from /lib/modules/[lcub ]version[rcub
]/scsi/aic7xxx.o. Then, place it in the initrd/lib/ directory.
-rw-r--r-- 1 root root 129448 Sep 27 1999 initrd/lib/aic7xxx.o
|
The file initrd/linuxrc should contain a script to load all the
modules needed for the kernel to access the SCSI partition. In this
case, just the aic7xxx module [lsqb ] insmod can take options such as
the IRQ and IO-port for the device. See Chapter 42.]:
#!/bin/sash
aliasall
echo "Loading aic7xxx module"
insmod /lib/aic7xxx.o
|
Now double-check all your permissions and then chroot to the file
system for testing.
chroot ~/initrd /bin/sash
/linuxrc
|
Now, create a file system image similar to that in Section 19.9:
dd if=/dev/zero of=~/file-inird count=2500 bs=1024
losetup /dev/loop0 ~/file-inird
mke2fs /dev/loop0
mkdir ~/mnt
mount /dev/loop0 ~/mnt
cp -a initrd/* ~/mnt/
umount ~/mnt
losetup -d /dev/loop0
|
Finally, gzip the file system to an appropriately named file:
gzip -c ~/file-inird > initrd-<kernel-version>
|
31.7 Modifying lilo.conf for initrd
Your lilo.conf file can be changed slightly to force use of an initrd
file system. Simply add the initrd option. For example:
boot=/dev/sda
prompt
timeout = 50
compact
vga = extended
linear
image = /boot/vmlinuz-2.2.17
initrd = /boot/initrd-2.2.17
label = linux
root = /dev/sda1
read-only
|
Notice the use of the linear option. This is a BIOS trick that you can
read about in lilo(5). It is often necessary but can make SCSI disks
nonportable to different BIOSs (meaning that you will have to rerun
lilo if you move the disk to a different computer).
14. Appendix B - Sample lilo.conf14.1. Resources on LILO
See also following documents:
14.2. Troubleshooting LILO
The beeper error codes :
Table 1.
Beeper Error Codes Table
Code
|
Description
|
---|
0
|
PC-Speaker Defect
|
1
|
Refresh of DRAM defect
|
2
|
Paritykring defect
|
3
|
Error in the 64 basis RAM
|
4
|
Systeemtimer defect
|
5
|
Processor defect
|
6
|
Keyboard controller error
|
7
|
Virtuele modus error
|
8
|
Test from videomemory failed
|
9
|
ROM-BIOS checksumm error
|
2 short beeps : POST not correct. Error in a Harware test. 1 short & 2
long beeps : video error. 1) Video ROM BIOS, parity error. 2) Problem
with the horizontal retour from the video adapter. 1 long & 3 short
beeps: video error. 1) videocard defect. 2) wrong detection from used
monitor. 3) Video RAM error. 1 long beep : POST was correct If there
is a posterror, there is a hardwareproblem. Check the extentioncards
for a bad contact
See also
http://www.preggers.easynet.be/lilo.html
If you get problems in LILO, refer to following tips. During boot if
you get error "L0101010101010101 ....", then do this
Use your favorite text editor to open /etc/lilo.conf
# Find the line that reads
linear
# Comment it out. Change it to read
# linear
Save and rerun lilo.
|
You need to have your booting partion below the 8 gb mark. If
you have a program like parition magic or Mandrake's DiskDrake
utility you can easily fix this.
01 is dram refresh error. When you get the L 01 simply reboot
again with CTRL+ATL+DEL (but you should not power off just do
ctrl+alt+del). This may correct the problem.
14.3. Sample on LILO
Always give a date extension to the filename, because it tells you
when you built the kernel, as shown below:
bash# man lilo
bash# man lilo.conf
And edit /etc/lilo.conf file and put these lines -
image=/boot/bzImage.myker.26mar2001
label=myker
root=/dev/hda1
read-only
You can check device name for 'root=' with the command -
bash# df /
Now give -
bash# lilo
bash# lilo -q
|
You must re-run lilo even if the entry 'myker' exists, everytime you
create a new bzImage.
Given below is a sample /etc/lilo.conf file. You should follow the
naming conventions like ker2217 (for kernel 2.2.17), ker2214 (for
kernel 2.2.14). You can have many kernel images on the same /boot
system. On my machine I have something like:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
default=firewall
image=/boot/vmlinuz-2.2.14-5.0
label=ker2214
read-only
root=/dev/hda9
image=/boot/vmlinuz-2.2.17-14
label=ker2217
read-only
root=/dev/hda9
#image=/usr/src/linux/arch/i386/boot/bzImage
# label=myker
# root=/dev/hda7
# read-only
image=/boot/bzImage.myker.11feb2001
label=myker11feb
root=/dev/hda9
read-only
image=/boot/bzImage.myker.01jan2001
label=myker01jan
root=/dev/hda9
read-only
image=/boot/bzImage.myker-firewall.16mar2001
label=firewall
root=/dev/hda9
read-only
|
15. Appendix C - GRUB Details And A Sample grub.conf15.1. References on GRUB
See
bash# man grub
bash# man grubby # (command line tool for configuring grub, lilo, and elilo)
bash# man grub-install
|
Edit the file /etc/grub.conf to make entries for the new kernel. See
the sample file below:
15.2. Tips On GRUB
In Redhat Linux, during grub display, just type c for command-line
option of GRUB:
To boot Linux do this:
grub> help
grub> root
(hd1,1): Filesystem is type ext2fs, partition type 0x83
grub> root (hd1,0)
grub> kernel / <Press-TAB-KEY>
This will list all files
grub> kernel /boot <Press-TAB-KEY>
This will list all files in /boot
grub> kernel /boot/vmlinuz
grub> boot
|
See also the
GRUB Manual
. To boot MS Windows 95/2000 etc do this: If you want to boot an
unsupported operating system (e.g. Windows 95), chain-load a boot
loader for the operating system. Normally, the boot loader is embedded
in the boot sector of the partition on which the operating system is
installed.
grub> help
grub> help rootnoverify
grub> rootnoverify (hd0,0)
grub> makeactive
grub> chainloader +1
grub> boot
|
15.3. Sample GRUB Conf File
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,8)
# kernel /boot/vmlinuz-version ro root=/dev/hda9
# initrd /boot/initrd-version.img
#boot=/dev/hda
# By default boot the second entry
default=1
# Fallback to the first entry.
fallback 0
# Boot automatically after 2 minutes
timeout=120
splashimage=(hd0,8)/boot/grub/splash.xpm.gz
title Windows 2000
unhide (hd0,0)
hide (hd0,1)
hide (hd0,2)
rootnoverify (hd0,0)
chainloader +1
makeactive
title Red Hat Linux (2.4.18-19.8.0.19mar2003)
root (hd0,8)
kernel /boot/bzImage.2.4.18-19.8.0.19mar2003 ro root=LABEL=/ hdd=ide-scsi
initrd /boot/initrd-2.4.18-19.8.0custom.img.19mar03
title Red Hat Linux (2.4.18-19.8.0custom)
root (hd0,8)
kernel /boot/vmlinuz-2.4.18-19.8.0custom ro root=LABEL=/ hdd=ide-scsi
initrd /boot/initrd-2.4.18-19.8.0custom.img
title Red Hat Linux (2.4.18-14)
root (hd0,8)
kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdd=ide-scsi
initrd /boot/initrd-2.4.18-14.img
title MyKernel.26jan03 (Red Hat Linux 2.4.18-14)
root (hd0,8)
kernel /boot/bzImage.myker.26jan03 ro root=LABEL=/ hdd=ide-scsi
initrd /boot/initrd-2.4.18-19.8.0.img
title Windows 98
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
rootnoverify (hd0,2)
chainloader +1
makeactive
title DOS 6.22
hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
rootnoverify (hd0,1)
chainloader +1
makeactive
title Partition 2 (floppy)
hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
chainloader (fd0)+1
title Partition 3 (floppy)
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
chainloader (fd0)+1
|
16. Appendix D - Post Kernel Building
After successfully building and booting the Linux kernel, you may be
required to do these additional steps to make some of the devices to
work with Linux. (The steps below were tested on Redhat Linux but should
work with other distributions as well.)
Video card/Monitor configuration:
Please see the video card manual which is usually shipped with the
PC. You should look for a "Technical Specifications" page.
Please see the monitor's manual and look for a "Technical
Specifications" page.
If you are using latest version of Linux (2.4 or later) and inside
KDE/GNOME desktop click on Start->"System Settings"->Display.
For older versions of Linux follow the steps below:
You can configure the Video card and monitor by using these commands:
bash$ su - root
bash# man Xconfigurator
bash# /usr/bin/X11/Xconfigurator --help
bash# /usr/bin/X11/Xconfigurator
bash# /usr/bin/X11/Xconfigurator --expert
See also:
bash# man xf86config
bash# /usr/bin/X11/xf86config
|
If your card is not detected automatically, then you can use the
--expert option and select the "Unlisted card". If your monitor is not
listed then select the generic monitor type SVGA 1024x768.
Sound card configuration:
Connect your external speakers to the sound card's audio port.
Connect your CDROM audio wire to sound card's audio 4-pin socket.
(Otherwise your cdrom drive will not play the music from your
music cd)
Refer to HOWTO docs on 'Sound' at
"http://www.linuxdoc.org"
If you are using latest version of Linux (2.4 or later) and inside
KDE/GNOME desktop click on Start->"System Settings"->Soundcard
Detection.
For older versions of Linux follow the steps below:
bash$ su - root
bash# man sndconfig
bash# /usr/sbin/sndconfig
|
Then start X-window 'KDE desktop' with 'startx' command. Click on 'K
Start->ControlCenter->SoundServer->General->Test Sound'.
This should play the test sound. Then click on 'K
Start->MultiMedia->SoundMixer->SoundVolumeSlider' and adjust
the sound volume.
Network card configuration:
If you are using latest version of Linux (2.4 or later) and inside
KDE/GNOME desktop click on Start->"System Settings"->Network.
For older versions of Linux follow the steps below:
Configure Firewall and IP Masquerading :
For Linux kernel version 2.4 and above, the firewall and IP Masquerading
is implemented by NetFilter package. Hence in kernel config you should
enable Netfilter and run the Firewall/IPMasq script. Download the
scripts from
Firewall-IPMasq scripts
, main page of Netfilter is at
"http://netfilter.samba.org"
. Related materials at
firewalling-matures
and
Netfilter-FAQ
.
For kernel version below 2.4 you should install the firewall rpms from
rpmfind.net
or
firewall.src.rpm
.
Configuration of other devices:
Refer to HOWTO docs relating to your devices at
"http://www.linuxdoc.org"
17. Appendix E - Troubleshoot Common Mistakes17.1. Compiles OK but does not boot
If the kernel compiles ok but booting never works and it always
complains with a kernel panic about /sbin/modprobe.
Solution: You did not create initrd image file. See the Appendix A at
Section 13
. Also, you must do 'make modules' and 'make modules_install' in
addition to creating the initrd image file.
17.2. The System Hangs at LILO
Sympton:
After you build the kernel and reboot, the system hangs just before
LILO.
Reason:
Probably you did not set the BIOS to pick up the proper Primary Master
IDE and Secondary Slave IDE hard disk partition.
Solution:
Power on the machine and press DEL key to do setup of the BIOS (Basic
Input Output system). Select the IDE settings and set proper primary
hard disk partition and slave drives. When the system boots it looks
for the primary IDE hard disk and the Master Boot Record partition. It
reads the MBR and starts loading the Linux Kernel from the hard disk
partition.
17.3. No init found
The following mistake is commited very frequently by new users.
If your new kernel does not boot and you get -
Warning: unable to open an initial console
Kernel panic: no init found. Try passing init= option to kernel
|
The problem is that you
did not
set the "root=" parameter properly in the /etc/lilo.conf. In my case,
I used root=/dev/hda1 which is having the root partition "/". You must
properly point the root device in your lilo.conf, it can be like
/dev/hdb2 or /dev/hda7.
The kernel looks for the init command which is located in /sbin/init.
And /sbin directory lives on the root partition. For details see -
See the
Section 15
file and see the
Section 14
.
17.4. Lot of Compile Errors
The 'make', 'make bzImage', 'make modules' or 'make modules_install'
gives compile problems. You should give 'make mrproper' before doing
make.
If this problem persists, then try menuconfig instead of xconfig.
Sometimes GUI version xconfig causes some problems:
bash# export TERM=VT100
bash# make menuconfig
|
17.5. The 'depmod' gives "Unresolved symbol error messages"
When you run
depmod
it gives "Unresolved symbols". A sample error message is given here to
demonstrate the case:
bash$ su - root
bash# man depmod
bash# depmod
depmod: *** Unresolved symbols in /lib/modules/version/kernel/drivers/md/linear.o
depmod: *** Unresolved symbols in /lib/modules/version/kernel/drivers/md/multipath.o
depmod: *** Unresolved symbols in /lib/modules/version/kernel/drivers/md/raid0.o
depmod: *** Unresolved symbols in /lib/modules/version/kernel/drivers/md/raid1.o
depmod: *** Unresolved symbols in /lib/modules/version/kernel/drivers/md/raid5.o
|
Reason:
You did not make modules and install the modules after building the
new kernel with
"make bzImage"
.
Solution:
After you build the new kernel, you must do:
bash$ su - root
bash# cd /usr/src/linux
bash# make modules
bash# make modules_install
|
17.6. Kernel Does Not Load Module - "Unresolved symbols" Error Messages
When you boot kernel and system tries to load any modules and you get
"Unresolved symbol : __some_function_name" then it means that you did
not clean compile the modules and kernel. It is mandatory that you
should do
make clean
and make the modules. Do this -
bash# cd /usr/src/linux
bash# make dep
bash# make clean
bash# make mrproper
bash# nohup make bzImage &
bash# tail -f nohup.out (.... to monitor the progress)
bash# make modules
bash# make modules_install
|
17.7. Kernel fails to load a module
If the kernel fails to load a module (say loadable module for network
card or other devices), then you may want to try to build the driver
for device right into the kernel. Sometimes
loadable module will NOT work
and the driver needs to be built right inside the kernel. For example
- some network cards do not support loadable module feature - you MUST
build the driver of the network card right into linux kernel. Hence,
in 'make xconfig' you MUST not select loadable module for this device.
17.8. Loadable modules
You can install default loadable modules with -
The step given below may not be required but is needed
ONLY FOR EMERGENCIES
where your /lib/modules files are damaged. If you already have the
/lib/modules directory and in case you want replace them use the
--force to replace the package and select appropriate cpu
architecture.
For new versions of linux redhat linux 6.0 and later, the kernel
modules are included with kernel-2.2*.rpm. Install the loadable
modules and the kernel with
This will list the already installed package.
bash# rpm -qa | grep -i kernel
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i686.rpm
(or)
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i586.rpm
(or)
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i386.rpm
|
This is only for old versions of redhat linux 5.2 and before. Boot new
kernel and install the loadable modules from RedHat Linux "contrib"
cdrom
bash# rpm -i /mnt/cdrom/contrib/kernel-modules*.rpm
....(For old linux systems which do not have insmod pre-installed)
|
17.9. See Docs
More problems. You can read the /usr/src/linux/README (at least once)
and also /usr/src/linux/Documentation.
17.10. make clean
If your new kernel does really weird things after a routine kernel
upgrade, chances are you forgot to
make clean
before compiling the new kernel. Symptoms can be anything from your
system outright crashing, strange I/O problems, to crummy performance.
Make sure you do a
make dep
, too.
17.11. Huge or slow kernels
If your kernel is sucking up a lot of memory, is too large, and/or
just takes forever to compile even when you've got your new
Quadbazillium-III/4400 working on it, you've probably got lot of
unneeded stuff (device drivers, filesystems, etc) configured. If you
don't use it, don't configure it, because it does take up memory. The
most obvious symptom of kernel bloat is extreme swapping in and out of
memory to disk; if your disk is making a lot of noise and it's not one
of those old Fujitsu Eagles that sound like like a jet landing when
turned off, look over your kernel configuration.
You can find out how much memory the kernel is using by taking the
total amount of memory in your machine and subtracting from it the
amount of ``total mem'' in
/proc/meminfo
or the output of the command `
free
'.
17.12. The parallel port doesn't work/my printer doesn't work
Configuration options for PCs are: First, under the category `General
Setup', select `Parallel port support' and `PC-style hardware'. Then
under `Character devices', select `Parallel printer support'.
Then there are the names. Linux 2.2 names the printer devices
differently than previous releases. The upshot of this is that if you
had an
lp1
under your old kernel, it's probably an
lp0
under your new one. Use `
dmesg
' or look through the logs in
/var/log
to find out.
17.13. Kernel doesn't compile
If it does not compile, then it is likely that a patch failed, or your
source is somehow corrupt. Your version of gcc also might not be
correct, or could also be corrupt (for example, the include files
might be in error). Make sure that the symbolic links which Linus
describes in the
README
are set up correctly. In general, if a standard kernel does not
compile, something is seriously wrong with the system, and
reinstallation of certain tools is probably necessary.
In some cases, gcc can crash due to hardware problems. The error
message will be something like ``xxx exited with signal 15'' and it
will generally look very mysterious. I probably would not mention
this, except that it happened to me once - I had some bad cache
memory, and the compiler would occasionally barf at random. Try
reinstalling gcc first if you experience problems. You should only get
suspicious if your kernel compiles fine with external cache turned
off, a reduced amount of RAM, etc.
It tends to disturb people when it's suggested that their hardware has
problems. Well, I'm not making this up. There is an FAQ for it -- it's
at
"http://www.bitwizard.nl/sig11"
.
17.14. New version of the kernel doesn't seem to boot
You did not run LILO, or it is not configured correctly. One thing
that ``got'' me once was a problem in the config file; it said `
boot = /dev/hda1
' instead of `
boot = /dev/hda
' (This can be really annoying at first, but once you have a working
config file, you shouldn't need to change it.).
17.15. You forgot to run LILO, or system doesn't boot at all
Ooops! The best thing you can do here is to boot off of a floppy disk
or CDROM and prepare another bootable floppy (such as `
make zdisk
' would do). You need to know where your root (
/
) filesystem is and what type it is (e.g. second extended, minix). In
the example below, you also need to know what filesystem your
/usr/src/linux
source tree is on, its type, and where it is normally mounted.
In the following example,
/
is
/dev/hda1
, and the filesystem which holds
/usr/src/linux
is
/dev/hda3
, normally mounted at
/usr
. Both are second extended filesystems. The working kernel image in
/usr/src/linux/arch/i386/boot
is called
bzImage
.
The idea is that if there is a functioning
bzImage
, it is possible to use that for the new floppy. Another alternative,
which may or may not work better (it depends on the particular method
in which you messed up your system) is discussed after the example.
First, boot from a boot/root disk combo or rescue disk, and mount the
filesystem which contains the working kernel image:
mkdir /mnt mount -t ext2 /dev/hda3 /mnt
If
mkdir
tells you that the directory already exists, just ignore it. Now,
cd
to the place where the working kernel image was. Note that /mnt +
/usr/src/linux/arch/i386/boot - /usr = /mnt/src/linux/arch/i386/boot
Place a formatted disk in drive ``A:'' (not your boot or root disk!),
dump the image to the disk, and configure it for your root filesystem:
cd /mnt/src/linux/arch/i386/boot dd if=bzImage of=/dev/fd0 rdev
/dev/fd0 /dev/hda1
cd
to
/
and unmount the normal
/usr
filesystem:
cd / umount /mnt
You should now be able to reboot your system as normal from this
floppy. Don't forget to run lilo (or whatever it was that you did
wrong) after the reboot!
As mentioned above, there is another common alternative. If you
happened to have a working kernel image in
/
(
/vmlinuz
for example), you can use that for a boot disk. Supposing all of the
above conditions, and that my kernel image is
/vmlinuz
, just make these alterations to the example above: change
/dev/hda3
to
/dev/hda1
(the
/
filesystem),
/mnt/src/linux
to
/mnt
, and
if=bzImage
to
if=vmlinuz
. The note explaining how to derive
/mnt/src/linux
may be ignored.
Using LILO with big drives (more than 1024 cylinders) can cause
problems. See the LILO mini-HOWTO or documentation for help on that.
17.16. It says `warning: bdflush not running'
This can be a severe problem. Starting with a kernel release after
Linux v1.0 (around 20 Apr 1994), a program called `
update
' which periodically flushes out the filesystem buffers, was
upgraded/replaced. Get the sources to `
bdflush
' (you should find it where you got your kernel source), and install
it (you probably want to run your system under the old kernel while
doing this). It installs itself as `
update
' and after a reboot, the new kernel should no longer complain.
17.17. I can't get my IDE/ATAPI CD-ROM drive to work
Strangely enough, lot of people cannot get their ATAPI drives working,
probably because there are a number of things that can go wrong.
If your CD-ROM drive is the only device on a particular IDE interface,
it must be jumpered as ``master'' or ``single.'' Supposedly, this is
the most common error.
Creative Labs (for one) has put IDE interfaces on their sound cards
now. However, this leads to the interesting problem that while some
people only have one interface to being with, many have two IDE
interfaces built-in to their motherboards (at IRQ15, usually), so a
common practice is to make the soundblaster interface a third IDE port
(IRQ11, or so I'm told).
This causes problems with older Linux versions like 1.3 and below. in
that versions Linux don't support a third IDE interface. To get around
this, you have a few choices.
If you have a second IDE port already, chances are that you are not
using it or it doesn't already have two devices on it. Take the ATAPI
drive off the sound card and put it on the second interface. You can
then disable the sound card's interface, which saves an IRQ anyway.
If you don't have a second interface, jumper the sound card's
interface (not the sound card's sound part) as IRQ15, the second
interface. It should work.
17.18. It says weird things about obsolete routing requests
Get new versions of the
route
program and any other programs which do route manipulation.
/usr/include/linux/route.h
(which is actually a file in
/usr/src/linux
) has changed.
17.19. ``Not a compressed kernel Image file''
Don't use the
vmlinux
file created in
/usr/src/linux
as your boot image;
[..]/arch/i386/boot/bzImage
is the right one.
17.20. Problems with console terminal after upgrade to Linux v1.3.x
Change the word
dumb
to
linux
in the console termcap entry in
/etc/termcap
. You may also have to make a terminfo entry.
17.21. Can't seem to compile things after kernel upgrade
The linux kernel source includes a number of include files (the things
that end with
.h
) which are referenced by the standard ones in
/usr/include
. They are typically referenced like this (where
xyzzy.h
would be something in
/usr/include/linux
): #include <linux/xyzzy.h> Normally, there is a link called
linux
in
/usr/include
to the
include/linux
directory of your kernel source (
/usr/src/linux/include/linux
in the typical system). If this link is not there, or points to the
wrong place, most things will not compile at all. If you decided that
the kernel source was taking too much room on the disk and deleted it,
this will obviously be a problem. Another way it might go wrong is
with file permissions; if your
root
has a umask which doesn't allow other users to see its files by
default, and you extracted the kernel source without the
p
(preserve filemodes) option, those users also won't be able to use the
C compiler. Although you could use the
chmod
command to fix this, it is probably easier to re-extract the include
files. You can do this the same way you did the whole source at the
beginning, only with an additional argument:
blah# tar zxvpf linux.x.y.z.tar.gz linux/include Note: ``
make config
'' will recreate the
/usr/src/linux
link if it isn't there.
17.22. Increasing limits
The following few
example
commands may be helpful to those wondering how to increase certain
soft limits imposed by the kernel: echo 4096 >
/proc/sys/kernel/file-max echo 12288 > /proc/sys/kernel/inode-max
echo 300 400 500 > /proc/sys/vm/freepages
|
|