Вы находитесь на странице: 1из 30

HowTo (kernel) Linux

Brian Ward, bri@cs.uchicago.edu


v1.0, 5 1999
,
compilation, , / ix86.
______________________________________________________________________
Table of Contents

1.
1.1 ! ( )
1.2
2. ,
2.1
2.2
2.3
2.4
2.5
2.6
2.7

, , ;
;
hardware ;
gcc libc ;
module (loadable);
;
;

3.
3.1 (source)
3.2 source
3.3
3.3.1 ( Pr)
3.3.2 MFM/RLL, IDE, cdrom (Block Devices)
3.3.3 ( )
3.3.4 System V IPC ( )
3.3.5 processor ( processor)
3.3.6 SCSI
3.3.7
3.3.8 (Filesystems)
3.3.8.1 , filesystems !
3.3.9 (Character devices)
3.3.10
3.3.11
3.3.12
3.4 , ; ( Makefile)
4. compile
4.1
4.2
4.3
4.4


compile
"make"

5. (patching)
5.1
5.2
5.3
5.4

(patch)

.orig
patches

6.
6.1 kbd
6.2 util-linux
6.3 hdparm

6.4 gpm
7.

7.1 make clean


7.2
7.3 ,
7.4 compile
7.5 boot
7.6 LILO, / boot
7.7 "warning: bdflush not running"
7.8 IDE/ATAPI CD-ROM
7.9 routing
7.10 firewalling 1.2.0
7.11 "Not a compressed kernel Image file"
7.12 (console terminal) 1.3.x
7.13 compile,
7.14
8. 2.0.x, 2.2.x
9. Modules
9.1 utilities modules
9.2 Modules
10.
10.1 make patch
10.2
10.3
11. HOWTOs
12.
12.1
12.2
12.3
12.4

Copyright, ,

______________________________________________________________________
1.
; ,
' :

"! -46.5.6
2.8.193, 1.0.9!"
driver ' ,
.
compile ' .
" README

;"
, .
, '
.
1.1. ! ( )

GNU tar, find, xargs.
, . ,

(filesystem) / . ,
( /)
mount, /etc/fstab (
). ,
, partition ,
,
Linux, .
""
2.2.9 ,
' .
,
. ,
, .
, .
source Linux,
"" "".
. 1.2.x ,
2.0.x , 2.2.x . (
)
bugs. (2.1.x , 2.3.x , )
,
( bugs) . !

1.2.
, ,
, (
), (
text, ). ( )
("),
:
,
,
. ( ,
" "
) '
, ,
' . ' ,
"make config",
"make config", "make config." . (... : ,

,
.)

2. ,
2.1. , , ;
*nix's
hardware. , (
) (processes),
( , )
. ,
,
hardware.
,
,
.
2.2. ;

hardware (, drivers
), ,
' , '
,
. ,
drivers bugs.

2.3. hardware ;
Hardware-HOWTO. ,
config.in source Linux,
, make config.
hardware ,
Linux. drivers
( PCMCIA )
modules (loadable),
.

2.4. gcc libc ;


README,
Linus gcc.
libc,
gcc '
, '
.

source Linux, o
, ,

libc .

2.5. module (loadable);


modules ,
(linked) . compile
,
( ), .
,
. drivers
, drivers PCMCIA
QIC-80/40, modules .

2.6. ;
/ . ,
source Linux 14 Mytes
2.2.9 .
, 67 MB.

2.7. ;
/, compilation ,
' , . AMD K6-2/300
2.2.x .
compilation Pentiums, 486s, 386s,
, ...
, compile
/ ,
( ,
utilities , ),
image .

3.
3.1. (source)
source anonymous ftp
ftp.kernel.org, dir /pub/linux/kernel/vx.y, x.y
( 2.2), - -
, .
linux-x.y.z.tar.gz, x.y.z
. sites
.bz2, . bzip2. (
, .)
ftp.xx.kernel.org, xx
. , ftp.at.kernel.org
, ftp.us.kernel.org .

3.2. source

login ( su ) root, cd directory


/usr/src. source (
), dir linux,
source.
,
directory.
/ , ' dir. uname
-r . , uname -r
1.0.9, ( mv) linux linux-1.0.9.
,
directory. , ,
source , directory linux
/usr/src.
, /usr/src, tar
zxpvf linux-x.y.z.tar.gz. ( .tar, .gz
, tar xpvf linux-x.y.z.tar.)
source . ,
linux directory /usr/src. cd
linux, README.
INSTALLING the kernel ( = ).
-
(symbolic links) ,
.o, .
.bz2 bzip2 ( '
http://www.muraroa.demon.co.uk/), :

bz2cat linux-x.y.z.tar.bz2 | tar xvf 3.3.


: /
README Linus.
make config,
script ,
bash,
/bin/bash, /bin/sh,

/usr/src/linux,
. script
bash
$BASH.

, make
config,
. make menuconfig
. , , ,
, '
' . X-Windows,
make xconfig, , Tk ("clicko-rama" - Nat). make menuconfig
(n)curses text .
:
,
.

make menuconfig make xconfig,


.
, ' , y (yes,
), n (no, ). drivers
m. "module", /
compile, , module
. m,
"maybe". ( = .)
, .
, " ".
make menuconfig,
.
2.0.x ( ) "?",
.
.
,
, .

3.3.1. (
Pr)
(. 386 486SX
/), ' y .
, ' ' y,
- ,
' .
no, yes
. , .

3.3.2. MFM/RLL, IDE, cdrom (Block


Devices)
.
PC,
. driver
SCSI. ' ' .
drivers "old () disk-only"
"new () IDE". ' .
driver
(. ),
(.
) cd-rom IDE/ATAPI. driver is 4k
, "",
( bugs)
, hardware

( EIDE).

3.3.3. ( )
, ' y /
' ( Internet),
SLIP, PPP, term, ,
Internet. , ( X
Windows) , /
, ' y. ,
TCP/IP. y
, .

3.3.4. System V IPC ( )


IPC (Interprocess Communication,
) , Perl.
, Perl
IPC processes
, (
DOOM), ' n,
.

3.3.5. processor ( processor)


( : -m486
486.)
, compile
. ,
, .
, compile
. "386" '
ix86 /.

3.3.6. SCSI
SCSI devices, y.
, cd-rom, ,
SCSI . , SCSIHOWTO.

3.3.7.
, SLIP PPP,

Internet, y. script
,
.

3.3.8. (Filesystems)
, script
filesystems :
(minix) - minix
filesystems, ,
.
" ",
minix filesystem,
.
second extended - filesystem Linux.
, y.
msdos - MS-DOS partitions
, mount MS-DOS , y.
filesystems .
/proc - ( Bell Labs, .)
proc filesystem ' :
filesystem (processes).
(process listers),
ps. cat /proc/meminfo, cat
/proc/devices. (shells), rc,
/proc/self/fd ( /dev/fd ) -
(I/O). y .
Linux ' .
NFS - / ' ,
filesystems / NFS,
y.
ISO9660 - CD-ROMs. CDROM, Linux, y.

3.3.8.1. , filesystems !
, mount. :

blah# mount
/dev/hda1 on / type ext2 (defaults)
/dev/hda3 on /usr type ext2 (defaults)
none on /proc type proc (defaults)
/dev/fd0 on /mnt type msdos (defaults)

: type
filesystem. filesystems / /usr second
extended, /proc,
mount, msdos (!) filesystem.
cat /proc/filesystems,
/proc : filesystems .
, filesystems .
modules ,
""
.

3.3.9. (Character devices)


drivers (.
), busmouse PS/2 (
/ PS/2 trackballs
), ,
"". y .
: gpm , (
X-Windows) cut paste
(virtual) . ,
X,
.

3.3.10.
' biff , y,
,
. ( :
driver,
' n
, .)
,
drivers http://www.linux.org.uk/OSS/,
Open Sound System (OSS), http://www.opensound.com/.

3.3.11.
,
, (
3Com 3C509 compile driver
ethernet.)
( script Configure),
Axel Boldt
(boldt@math.ucsb.edu), online .
(
2.0), Documentation/Configure.help
dirs source Linux .

3.3.12.
> README Linus :
" (kernel hacking)"
( ),
,
,
( kmalloc() ). ,
' "n" "".

3.4. , ; ( Makefile)
,
, " -
Makefile (check the top-level Makefile for
additional configuration)", .
, Makefile.
, . '
,
rdev. ,
.

4. compile
4.1.
script , make
dep ( = ) () clean ( =
). , make dep.
, include, .
, /
. ,
make clean. object
, .
,
compile .

4.2. compile
depend clean, make bzImage,
make bzdisk. (
.) make bzImage compile ,
directory arch/i386/boot, (
) bzImage. , .
make bzdisk ,
bzImage ,
"A:". bzdisk ,
. ( ),
. '
boot,
( ).
,
' . ("'
! ' ;")
( )
, bz .
, .
, bzImage.
zImage. ,
, ,
, .

4.3. "make"
make mrproper clean,
.
(patch). make mrproper ,
backup (.config),
.
make oldconfig
. make config.
compile ,
, ,
' default .
modules, make modules.

4.4.
,
, .
LILO (Linux Loader) . make
bzlilo , LILO,
boot, lilo /

: /vmlinuz, lilo
/sbin, lilo (/etc/lilo.conf)
.
, LILO .
' ,

. (/etc/lilo/config
Linux, /etc/lilo.conf ),
. :
image = /vmlinuz
label = Linux
root = /dev/hda1
...

image = ,
/vmlinuz. label ( = )
lilo
boot, root directory /
. backup
bzImage . ( cp
bzImage /vmlinuz, /vmlinuz). ,
lilo. lilo,
/etc/lilo/install (), /etc/lilo/lilo
-C /etc/lilo/config ().
LILO,
LILO,
ftp server, .
boot '
( ,
),
( ) image = xxx
LILO, image = xxx image = yyy, yyy
path , backup
. , label = zzz label = linux-backup
lilo.
, delay=x, x
, LILO
boot, (
shift), label () backup (
).

5. (patching)
5.1. (patch)
patches ( =
). , 1.1.45,
patch46.gz ' ,

1.1.46, patch. ,
backup dirs source
( make clean, cd /usr/src; tar zcvf oldtree.tar.gz linux, tar ).
, ,
patch46.gz /usr/src. cd dir /usr/src
zcat patch46.gz | patch -p0 ( patch -p0 < patch46, patch
). (
, / ),
, .
,
,
. ,
-s patch,
. ( '
" , / ' !",
.)
, dir /usr/src/linux
.rej . patch ( ,
compile filesystem),
# . find
.
find . -name '*.rej' -print

.rej
dir subdirs .
, make clean, config, dep,
3 4.
patch. ,
patch -s , .
source dir
/usr/src/linux, patch -p1 (' dir) patch
. patch
man.

5.2.
( : .)
, patch
config.in, ,
/.
,
. , config.in.rej,
patch. + .
, y n. ,

config.in, y n n y,
.
patch -p0 < config.in.rej

(. ),
compilation.
config.in.rej , .
,
patch . patch previously
applied patch detected: Assume -R? ( patch,
;) patch
. y,
source , ' . ,
source ( , ,
).

patch, patch -R
patch.
, patches
, '
source ( linux-x.y.z.tar.gz),
.

5.3. .orig
patches, ' .orig
. , 1.1.51 ,
1.1.48 . .orig ,
MB.
find . -name '*.orig' -exec rm -f {} ';'

. patch #
.rej, tilde () .orig .
.orig,
GNU xargs. :
find . -name '*.orig' | xargs rm

" , " :

find . -name '*.orig' -print0 | xargs --null rm --

5.4. patches
patches ( " "), '
Linus. , patches
Linus ,
- source patch -
source ,
. ,
, ' source (
), patches
Linus, . ,
patches . ,
' , patch
source ,
( )
patch.
patches ;
.
noblink patch virtual ,
. ( patch -
- .) ,
drivers
modules , " "
patches .

6.
Linux ,
source .
,
.

6.1. kbd
Linux '
.
fonts, ,
( ), . kbd
,
fonts ,
sites, source
.

6.2. util-linux

Rik Faith (faith@cs.unc.edu) '


utilities Linux, - - utillinux. utilities Andries Brouwer
(util-linux@math.uio.no). ftp
sunsite.unc.edu dir /pub/Linux/system/misc,
setterm, rdev, ctrlaltdel,
. Rik,
.
. ( ,
.)

6.3. hdparm
,
. patches
, (
) .

6.4. gpm
gpm general purpose mouse ( ).
cut paste text
virtual , ,
.

7.

7.1. make clean



, make clean compile
. ,
/ I/O,
. , make dep.

7.2.
, , /
compile Quadbazillium-III/4400,
(drivers ,
filesystems, ). , ,
/.

(swapping) - .
, Fujitsu Eagles,
,
.

,
/ , "total mem"
( ) /proc/meminfo,
free.

7.3. ,
PCs : , "General
Setup" ( ), "Parallel port support"
( ) "PC-style hardware" (hardware
PC). , "Character devices" ( )
"Parallel printer support" ( ).
, . Linux 2.2
' , .
lp1 , lp0
. ,
dmesg, (logs) dir /var/log.

7.4. compile
compile, patch,
source . ,
gcc (
include). (symbolic links)
Linus README, . ,
compile ,
Linux,
.
, gcc
hardware. "xxx exited with signal 15"
( = xxx 15),
.
, -
cache, compiler .
, gcc.
compile
off cache, RAM, .
, hardware
, ' .
(FAQs),
http://www.bitwizard.nl/sig11/.

7.5. boot
LILO,
"" ,
boot = /dev/hda1, boot = /dev/hda.
,

.
,
(
,

.)

7.6. LILO, / boot


! boot
CDROM, (
make zdisk).
root filesystem (/), (. second
extended, minix). ,
filesystem source
(/usr/src/linux), , mount .
, / /dev/hda1, filesystem
/usr/src/linux /dev/hda3,
mount /usr. filesystems second
extended. image
/usr/src/linux/arch/i386/boot bzImage.
, bzImage,
. ,
, (
/ ), .
, boot boot/root (
- rescue disk), mount filesystem image
:

mkdir /mnt
mount -t ext2 /dev/hda3 /mnt

mkdir dir , .
, cd dir image .

/mnt + /usr/src/linux/arch/i386/boot - /usr = /mnt/src/linux/arch/i386/boot

drive "A:" ( boot


root!), image , root
filesystem :

cd /mnt/src/linux/arch/i386/boot
dd if=bzImage of=/dev/fd0
rdev /dev/fd0 /dev/hda1

, cd / unmount filesystem
/usr :

cd /
umount /mnt

, /
' . lilo (
, ) !
, .
/ (
/vmlinuz), .
, image
/vmlinuz, :
/dev/hda3 /dev/hda1 ( filesystem /), /mnt/src/linux
/mnt, if=bzImage if=vmlinuz. (
/mnt/src/linux.)
LILO ( 1024 )
. LILO mini-HOWTO,
.

7.7. "warning: bdflush not running"


(. " : bdflush".)
.
1.0 ( 20 1994),
update (
filesystem). source bdflush (
, source ),
. ( ,
.)
update,
.

7.8. IDE/ATAPI CD-ROM


,
ATAPI ,
.

CD-ROM ' IDE,


( jumpers - - )
"master" "single". -
.

, Creative Labs IDE


. ,
, IDE,
motherboard (
IRQ15), SoundBlaster IDE
( IRQ11).
Linux, 1.2.x
IDE. (
1.3.x ,
, .) (... :
Linux HowTo,
3
IDE.) , :
IDE, ,
- cdrom . ATAPI
, IDE. ,
IDE (
IRQ).
IDE, jumpers IDE
( !)
IRQ15, IDE.
.

7.9. routing
route,
routing.
/usr/include/linux/route.h (
/usr/src/linux).

7.10. firewalling 1.2.0


1.2.1 .

7.11. "Not a compressed kernel Image file"


(. " image ".)
boot vmlinux
/usr/src/linux. [..]/arch/i386/boot/bzImage.

7.12. (console terminal)


1.3.x
console termcap /etc/termcap,
dumb linux.
terminfo.

7.13. compile,
source Linux
include ( .h) dir /usr/include,
.
( xyzzy.h include
/usr/include/linux) :
#include <linux/xyzzy.h>

, /usr/include link linux directory


include/linux source (
/usr/src/linux/include/linux). link ,
,
compile. source
, , ' .
, .
dir root umask,
, source
p (preserve filemodes -
),
compiler C.
chmod
, include.
source
, :

blah# tar zxvpf linux.x.y.z.tar.gz linux/include

: "make config" link


/usr/src/linux, .

7.14.
, , '
,
:
echo 4096 > /proc/sys/kernel/file-max
echo 12288 > /proc/sys/kernel/inode-max
echo 300 400 500 > /proc/sys/vm/freepages

8. 2.0.x, 2.2.x
2.0.x 2.2.x
. Documentation/Changes

dirs source 2.0.x


,
.
, gcc, libc, SysVInit, '
, . ,
.
9. Modules
modules (loadable),
.
modules , filesystems, drivers
, drivers , drivers ,
.

9.1. utilities modules


utilities modules ( modutilsx.y.z.tar.gz) , source .
x.y.z patch,
( ) .
tar zxvf modutils-x.y.z.tar.gz, cd directory
(modutils-x.y.z), README,
( ,
make install). ,
insmod, rmmod, ksyms, lsmod, genksyms, modprobe, depmod dir
/sbin. , utilities driver
"hw", insmod . ,
INSTALL subdir.
insmod module . modules
.o . driver ,
drv_hello.o. , ,
insmod drv_hello.o. modules
, lsmod. :
blah# lsmod
Module:
drv_hello

#pages: Used by:


1

drv_hello module, 4k
, modules '
. , rmmod drv_hello.
rmmod module , .
module lsmod.
utilities modules man.

9.2. Modules
2.0.30,
loadable modules. ,
. , y ' ,
make config. compile ,

' . , cd /usr/src/linux,
make modules. compile modules
, links
/usr/src/linux/modules.
dir , make modules_install,
dir /lib/modules/x.y.z ( x.y.z ).
filesystems. ,
filesystems minix msdos, ,
msdos (!!!), insmod
/usr/src/linux/modules/msdos.o, rmmod msdos.
50k RAM
. filesystem
minix : ,
"".

10.
10.1. make patch
make patch,
. ,
(shell) : grep root /etc/passwd,
/bin/csh.
sh bash, :
(command) 2>&1 | tee (output file)

(command) ( = )
(output file) ( = ).
csh tcsh, :
(command) |& tee (output file)

rc ( : ) :
(command) >[2=1] | tee (output file)

10.2.

,
. ,
Unix, LILO
boot ' . (
500 MBytes, LILO
.) ,

image = /usr/src/linux/arch/i386/boot/bzImage
label = new_kernel

LILO,
, ' /vmlinuz (,
lilo). LILO
boot , shift
( LILO , ),
(prompt).
new_kernel (. ), boot
.
/
source (, :
),
/usr/src/linux-x.y.z, x.y.z . ,
"" source '
(symbolic link). , ln -sf linux-1.2.2 /usr/src/linux,
1.2.2 . symbolic link,
ln
directory ( symbolic links ),
.

10.3.
Russell Nelson (nelson@crynwr.com)
. ,
. ftp
ftp.emlist.com ( dir pub/kchanges), site
http://www.crynwr.com/kchanges

11. HOWTOs
Sound-HOWTO : utilities
SCSI-HOWTO : SCSI controllers
NET-2-HOWTO :

PPP-HOWTO : PPP
PCMCIA-HOWTO : drivers
ELF-HOWTO : ELF,
Hardware-HOWTO : hardware
Module mini-HOWTO : modules
Kerneld mini-HOWTO : daemon kerneld
BogoMips mini-HOWTO : ... ( /)
12.
12.1.
Linux Kernel-HOWTO Brian Ward
(bri@cs.uchicago.edu). , , ,
( ).
,
URLs :
http://www.math.psu.edu/bri/
http://blah.math.tu-graz.ac.at/~bri/

mails ,
' , '
. ,
. harware
( ), hardware
. ,
" , ".
. , ,
gcc, libc .
, . ,
, , !
e-mail.
,
, .

(. ),
e-mail . . , .
e-mails ,
hardware. ok,
hardware .

AMD , Adaptec Sybios SCSI controllers,


IBM SCSI.
-0.1 HowTo 3 1994.
SGML, PostScript, TeX, roff,
text.

12.2.
" " .
.
" ".
debugging crash recovery ( =
/ ).

12.3.
README Linus ( ).
, Linus!
uc@brian.lunetix.de (Ulrich Callmeier) : patch -s
xargs.
quinlan@yggdrasil.com (Daniel Quinlan) :
.
nat@nat@nataa.fr.eu.org (Nat Makarevitch) : mrproper, tar -p,
.
boldt@math.ucsb.edu (Axel Boldt) :
Internet , .
lembark@wrkhors.psyber.com (Steve Lembark) :
boot.
kbriggs@earwax.pd.uwa.edu.au (Keith Briggs) :
.
rmcguire@freenet.columbus.oh.us (Ryan McGuire) :
makeables.
dumas@excalibur.ibp.fr (Eric Dumas) : .

simazaki@ab11.yamanashi.ac.jp (Yasutada Shimazaki) :


.
jjamor@lml.ls.fi.upm.es (Juan Jose Amor Iglesias) :
.
mva@sbbs.se (Martin Wahlen) : .
jzp1218@stud.u-szeged.hu (Zoltan Vamosi) : .
bart@mat.uni.torun.pl (Bartosz Maruszewski): .
donahue@tiber.nist.gov (Michael J Donahue) : ,
" ".
rms@gnu.ai.mit.edu (Richard Stallman) : ""
.
dak@Pool.Informatik.RWTH-Aachen.DE (David Kastrup) : NFS.
esr@snark.thyrsus.com (Eric Raymond) : .
, mails
.
12.4. Copyright, ,
Copyright (C) Brian Ward, 1994-1999.

, copyright
.

,

.
" ".
: .
: .
,
, .
( ,

.) ,
. .
.

Вам также может понравиться