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

Gentoo Linux

Gentoo-doc TEAM
2.0-M2

Gentoo Linux
c
2.0-M2
Gentoo-doc TEAM
Copyright 2007-2010


... ..................................................................................................................................... 1
a.k.a changelog ..................................................................................................... 2
......................................................................................................................................... 6
1. ........................................................................................................................... 6
2. ..................................................................................................................................... 6
3. ........................................................................................................................ 7
4. ................................................................................................................ 7
5. Gentoo Linux ................................................................................... 8
............................................................................................................................ 9
1. Linux ........................................................................................................... 11
.................................................................................................................... 13
1. UNIX .............................................................................................................................. 13
1.1. .............................................................................................................. 13
1.2. ................................................................................................................ 14
1.3. ............................................................................................................ 18
1.4. UNIX .............................................................................. 19
2. LINUX ............................................................................................................................ 20
2.1. .............................................................................................................. 20
2.2. .............................................................................................................. 20
2.3. ............................................................................................................ 21
2.4. ...................................................................................................... 22
Windows- ................................................................................................................. 25
1. ............................................................................ 26
2. ................................................................................................................... 26
3. .................................................................................................................. 27
4. / ................................................................................................................... 28
4.1. Chat ...................................................................................................................... 28
4.2. File managers ........................................................................................................ 29
4.3. FTP ...................................................................................................................... 29
4.4. Graphics ................................................................................................................ 29
4.5. Internet ................................................................................................................. 29
4.6. Mail ...................................................................................................................... 30
4.7. Multimedia ............................................................................................................ 30
4.8. Office .................................................................................................................... 30
4.9. P2P ....................................................................................................................... 31
2. Gentoo: ........................................................................................... 32
Gentoo Linux ........................................................................................................................... 36
1. ? ........................................................................................................ 36
2. Gentoo Linux ................................................................................................................... 37
3. Gentoo .............................................................................................................. 37
4. Gentoo .......................................................................................................... 38
Gentoo Linux: ......................................................................................... 41
1. Gentoo Linux ............................................................................................................... 41
2. ................................................................................................ 42
3. ................................................................................... 43
4. .............................................................................................. 46
5. ...................................................................... 48
6. Gentoo ........................................................................................ 49

iii


7. : ......................................................................................... 51
8. : ........................................................... 54
9. ................................................................................................. 55
10. ................................................................................................ 59
Gentoo Linux x86 ................................................................. 60
1. ......................................................................................................... 60
2. ............................................................................................................... 61
3. .......................................................................................................... 61
4. ............................................................................................................ 61
5. Gentoo ................................................................................ 61
6. ............................................................................................................... 62
7. ......................................................................................................... 62
8. .......................................................................................... 63
9. ..................................................................................................... 63
9.1. Grub ..................................................................................................................... 64
9.2. Lilo ....................................................................................................................... 64
10. .................................................................................................... 65
Gentoo Linux .................................................... 66
1. ......................................................................................................... 66
2. Smart BootManager ................................... 66
3. Knoppix ..................................................................................... 67
4. Stage 1 ......................................................................... 68
5. PXE ................................................................ 69
6. Gentoo Linux- ....................................................... 73
Gentoo/x86 ................................................................................ 76
1. 1. ................................................................................................................. 76
2. 2. .............................................................................................. 76
3. 3. ................................................................................................. 79
4. 4. / ........................................................................................... 80
4.1. ..................................................................... 80
Gentoo ................................................................................................. 82
1. ....................................................................................................................... 82
2. ................................................................................................. 82
3. .......................................................................... 83
3.1. .................................................................................................. 83
3.2. ................................................................................ 83
3.3. ................................................................................................ 84
3.4. Gentoo .............................................................................................. 85
3.5. ........................................................................................................ 86
3.6. ............................................................................. 86
3.7. ......................................................................................... 87
3.8. UNICODE ................................................................................... 87
3.9. Gentoo .................................................................................................. 88
4. ....................................................................................... 88
4.1. ......................................................................................... 88
4.2. ........................................................................................ 89
......................................................................................................... 91
...................................................................................... 101
1. ................................................................................................................... 101
2. ............................................................................................................ 101
2.1. ? ................................................................................... 101
2.2. ? ......................................................................................... 102

iv


2.3. Gentoo Way ........................................................................................................ 102
2.4. root ? ........................................................................ 103
3. ........................................................................................................... 103
3.1. ............................................................................................. 103
3.2. ? ........................................... 105
3.3. ? ..................................................................................................................... 105
4. X Window ................................................................................. 106
4.1. ? ................................................................................. 106
4.2. ? ..................................................... 106
Gentoo Linux x86 ......................................................................................... 107
1. Gentoo ......................................................................................................... 110
1.1. Gentoo Linux ................................................................................ 110
1.2. ................................................... 112
1.3. ................................................................................................... 119
1.4. ............................................................................................. 126
1.5. Gentoo ............................................................ 134
1.6. Gentoo .................................................................... 140
1.7. .................................................................................................. 145
1.8. ......................................................................... 151
1.9. ............................................................... 156
1.10. ..................................................................... 159
1.11. Gentoo .......................................................................... 166
1.12. ? ...................................................................................... 167
2. Gentoo ............................................................................................................ 168
2.1. Portage ............................................................................................. 168
2.2. USE- .......................................................................................................... 176
2.3. Portage ......................................................................................... 181
2.4. ................................................................................... 184
2.5. ............................................................................................. 193
3. Portage ............................................................................................................ 197
3.1. .............................................................................................. 197
3.2. .................................................................... 200
3.3. .................................................... 203
3.4. Portage ...................................................................... 205
3.5. ................................................................ 207
3.6. ebuild ......................................................................................... 209
4. Gentoo .............................................................................................. 212
4.1. .......................................................................................... 212
4.2. ..................................................................................... 214
4.3. ............................................................................... 216
4.4. .............................................................................................. 222
4.5. ........................................................................... 229
4.6. .............................................................................................. 231
Gentoo ................................................................................................. 233
1. X.org ................................................................................................................. 234
Portage ......................................................................................................................... 235
1. Portage .................................................................................. 235
2. ? ............................................................................. 236
3. ? ..................................................................................... 236
4. ................................................................................................. 237
5. ........................................................................................ 237


3. Gentoo .................................................................................................................. 238
Gentoo Linux ......................................................................................................... 243
1. Gentoo ............................................................................. 243
1.1. Gentoo .......................................................................................... 243
1.2. .............................................................................. 244
1.3. ............................................................... 245
HOWTO ...................................................................................... 247
1. /var/lib/portage/world ................................................................ 247
2. profile ....................................................................................................... 248
3. USE- .................................................................................................................. 248
4. ( toolchain) ................................ 248
5. emerge -U -u ........................................... 248
6. toolchain ................................................... 249
7. . ........................................................................................... 250
8. . ............................................................................ 250
9. . ................................................................................................ 251
Gentoo Linux GCC ....................................................................... 252
1. ....................................................................................................................... 252
1.1. GCC ............................................................................................... 252
2. ................................................................................... 253
2.1. ............................................................................................................ 253
3. GCC-3.3 3.4 .................................................................. 254
3.1. ............................................................................................................ 254
3.2. ............................................................................................................ 254
3.3. revdep-rebuild ............................................................................. 255
3.4. emerge -e ................................................................................... 255
4. GCC ........................................................................... 256
4.1. ............................................................................................................ 256
4.2. revdep-rebuild ............................................................................. 257
4.3. emerge -e ................................................................................... 257
4.4. .............................................................................................................. 258
5. ........................................................................................................... 258
5.1. ........................................................ 258
Gentoo ( 2) ................................................................................ 260
1. Gentoo ..................................................... 260
1.1. Portage .................................................................................................. 261
1.2. Portage .............................................................................................. 261
1.3. .................................................................... 262
1.4. ? ........................................................................... 262
1.5. .................................................................................. 263
1.6. . ......................................................................................... 263
1.7. Portage ....................................................................................................... 264
1.8. .............................................................................. 264
1.9. ...................................................................................... 264
1.10. ................................................................ 265
1.11. ..................................................................................... 265
1.12. ........................................................... 265
........................................................................... 267
1. : ........................................................................................ 268
2. . .................................................................................................. 269
3. USE- .................................................................................................................... 269
4. =) .............................................................. 271

vi


4.1. : ........................................................................ 271
5. "Masked" . .......................................................................................................... 272
6. . ', DE. ....................................................................................... 273
Gentoo .......................................................................................................................... 274
1. 2.6: ...................................................................................... 274
1.1. ......................................................................... 275
2. Gentoo Linux .................................... 275
2.1. ............................................................................................................ 276
2.2. ................................................... 277
2.3. ............................................................................. 278
2.4. ....................................................... 279
2.5. ........................................................................................................ 281
3. .......................................................... 281
3.1. ............................................................................................................ 281
4. mplayer ........................................................................................................................ 281
5. XMMS ........................................................................................................................... 282
6. Mozilla ......................................................... 282
6.1. Navigator(Seamonkey/Firefox) ............................................................................. 282
6.2. Firefox Seamonkey ......................................................... 283
6.3. ......................................................................... 283
6.4. Firefox Seamonkey. .......................................................... 284
6.5. Thumbnail' ............................................... 284
7. IDE hdparm ......................................................... 284
7.1. ............................................................................................................ 284
7.2. IDE ........................................................................ 285
7.3. ........................................................................................................... 286
7.4. ...................................................................................................... 287
8. ......................................................................................... 287
8.1. ............................................................................................................ 288
8.2. ......................................................................................... 288
8.3. ................................................................................................... 288
8.4. ......................................... 289
8.5. ...................................................... 290
rpm- Gentoo ....................................................................................... 291
UTF-8 Gentoo ................................................................................................ 294
1. ............................................................. 294
2. ..................................................................................................................... 295
2.1. ? ......................................................................................... 295
2.2. ............................................................................. 295
2.3. ? ............................................................................................ 296
2.4. UTF-8 ................................................................................................................. 296
2.5. UTF-8 ...................................................................... 296
3. UTF-8 Gentoo Linux ................................................................................. 297
3.1. UTF-8 ................................................................... 297
3.2. ............................................................................................... 297
4. ............................................................................................ 298
4.1. , NTFS FAT ............................................................................... 299
4.2. ............................................................................................. 300
4.3. ncurses slang .................................................................................................... 300
4.4. KDE, GNOME Xfce ......................................................................................... 301
4.5. X11 ................................................................................................... 301
4.6. .................................................... 302

vii


4.7. Vim, Emacs, Xemacs Nano ............................................................................... 302
4.8. .......................................................................................... 302
4.9. Irssi ..................................................................................................................... 303
4.10. Mutt .................................................................................................................. 303
4.11. Man ................................................................................................................... 303
4.12. elinks links ..................................................................................................... 303
4.13. Samba ............................................................................................................... 304
4.14. ........................................................................... 304
4.15. .................................................................................................. 304
Gentoo Linux .................................................................. 306
1. ....................................................................................................................... 306
1.1. .......................................................................... 306
1.2. ............................................................................. 307
2. ..................................................................................... 307
2.1. ............................................................................................................ 307
2.2. ............................................................................. 307
2.3. ....................................................................... 308
2.4. (mapscreen) ......................................................... 309
2.5. ....................................................................... 309
3. locale ............................................................................................... 310
3.1. locale ru_RU.KOI8-R .......................................................................... 310
4. ............................................................................................. 312
4.1. ............................................................................ 312
4.2. .............................................................. 312
5. X .................................................................................. 312
5.1. ............................................................................................................ 312
5.2. xf86config ........................................... 313
5.3. ................................................................... 314
5.4. .......................................... 315
udev Gentoo .................................................................................................. 316
1. udev? ............................................................................................................ 316
1.1. /dev ...................................................................................................... 316
1.2. namedev .............................................................................................................. 317
1.3. libsysfs ................................................................................................................ 318
1.4. udev .................................................................................................................... 318
2. udev Gentoo ................................................................................... 318
2.1. ........................................................................................ 318
2.2. .................................................................................................... 319
3. .................................................................................................... 320
3.1. .................................. 320
3.2. udev nvidia ...................................................................................................... 320
3.3. LVM2 .............................................................................. 321
3.4. DevFS udev ........................................................... 321
3.5. ............................................................................................... 322
4. ............................................................................ 322
..................................................................... 323
1. devfs? ............................................................................................................ 323
1.1. (?) ................................................................................. 323
1.2. ........................................................................................................... 324
1.3. ............................................................................................................. 324
1.4. devfs ? .................................................................... 324
2. ............................................................................... 325

viii


2.1. ........................................................................................................ 325
2.2. o devfsd ..................................................... 326
3. .......................................................................... 326
3.1. devfsd ........................................................................................... 326
3.2. compatibility symlinks .......................................................................... 326
3.3. ..................................... 327
4. , ..................................................................... 327
4.1. / PAM ........................................ 327
4.2. / devfsd ...................................... 328
4.3. devfsd .................................................. 328
HOWTO fbsplash ....................................................................................................................... 330
1. ...................................................................................................................... 331
1.1. gensplash? ........................................................................................... 331
1.2. fbsplash (framebuffer splash)? .............................................................. 331
1.3. frame buffer? .................................................................... 331
2. fbsplash splashutils ..................................................................................... 331
2.1. ........................................................................................ 332
2.2. ............................................................................................ 332
2.3. () .............................................................................. 332
2.4. / ( genkernel) ....................... 333
2.5. splashutils ........................................................................................... 333
2.6. / ( ) ............................................. 333
3. initramfs ............................................................................................ 334
3.1. initramfs? ............................................................................................ 334
3.2. initramfs ........................................ 334
3.3. initramfs ............................................................... 335
3.4. gensplash ........................................................... 335
3.5. bootsplash gensplash ............................................................ 336
3.6. gensplash ......................................................... 336
4. .................................................................................................. 337
4.1. ................................................................................................. 337
4.2. Grub ............................................................................... 338
4.3. Lilo ................................................................................ 338
5. ................................................................................. 339
6. Gensplash ........................................................................... 339
6.1. ........................................................................................ 339
6.2. 3 .................................................................. 340
7. ......................................................................................................... 340
7.1. /usr .......................................................................... 340
7.2. ..................................................................... 340
8. .......................................................................................................................... 341
4. WIKI ................................................................................................................................ 342
HOWTO hal ............................................................................................... 349
1. hal-0.5.10 ...................................................................................................................... 349
2. portage ....................................................................................................... 349
3. xorg .......................................................................................... 349
4. ................................................................................................................... 350
5. X- ...................................................................................................... 351
6. .......................................................................................................................... 352
7. Touchpad ....................................................................................................................... 352
HOWTO Ivman .......................................................................................................................... 353
1. .............................................................................................................................. 353

ix


2. .................................................................................................. 353
3. .............................................................................................................. 354
3.1. Ivman root .......................................................................................... 354
3.2. Ivman ............................................................ 355
3.3. .............................................................................. 355
4. ..................................................................................................................... 356
4.1. fstab (ivman 0.6.x ) ............................ 356
4.2. fstab ( ivman 0.5.x!) ...................................... 356
4.3.
( ivman 0.5.x!) ............................................................................................. 356
4.4. ............................................................................................................................ 357
5. ........................................................................................................................... 357
6. .......................................................................................................... 358
.............................................................................................. 359
1. .......................................................................................................... 359
1.1. ......................................................................................................... 361
1.2. :) ...................................................................................................... 363
1.3. - ................................................................... 368
CD/DVD ..................................................................................................................... 370
1. .................................................................................................. 370
2. .................................................................................. 370
2.1. 2.4.x ................................................................................................. 370
2.2. 2.6.x ............................................................................................... 371
3. ISO ................................................................................................. 371
3.1. ISO ............................................. 372
4. ATAPI- ..................................................................................... 372
5. ISO ....................................................................................................... 373
5.1. .......................................................................... 373
6. .................................................................................................... 373
7. ................................................................................................. 374
8. ......................................................................................................... 374
DVD .......................................................................................................................... 375
1. ....................................................................................................................... 375
1.1. ................................................................................................ 375
1.2. ................................................................................... 375
2. DVD ............................................................................. 376
2.1. transcode MPEG2, DVD ............................................. 376
2.2. tcmplex ......................... 379
2.3. kino ( transcode+tcmplex) ........................................ 379
2.4. replex ( DVB
(Digital Television)) .................................................................................................... 380
3. (authoring) dvdauthor ..................... 380
4. DVD ................................................................................. 381
5. ........................................................................................................................... 381
5.1. ............................................................... 381
5.2. ......................................................................................... 381
Portage ........................................................................................................................ 383
1. Portage NFS ......................................................................................................... 383
1.1. ......................................................................................................... 383
1.2. ............................................................................................................ 383


1.3. ....................................................................................... 383
1.4. ............................................................................................................. 384
1.5. .......................................................................................... 384
1.6. ................................................................................................. 386
1.7. ..................................................................................................... 386
Portage ..................................................................................................................... 388
1. Portage Setup Howto ..................................................................................................... 388
1.1. ............................................................................................ 388
1.2. howto? .................................................................................... 388
1.3. Portage (Portage profiles) .................................................................... 388
1.4. ......................................................................................... 389
Portage Overlay .......................................................................................................................... 392
1. ....................................................................................................................... 392
2. Portage Overlay ............................................................................................. 392
3. ebuild ............................................................................................ 392
4. digest- ................................................................................................. 393
4.1. ebuild ..................................................................................... 394
4.2. ................................................................................................... 394
deltup ....................................................................................... 395
1. ? ............................................................................................................... 395
2. .................................................................................................. 395
2.1. emerge ............................................................................................... 396
2.2. getdelta ........................................................................................ 396
2.3. ................................................................................................... 396
............................ 397
............................... 399
.................................................................................................... 401
1. ...................................................................................................................................... 401
1.1. /var/lib/portage/world ...................................................... 401
2. ...................................................................................................................................... 402
2.1. USE- ........................................................................................................ 402
3. ...................................................................................................................................... 404
3.1. . ................................................................................ 404
4. ...................................................................................................................................... 404
4.1. . ................................................................... 404
5. ...................................................................................................................................... 405
5.1. . ...................................................................................... 405
6. ...................................................................................................................................... 405
6.1. . ............................... 405
.................................................................................................. 406
...................................................................................................................................... 408
1. MS Windows - ................................................................................... 409
1.1. ............................................................................................................ 409
1.2. .................................................................................................................. 409
1.3. ................................................................................................... 409
1.4. ............................................................................................. 411
2. Udev .............................................................................................................................. 411
2.1. ........................................................................................... 411
2.2. ........................................................................................... 411
2.3. . ...................................................................... 412
2.4. Troubleshuting .................................................................................................... 412
3. CFLAGS .................................. 413

xi


3.1. ? ....................................................................................... 413
3.2. ...................................................................................................... 413
4. nano ............................................................................................................... 416
4.1. ........................................................................................................... 417
4.2. ................................................................................................................ 417
5. Udev ............................................................................ 417
5.1. ........................................................................................................... 417
5.2. ........................................................................................................ 417
5.3. udev ............................................................................................. 417
5.4. .................................................................................................. 419
5.5. ....................................................................................................... 420
6. glibc ....................................................................................................... 420
6.1. ........................................................................................................... 420
6.2. Glibc ........................................................................ 421
6.3. ...................................................................................................... 421
6.4. ..................................................................................................... 424
7. USB-flash ................................................................................................ 424
7.1. USB-flash ............................................................... 424
7.2. kde ....................................................................................... 426
7.3. .......................................................................... 427
8. - NTFS ntfs-3g .............................................. 427
8.1. ............................................................................................................ 427
8.2. ........................................................................................................... 428
8.3. .................................................................................... 428
8.4. .............................................................................................. 429
....................................................................................................................... 430
1. Apache2 ........................................................................................................ 432
1.1. .......................................................................................................... 432
1.2. Apache ................................................................................................... 432
1.3. ............................................................................................................. 432
1.4. ................................................................................................... 433
1.5. Common Problems ............................................................................................. 434
1.6. See Also ............................................................................................................ 436
2. iptables ............................................................................. 436
2.1. ........................................................................................................... 436
2.2. Linux ........................................................................... 436
2.3. iptables ............................................................................................. 437
2.4. ................................................................................................... 437
2.5. iptables ................................................................................................... 437
2.6. /etc/init.d/iptables ....................................................................... 437
2.7. ............................................................................................... 437
2.8. ........................................................................................... 438
2.9. ..................................................................................... 439
2.10. ................................................................................................ 439
2.11. ............................................................................................................ 440
3. iptables ....................................................................................... 441
3.1. ............................................................................................................ 441
3.2. ............................................................................................ 441
3.3. ....................................................................................... 442
3.4. ............................................................................... 442
3.5. ............................................................................................. 443
3.6. Scripting .............................................................................................................. 444

xii


3.7. ........................................................................
3.8. Firewall ................................................................................................
3.9. .....................................................................
3.10. iptables ACCEPTS .............................................................................................
3.11. iptables DROP & REJECT .................................................................................
3.12. ...................................................................................................
3.13. ....................................................................................
3.14. .........................................................
3.15. .......................................
3.16. ........................................................................
3.17. Ports ..................................................................................................................
3.18. Sysctl' .............................................................................................................
3.19. NAT ..............................................................................
3.20. The full script ....................................................................................................
4. ........................................................................................
4.1. postfix ........................................................................................
5. vsftpd ...........................................................................................................
5.1. ...........................................................................................................
5.2. VSFTPD ...........................................................................................
5.3. ...............................................................
5.4. ..................................................................................................
5.5. ...................................................................
5.6. ........................................................................................
5.7. ............................................................................................................
6. Jabber Server .................................................................................................................
6.1. ............................................................................................................
6.2. ..............................................................................................
6.3. ....................................................................................................
6.4. ....................................................................................................
7. Counter-Strike ................................................................................
7.1. ............................................................
7.2. .......................................................................................
8. Samba Win2k .............................................................................
8.1. .......................................................................................................
8.2. .................................................................................................
9. Samba PDC LDAP ....................
9.1. ...................................................................................
9.2. OpenLDAP ..........................................................................................................
9.3. OpenLDAP .................................................................................
9.4. SAMBA ..............................................................................................................
9.5. LDAP .....................................................
9.6. ...............................................................................
10. ......................................................................................
10.1. ..........................................................................................................
10.2. "" .........................................................................................
10.3. ...............................................................
10.4. ..............................................................................................
10.5. .................................................................
10.6. ..............................................................................................
10.7. Linux iptables ....................................................................................................
10.8. FreeBSD ipfw ....................................................................................................
10.9. ..............................................................................................

xiii

445
445
446
447
448
449
449
450
450
451
452
454
455
457
465
466
473
473
473
474
474
474
475
475
476
476
476
476
477
477
477
477
478
478
478
482
482
482
484
484
492
494
498
498
499
499
500
503
504
504
505
507


10.10. "" ......................................................................... 508
10.11. ............................................................ 511
10.12. rrdtool ........................................................................................ 511
10.13. Net-Telnet .................................................................................. 512
10.14. Apache ....................................................................................... 512
10.15. ............................................................ 513
10.16. .............................................................. 514
10.17. ............................................................................ 516
10.18. ........................................................................... 519
10.19. ................................................................................................. 519
X ............................................................................................................................. 521
1. X .................................................................................. 522
1.1. ........................................................................................................... 522
1.2. ...................................................................... 522
1.3. ft ..................................................................................................................... 522
1.4. ............................................................ 523
1.5. ......................................................................... 524
1.6. Qt Gtk ........................................................................................... 525
2. X .................................................................................. 525
2.1. ........................................................................................................... 525
2.2. .................................................................................................. 526
2.3. ................................................................................. 526
2.4. .................................................................................... 526
3. Xorg X11 .............................................................................................. 527
3.1. ............................................................................................................ 527
3.2. X.org .................................................................................................. 528
3.3. X Composite Extension ....................................................................... 528
3.4. KDE 3.4 ................................................................................ 528
3.5. ........................................................................................................ 530
4. Xorg. ..................................................................................... 530
5. Xgl ............................................................................................................... 531
5.1. ............................................................................................................ 531
5.2. ........................................................................................................ 531
5.3. nvidia .................................................................. 532
6. XGL .............................................................................................................................. 533
6.1. ........................................................................................................... 533
6.2. ....................................................................................... 533
6.3. ........................................................... 533
6.4. ................................................................................ 534
6.5. Portage .................................................................................... 534
6.6. : ........................................... 535
6.7. ............................................................. 535
6.8. Xgl .................................................................................................... 537
6.9. Xgl ................................................................................................ 538
6.10. Xgl ....................................................................................................... 539
7. ..................................................................... 554
8. Cedega 5.1 ..................................................................................................................... 555
8.1. ............................................................................................................ 555
8.2. ........................................................................................................... 555
....................................................................................................... 557
1. ...................................................................................................................................... 557
1.1. ................................................................................................. 557

xiv


2. ...................................................................................................................................... 559
2.1. - ......................................................................................................... 559
3. ...................................................................................................................................... 560
3.1. ...................................................................................... 560
4. ...................................................................................................................................... 560
4.1. CD ....................................................................................................... 560
5. ...................................................................................................................................... 561
5.1. .............................................................................................. 561
6. ...................................................................................................................................... 562
6.1. ............................................................................................... 562
7. ...................................................................................................................................... 563
7.1. .............................................................................. 563
8. ...................................................................................................................................... 563
8.1. ........................................................................................... 563
9. ...................................................................................................................................... 564
9.1. ................................................................................................... 564
10. .................................................................................................................................... 565
10.1. ....................................................................................................... 565
ccache emerge .............................................................................................. 566
Keymap ..................................................................................................................................... 567
5. Gentoo .......................................................................................................................... 568
Gentoo X.Org ........................................................................................................................ 571
1. X- 6.X ...................................... 572
1.1. X Window Server? .............................................................................. 572
1.2. Xorg .................................................................................................. 573
1.3. Xorg .................................................................................................. 574
1.4. xorg.conf .......................................................................................... 576
1.5. .............................................................................................................. 578
2. X- 7.X (.) ............................. 578
2.1. Introduction ......................................................................................................... 579
2.2. Preparation ......................................................................................................... 579
2.3. Emerge Modular X.org ....................................................................................... 581
2.4. Installation ......................................................................................................... 581
2.5. GL Issues ............................................................................................................ 582
2.6. Configuration file locations have changed ............................................................ 583
2.7. Other problems and solutions .............................................................................. 584
3. XkbOptions .................................................................................................................... 584
3.1. "XkbOptions" .................................................................................. 584
3.2. .............................................................................................................. 585
4. HOWTO Xorg and Fonts (.) ...................................................................................... 586
4.1. HOWTO ................................................................................ 586
4.2. ................................................................................................ 586
4.3. DPI ................................................................................... 586
4.4. Windows/Mac Linux ................... 587
4.5. ....................................................................... 587
4.6. (Hinting) ...................................................................... 588
4.7. .............................................................. 588
4.8. /etc/X11/xorg.conf ............................................................................................ 591
4.9. : /etc/X11/xorg.conf ( ) ...................................... 594
4.10. .......................................................................................... 594
4.11. Mozilla Firefox and Thunderbird ........................................................................ 595
4.12. ...................................................................... 597

xv


4.13. , Linux Konsole . ...................................... 598
4.14. , ............................ 598
4.15. startx ................................................................................ 598
4.16. XEmacs ............................................................................................................. 598
4.17. ............................................................................................ 599
4.18. ................................................................................................ 599
4.19. ( JohnBat26), : ~/.fonts.conf: .................................... 599
5. nVidia Gentoo Linux ...................................................... 600
5.1. ............................................................................................................ 601
5.2. ................................................................................................ 601
5.3. ........................................................................................................... 605
5.4. ..................................................................................... 606
6. ATI Gentoo Linux ....................................................... 607
6.1. ......................................................................................... 607
6.2. ........................................................................................................... 608
6.3. ............................................................................... 609
Gentoo KDE .......................................................................................................................... 611
1. HOWTO KDE 3.x.x ...................................................................... 611
1.1. K Desktop Environment? ................................................................ 611
1.2. KDE .................................................................................................. 612
1.3. ............................................................................................. 613
1.4. KDE .................................................................................................. 614
2. KDE (31) ......................................... 615
3. Gentoo KDE 4.0 Guide (.) ......................................................................................... 618
3.1. ........................................................................................................... 619
3.2. KDE 3.5 .................................................................. 622
3.3. FAQ ( ) ...................................................................... 622
GNOME .......................................................................................... 625
1. GNOME? ...................................................................................................... 625
1.1. ........................................................................................................... 625
1.2. ............................................................................... 625
1.3. ........................................................................................................ 626
2. GNOME ....................................................................................................... 626
2.1. ? ........................................................................................ 626
2.2. ........................................................................................... 626
3. GNOME ....................................................................................................... 627
3.1. GNOME .............................................. 627
6. Hardware ....................................................................................................................................... 628
Hardware 3D Acceleration Guide (.) .................................................................................... 631
1. Introduction .................................................................................................................... 632
1.1. What is hardware 3D acceleration and why do I want it? ........................................ 632
1.2. How do I get hardware 3D acceleration? ............................................................... 632
1.3. What is DRI? ...................................................................................................... 632
1.4. What is X11-DRM and how does it relate to regular Xorg? ..................................... 632
1.5. Purpose ............................................................................................................... 632
1.6. Feedback ............................................................................................................. 633
2. Install Xorg and configure your kernel ............................................................................. 633
2.1. Install Xorg ......................................................................................................... 633
2.2. Configure your kernel .......................................................................................... 633
3. Install X11-DRM and configure direct rendering .............................................................. 634
3.1. Install X11-DRM ................................................................................................. 634
3.2. Configure Xorg.conf ............................................................................................ 635

xvi


3.3. Changes to modules.autoload.d ............................................................................. 636
4. Test 3D acceleration ....................................................................................................... 636
4.1. Reboot to the new kernel ..................................................................................... 636
5. Using the CVS sources ................................................................................................... 637
6. Tweak your performance ................................................................................................. 638
6.1. Get the most out of direct rendering ...................................................................... 638
7. Troubleshooting .............................................................................................................. 640
7.1. It doesn't work. I just recompiled my kernel or switched to a new one. ..................... 640
7.2. It doesn't work. I don't have rendering, and I can't tell why. .................................... 640
7.3. When I startx, I get this error: "[drm] failed to load kernel module agpgart" .............. 640
7.4. Direct rendering doesn't work, and in /var/log/Xorg.0.log I have an error about driver
version too low. .......................................................................................................... 640
7.5. I have a Radeon, and I want TV-Out. ................................................................... 640
7.6. It doesn't work. My card is so incredibly new and cool that it isn't supported at all.
................................................................................................................................... 641
7.7. I have a PCI card and it doesn't work. Help! ......................................................... 641
8. Acknowledgments .......................................................................................................... 641
9. 9. References ................................................................................................................. 641
Gentoo Linux ALSA .............................................................................................. 642
1. ....................................................................................................................... 643
1.1. ALSA? ............................................................................................... 643
1.2. ALSA Gentoo ................................................................................................... 643
2. ALSA ........................................................................................................... 643
2.1. ............................................................................................................ 643
2.2. ... ................................................................................................................. 644
2.3. ............................................................................ 644
2.4. ALSA , ................................. 645
2.5. ALSA ............................................................. 646
3. / ALSA ..................................................................................... 648
3.1. ALSA .................................................................................................. 648
3.2. ........................................................................................................... 648
3.3. ALSA ........................................................................ 649
3.4. audio ....................................................................................................... 649
3.5. ! .......................................................................................... 649
3.6. ! .................................................................................................. 651
3.7. ALSA USE ...................................................................................................... 652
3.8. ? ......................................................................................................... 652
4. ALSA .......................................................................................... 654
4.1. MIDI ............................................................................... 654
4.2. .................................................................................. 655
4.3. Firmware ........................................................................................... 656
4.4. .................................................................................... 656
4.5. ........................................................................................... 657
4.6. ... ............................................................................ 657
4.7. ............................................................................................................... 657
........................................................................................... 658
1. ....................................................................................................................... 659
1.1. .................................................................................................... 659
1.2. ........................................................... 659
2. .................................................................................................................... 660
2.1. BIOS ................................................................................................................... 660
2.2. USE- ....................................................................................... 660

xvii


2.3. ............................................................................................ 660
2.4. (runlevel) "battery" ...................................................... 662
2.5. ACPI- .......................................................................... 662
3. .......................................................................................... 664
3.1. .............................................................................................. 664
3.2. ............................................................................... 665
3.3. .................................................................... 666
3.4. ........................................................................................... 669
4. LCD Power Management ................................................................................................ 669
4.1. (standby) .......................................................................... 669
4.2. ...................................................................................... 670
5. ......................................................................................... 671
5.1. (idle time) laptop-mode .......................................... 672
5.2. ......................................................................... 673
5.3. hdparm ................................................................................................................ 673
5.4. " " ...................................................................................... 673
6. ....................................................................... 674
6.1. ............................................................................................. 674
6.2. .............................................. 674
6.3. USB ................................................................................ 675
7. : sleep, standby, suspend to disk .......................................................... 675
7.1. Sleep (S3) ........................................................................................................... 675
7.2. Hibernate (S4) ..................................................................................................... 676
8. .................................................................................................. 678
7. , , Internet, e-mail . .................................................................................... 682
HOWTO Internet ................................................................................................. 686
1. VPN ............................................................................................................. 686
1.1. ................................................................................ 686
1.2. ............................................................................................. 687
1.3. ............................................................................................. 687
1.4. pptpconfig ....................................................................... 688
1.5. ...................................................................................... 689
2. pppoe ................................................................................................................... 691
3. DIAL-UP ................................................................................ 692
3.1. ......................................................................................... 692
3.2. ............................................................... 693
3.3. Call back ........................................................................................... 695
4. GPRS ..................................................................................... 696
4.1. ........................................................................................ 696
4.2. USB- ............................................................... 696
4.3. COM- .............................................................. 697
4.4. Bluetooth ............................................................................. 697
4.5. IrDA ................................................................................... 699
5. CDMA (SKYLINK) ................................................................ 699
5.1. .................................................................................. 699
5.2. ............................................................... 699
Gentoo GPRS ......................................................................................................................... 701
1. GPRS Linux .............................................................................................. 701
1.1. ............................................................................................................ 701
1.2. ......................................................................................................... 701
1.3. .................................................................................................. 702
1.4. ........................................................................................................... 703

xviii


1.5. ........................................................................................ 705
1.6. .............................................................. 705
1.7. ........................................................................................................ 705
2. GPRS USB ........................................................................................................... 705
3. GPRS KPPP ......................................................................................................... 708
4. , Toonel. (Linux) ............................................................. 709
4.1. . ................................................................ 710
5. GPRS Bluetooth .................................................................................................. 710
Gentoo ........................................................................... 711
1. ....................................................................................................................... 711
1.1. ? ................................................................ 712
1.2. ..................................................................................................... 712
2. Gentoo ..................................... 712
2.1. .................................................................................................. 712
2.2. .................................................................................... 713
2.3. ......................................................................... 713
2.4. /etc/channels.conf ................................................................................................. 713
2.5. ............................................................................................. 715
2.6. .................................................................................................. 716
3. ........................................................................................ 716
4. ............................................................................. 719
OpenVPN .......................................... 720
Gentoo LDAP-DNS Guide (.) ............................................................................................ 725
1. Introduction .................................................................................................................... 725
2. Configuring LDAP-DNS ................................................................................................. 725
3. Configuring OpenLDAP ................................................................................................. 726
4. Testing the Installation .................................................................................................... 727
Samba PDC LDAP ............................... 728
1. ............................................................................................. 728
2. OpenLDAP .................................................................................................................... 729
2.1. OpenLDAP ........................................................................... 729
2.2. OpenLDAP ................................................................................ 731
3. SAMBA ......................................................................................................................... 731
3.1. OpenLDAP ......................................................................................... 731
3.2. SAMBA ...................................................................................... 734
4. LDAP ................................................................ 738
5. .......................................................................................... 741
5.1. ....................................................................................... 741
5.2. ............................................................................................. 743
5.3. ................................................................................ 743
5.4. ....................................................................................... 745
6. ..................................................................... 745
7. ..................................................................................................................... 745
................................................................................. 746
1. 1. ................................................................................................................... 746
2. 2. postfix ..................................................................................... 748
3. 3. Courier-imap .............................................................................................................. 749
4. 4. Cyrus-sasl .................................................................................................................. 750
5. 5. SSL- Postfix Apache ..................................................................... 751
6. 6. SSL SASL Postfix ................................................................ 752
7. 7. MySQL ...................................................................................................................... 754
8. 8. Apache phpMyAdmin .............................................................................................. 756

xix


9. 9. Vmail- ................................................................................................... 758
10. 10. MySQL ....................................... 758
11. 11. Squirrelmail ............................................................................................................ 764
12. 12. Mailman ................................................................................................................. 765
13. 13. Anti-Virus .................................................................. 768
14. 14. ............................................................................................................. 768
15. 15. Troubleshooting ...................................................................................................... 768
qmail/vpopmail. ........................................................ 772
1. 1. ................................................................................................................... 772
2. 2. qmail (" ") .................................................................................. 773
3. 3. vpopmail .................................................................................................................... 776
4. 4. Courier POP/IMAP ..................................................................................................... 777
5. 5. qmail ( ) .................................................................................... 779
6. 6. Horde / IMP ............................................................................................ 779
7. 7. ........................................................................................... 782
8. 8. .................................................................................... 785
Mutt ...................................................... 786
1. 1. E-Mail ..................................................................................................... 786
2. 2. Fetchmail ................................................................................................................... 787
3. 3. Procmail .................................................................................................................... 788
4. 4. Mutt .............................................................................................. 791
5. 5. SMTP ........................................................................................................................ 795
8. ................................................................................................................................. 797
Gentoo ............................................................................... 799
1. ....................................................................................................................... 799
2. A. .............................................................................................. 800
2.1. 1. .......................................................... 800
2.2. 2. .......................................................................................... 802
2.3. 3. ............................................................................................. 805
2.4. 4. ................................................................................. 812
2.5. 5. / ................................................................. 813
2.6. 6. ................................................................................. 817
2.7. 7. PAM ............................................................................................................... 820
2.8. 8. TCP ............................................................................................ 821
2.9. 9. .......................................................................................... 822
2.10. 10. .................................................................................... 826
2.11. 11. ............................... 837
2.12. 12. .................................................................................... 839
2.13. 13. ............................................................................. 858
2.14. 14. .............................................................................. 865
Hardened Gentoo ........................................................................................................................ 868
1. ...................................................................................................................... 868
2. ...................................................................................................................... 869
3. ..................................................................................................................... 871
4. .................................................................................................................. 873
4.1. .......................................................................................................... 874
4.2. ..................................................................................................... 874
4.3. ............................................................................................. 874
4.4. ........................................................................................... 874
5. ......................................................................................................................... 875
9. Linux ................................................................................................... 876
, ......................................................................................... 879

xx


1. 1. X ...................................................................................................... 879
2. 2. .................................................................... 879
Linux .......................................................................................................... 881
1. ........................................................................................... 881
1.1. ....................................................................................... 881
2. Unix- .............................................................. 883
2.1. Linux ................................................................................... 884
2.2. ..................................................................................... 888
2.3. ....................................................................................... 890
3. Linux : ............................................... 890
Linux ................................................................................................................ 894
1. ................................................................................................................. 895
2. .............................................................................................................. 896
3. ................................................................................... 898
4. ..................................................................................................... 899
5. System V shared memory ............................................................................................... 900
6. ......................................................................................................... 901
6.1. .......................................................................... 901
6.2. .................................................................................................... 904
6.3. ................................................................... 905
6.4. .......................................................................... 905
6.5. ....................................................................... 906
6.6. ............................................................................... 907
6.7. ................................................................................ 907
7. ....................................................... 908
8. GNU libc ................................................................................... 909
9. LD, Shared Library, SO ............................................................ 909
10. /proc .................................................. 911
11. sysctl ......................................................................................................... 912
12. .................................................................................................... 913
13. /dev .............................................................................................................. 913
13.1. /dev ........................................................... 915
13.2. DevFS ............................................................................................... 916
13.3. UDEV ............................................................................................. 917
14. .................................................................................................... 917
14.1. IDE ................................................ 919
14.2. SCSI- ........................................ 920
14.3. SATA IDE PATA ...................................................... 921
14.4. Logical Volume Manager .................................................................................... 922
14.5. Sotware RAID ................................................................................................... 925
14.6. Device mapper ................................................................................................... 927
14.7. Host-RAID, RAID- ................................. 928
15. ..................................................................................................... 928
16. IP ................................................................................ 930
17. ......................................................................................................... 932
17.1. ...................................................................... 933
17.2. ....................................... 933
17.3. ...................................................................................... 934
17.4. ................................................................................................. 935
17.5. iptables ....................................................................... 935
18. , NSS PAM .................................................................... 937
19. X11 -- ........................................................................................................ 939

xxi


19.1. - X11 .................................................................. 939
19.2. ...................................................................... 940
19.3. X11. ....................................................................... 941
19.4. X11. ......................................... 942
19.5. X11. FreeType XFT ........................................................................... 942
19.6. X11. ................................................................................. 943
19.7. X11. ....................................................................... 943
19.8. X11. ............................................................................ 943
19.9. X11. Composite, XGL Compiz ........................................................... 944
20. ................................................................................................................ 945
21. ............................................................................... 946
21.1. RPM ................................................................................... 947
21.2. ................................................................................. 948
21.3. rpm .................................................................. 948
10. Gentoo ........................................................................................................... 950
Gentoo Java ............................................................................................................................ 952
1. Java Gentoo ....................................................................... 952
1.1. 1. Java ? ............................................................................................. 953
1.2. 2. .................................................................................... 954
1.3. 3. .................................................................... 954
1.4. 4. ......................................................... 955
1.5. 5. .................................................................................................. 957
1.6. 6. CLASSPATH ....................................... 958
1.7. 7. Java- ............................................................................ 959
1.8. 8. USE , Java .................................................................. 960
1.9. 9. .............................................................................. 961
2. Java Gentoo ................................................................... 961
2.1. 1. ........................................................................................................ 961
2.2. 2. java-config ................................................................................. 963
2.3. 3. .......................................................................... 963
2.4. 4. ... ! .............................................................................. 963
2.5. 5. .......................................................................... 964
Gentoo ......................................................................................................................... 965
1. MySQL ..................................................................... 965
1.1. MySQL .................................................................................... 965
1.2. ..................................................................................... 968
1.3. MySQL ............................................................................ 969
1.4. MySQL ........................................................................................ 973
1.5. ........................................................................................................ 978
2. PostgreSQL Guide .......................................................................................................... 978
2.1. Introduction ......................................................................................................... 978
2.2. PostgreSQL configuration .................................................................................... 980
2.3. Using PostgreSQL ............................................................................................... 983
Gentoo . ......................................................................................... 987
1. Gentoo Subversion. ..................................................................................................... 987
1.1. HOWTO Subversion Apache2 WebDav .............................. 987
gcc ............................................................................................................ 996
1. , .............................................................. 997
2. , ............................................................... 1000
3. , . .................................................................................. 1003
4. , . .............................................................. 1005
5. . ................................................................................................................ 1007

xxii


6. . ............................................................................................................
7. ........................................................................................................................
11. Gentoo ...............................................................................................................
Ebuild HOWTO (.) ...........................................................................................................
1. The Portage tree ...........................................................................................................
1.1. Introduction .......................................................................................................
1.2. Checking Out the Portage Tree from CVS ...........................................................
1.3. What (not) to put in the Portage tree ...................................................................
1.4. CVS Commit Policy ..........................................................................................
1.5. The files Directory .............................................................................................
2. Ebuild scripts ...............................................................................................................
2.1. Introduction .......................................................................................................
2.2. Naming ebuild files ............................................................................................
2.3. Contents of an ebuild file ...................................................................................
2.4. Rules for writing an ebuild file ...........................................................................
2.5. USE Variables ...................................................................................................
3. File system Locations ...................................................................................................
3.1. Introduction to the FHS ......................................................................................
3.2. How to fit your packages into the file system ......................................................
4. The Portage scripts and utilities .....................................................................................
4.1. Public scripts .....................................................................................................
4.2. Private Scripts and Commands ...........................................................................
5. Package Dependencies ..................................................................................................
5.1. Why dependencies are important .........................................................................
5.2. How to Specify Dependencies in Your ebuild Files (a.k.a. DEPEND Atoms) ..........
5.3. Important Notes .................................................................................................
6. Testing and deploying ...................................................................................................
6.1. ChangeLog ........................................................................................................
6.2. Storing your own ebuilds locally .........................................................................
6.3. Testing the package ............................................................................................
6.4. Useful testing tools ............................................................................................
LiveCD Gentoo Linux ............................................................
1. .....................................................................................................................
2. ........................................................................................
3. .........................................................................................
4. KDE ...........................................................................................................
5. ...............................................................................................
5.1. root' .................................................
5.2. init'a .............................................................................
5.3. KDE .............................................................................................
5.4. , .......................
6. ................................................................................................................
..........................................................................................................................................
1. , ......................................................................
2. , ......................................................................
2.1. .................................................................................................................................
12. ...........................................................................................................
MAN ( ) ..................................................................................................
1. Emerge .........................................................................................................................
.....................................................................................
1. make.conf ............................................................................................................
2. 2. xorg.conf NVIDIA Geforce .......................................................................

xxiii

1007
1007
1008
1010
1011
1011
1011
1011
1012
1012
1013
1013
1013
1014
1020
1020
1022
1022
1022
1023
1023
1024
1026
1026
1026
1027
1028
1028
1028
1029
1029
1030
1030
1030
1031
1034
1035
1035
1036
1036
1036
1036
1038
1039
1049
1050
1051
1055
1055
1070
1071
1074


3. 3. xorg.conf ATI radeon: ..............................................................................
4. 4. /etc/fstab .........................................................................................................
Gentoo Linux ...............................................................................................
Unix Toolbox ...........................................................................................................................
1. 1. SYSTEM .................................................................................................................
1.1. 1.1 Hardware Informations .................................................................................
1.2. 1.2 Load, statistics and messages ........................................................................
1.3. 1.3 Users ...........................................................................................................
1.4. 1.4 Limits ..........................................................................................................
1.5. 1.5 Runlevels .....................................................................................................
1.6. 1.6 Reset root password .....................................................................................
1.7. 1.7 Kernel modules ............................................................................................
1.8. 1.8 Compile Kernel ............................................................................................
2. 2. PROCESSES ............................................................................................................
2.1. 2.1 Listing and PIDs ..........................................................................................
2.2. 2.2 Priority ........................................................................................................
2.3. 2.3 Background/Foreground ................................................................................
2.4. 2.4 Top ..............................................................................................................
2.5. 2.5 Signals/Kill ..................................................................................................
3. 3. FILE SYSTEM .........................................................................................................
3.1. 3.1 Permissions ..................................................................................................
3.2. 3.2 Disk information ..........................................................................................
3.3. 3.3 Boot ............................................................................................................
3.4. 3.4 System mount points/Disk usage ...................................................................
3.5. 3.5 Who has which files opened .........................................................................
3.6. 3.6 Mount/remount a file system .........................................................................
3.7. 3.7 Mount an SMB share ...................................................................................
3.8. 3.8 Mount an image ...........................................................................................
3.9. 3.9 Create and burn an ISO image ......................................................................
3.10. 3.10 Create a file based image ..........................................................................
3.11. 3.11 Create a memory file system .....................................................................
3.12. 3.12 Disk performance .....................................................................................
4. 4. NETWORK ..............................................................................................................
4.1. 4.1 Debugging (See also Traffic analysis) (page 18) .............................................
4.2. 4.2 Routing ........................................................................................................
4.3. 4.3 Configure additional IP addresses ..................................................................
4.4. 4.4 Change MAC address ...................................................................................
4.5. 4.5 Ports in use ..................................................................................................
4.6. 4.6 Firewall .......................................................................................................
4.7. 4.7 IP Forward for routing ..................................................................................
4.8. 4.8 NAT Network Address Translation ................................................................
4.9. 4.9 DNS ............................................................................................................
4.10. 4.10 DHCP ......................................................................................................
4.11. 4.11 Traffic analysis .........................................................................................
4.12. 4.12 Traffic control (QoS) ................................................................................
4.13. 4.13 NIS Debugging .........................................................................................
5. 5. SSH SCP .................................................................................................................
5.1. 5.1 Public key authentication ..............................................................................
5.2. 5.2 Check fingerprint .........................................................................................
5.3. 5.3 Secure file transfer .......................................................................................
5.4. 5.4 Tunneling .....................................................................................................
6. 6. VPN WITH SSH ......................................................................................................

xxiv

1077
1086
1087
1088
1090
1091
1092
1092
1093
1094
1096
1097
1097
1098
1098
1099
1099
1100
1100
1100
1101
1101
1101
1102
1102
1103
1104
1105
1106
1107
1108
1108
1108
1108
1109
1109
1110
1110
1110
1111
1111
1112
1114
1115
1116
1118
1118
1119
1120
1120
1121
1123


6.1. 6.1 Single P2P connection ..................................................................................
6.2. 6.2 Connect two networks ..................................................................................
7. 7. RSYNC ....................................................................................................................
7.1. 7.1 Rsync on Windows ......................................................................................
8. 8. SUDO ......................................................................................................................
8.1. 8.1 Configuration ...............................................................................................
9. 9. ENCRYPT FILES .....................................................................................................
9.1. 9.1 A single file .................................................................................................
9.2. 9.2 tar and encrypt a whole directory ..................................................................
9.3. 9.3 tar zip and encrypt a whole directory .............................................................
10. 10. ENCRYPT PARTITIONS ......................................................................................
10.1. 10.1 Linux .......................................................................................................
10.2. 10.2 FreeBSD ..................................................................................................
11. 11. SSL CERTIFICATES ............................................................................................
11.1. 11.1 Procedure .................................................................................................
11.2. 11.2 Configure OpenSSL ..................................................................................
11.3. 11.3 Create a certificate authority ......................................................................
11.4. 11.4 Create a certificate signing request .............................................................
11.5. 11.5 Sign the certificate ....................................................................................
11.6. 11.6 Create united certificate .............................................................................
11.7. 11.7 View certificate information .......................................................................
12. 12. CVS .....................................................................................................................
12.1. 12.1 Server setup .............................................................................................
12.2. 12.2 Test it ......................................................................................................
12.3. 12.3 SSH tunneling for CVS .............................................................................
12.4. 12.4 CVS commands and usage ........................................................................
13. 13. SVN .....................................................................................................................
13.1. 13.1 Server setup .............................................................................................
13.2. 13.2 SVN commands and usage ........................................................................
14. 14. USEFUL COMMANDS ........................................................................................
14.1. 14.1 less ..........................................................................................................
14.2. 14.2 vi .............................................................................................................
14.3. 14.3 mail .........................................................................................................
14.4. 14.4 tar ............................................................................................................
14.5. 14.5 dd ............................................................................................................
14.6. 14.6 screen ......................................................................................................
14.7. 14.7 Find .........................................................................................................
14.8. 14.8 Miscellaneous ...........................................................................................
15. 15. INSTALL SOFTWARE .........................................................................................
15.1. 15.1 List installed packages ..............................................................................
15.2. 15.2 Add/remove software ................................................................................
15.3. 15.3 Library path .............................................................................................
16. 16. CONVERT MEDIA ..............................................................................................
16.1. 16.1 Text encoding ...........................................................................................
16.2. 16.2 Unix - DOS newlines ................................................................................
16.3. 16.3 PDF to Jpeg and concatenate PDF files ......................................................
16.4. 16.4 Convert video ...........................................................................................
16.5. 16.5 Copy an audio cd .....................................................................................
17. 17. PRINTING ...........................................................................................................
17.1. 17.1 Print with lpr ............................................................................................
18. 18. DATABASES ........................................................................................................
18.1. 18.1 PostgreSQL ..............................................................................................

xxv

1123
1124
1125
1126
1128
1128
1129
1129
1129
1129
1130
1130
1131
1133
1133
1133
1134
1134
1134
1135
1135
1136
1136
1138
1139
1139
1140
1140
1142
1143
1143
1144
1145
1145
1146
1147
1148
1149
1150
1150
1150
1151
1151
1151
1152
1152
1152
1152
1153
1153
1153
1153


18.2. 18.2 MySQL ....................................................................................................
18.3. 18.1 SQLite .....................................................................................................
19. 19. DISK QUOTA ......................................................................................................
19.1. 19.1 Linux setup ..............................................................................................
19.2. 19.2 FreeBSD setup .........................................................................................
19.3. 19.3 Assign quota limits ...................................................................................
20. 20. SHELLS ...............................................................................................................
20.1. 20.1 bash .........................................................................................................
20.2. 20.2 tcsh ..........................................................................................................
21. 21. SCRIPTING .........................................................................................................
21.1. 21.1 Basics ......................................................................................................
21.2. 21.2 Bourne script example ..............................................................................
21.3. 21.3 Some sed commands .................................................................................
21.4. 21.4 Some useful commands .............................................................................
22. 22. PROGRAMMING .................................................................................................
22.1. 22.1 C basics ...................................................................................................
22.2. 22.2 C example ................................................................................................
22.3. 22.3 C++ basics ...............................................................................................
22.4. 22.4 C++ example ............................................................................................
22.5. 22.5 Simple Makefile .......................................................................................
23. 23. ONLINE HELP ....................................................................................................
23.1. 23.1 Documentation .........................................................................................
23.2. 23.2 Other Unix/Linux references .....................................................................
Gentoo Linux ............................................................................................
....................................................................................................................

xxvi

1154
1156
1156
1156
1157
1157
1158
1159
1160
1161
1161
1163
1164
1164
1165
1165
1165
1166
1166
1168
1168
1168
1169
1170
1171

...
a.k.a JohnBat26
2009
: .
! .


a.k.a changelog
2.0-M2 03.01.2010
1.

: ;

2.

DocBook 5.0.

3.

4.

2.0-M1 23.04.2008
1.

: a.k.a. HedgeHog;

2.

SVN.

3.

DocBook5 RelaxNG .

4.

5.

Linux UNIX.

6.

: "Linux ".

7.

: " ".

1.5 02.04.2008
1.

:
a.k.a. MooSe;
a.k.a integer || night_fever.

2.

Power Management Guide: ( : vah).

3.

: rpm- Gentoo (: MooSe).

4.

: Gentoo (:tuxmaster).

5.

: Unix Toolbox.

6.

: Gentoo ( 2) ( .);

a.k.a changelog

7.

: - (: gentoo).

8.

: HOWTO ivman.

9.

: gcc.

10. : Gentoo , :
MySQL ;
PostgreSQL Guide.
11. : Gentoo, :
2.6: ;
;
Mozilla;
:
Gentoo Linux;
IDE hdparm;
.
12. : Gentoo , :
HOWTO Subversion Apache2 WebDav.
13. : LiveCD Gentoo Linux (: Pizgin).
14. : , (: Perlovka)
15. : Hardened Gentoo (: powerman).
16. : Gentoo and KDE 4.0
17. .
18. .
19. : " "
1.4 01.02.2008
1.

: Gentoo Linux.

2.

. ;)

3.

KDE 4.0.0, : Gentoo KDE


: Gentoo and KDE 4.0
: KDE (31).

a.k.a changelog
4.

Java, : Gentoo Java


: Gentoo Java Guide;
: Gentoo Java Upgrade Guide;

5.

(: MooSe): OpenVPN.

6.

wiki: Gentoo.

7.

HOWTO: HOWTO hal .

8.

: Ebuild HOWTO ().

9.

XkbLayouts hal 0.5.10


.

10. : Power Management Guide (.)


11. : Windows-.
12. .
13. .
14. : " "
1.3 01.11.2007
1.

2.

. :)

3.

MAA (http://linuxforum.ru) Linux .

4.

Linux !

5.

Wiki-: HOWTO Xorg and Fonts.

6.

: "Gentoo GPRS".

7.

XkbOptions.

8.

: "Gentoo X.Org"

9.

: " Linux

10. : " Gentoo" .. . .


11. : " "
12. : "HOWTO Internet"
13. .
1.2 01.09.2007

a.k.a changelog
1.

Gentoo.

2.

3.

: Gentoo Linux

4.

Handbook!

5.

inhab (linuxforum.ru):
: Samba PDC LDAP.

6.

: GNOME.

7.

: HOWTO fbsplash

1.1 15.07.2007
1.

Mati_maniak (linuxforum.ru):

2.

3.

: Linux , : (no-dashi, dalth & viking).

4.

: IRC .

5.

: .


Gentoo-doc TEAM

1.
2.
3.
4.
5.

...................................................................................................................................
.............................................................................................................................................
................................................................................................................................
........................................................................................................................
Gentoo Linux ...........................................................................................

6
6
7
7
8

1.
1.

Linux
Gentoo .

2.

Gentoo Linux .

3.

Gentoo Linux, .

4.

Gentoo Linux .

5.

2.
1.

.. a.k.a. JohnBat26 (ICQ:198710313; Jabber.ru/Yahoo/AIM/Google/MSN/Skype: JohnBat26)


e-mail: JohnBat26@gmail.com
:
http://picasaweb.google.ru/JohnBat26


http://www.odnoklassniki.ru/user/182870623
http://vkontakte.ru/id4283007
http://evgeniy-batogov.moikrug.ru/
2.

a.k.a integer || night_fever (jabber: night_fever@jabber.ru; ICQ: 496480428)


e-mail: gentoo.integer@gmail.com

3.

a.k.a. MooSE (jabber: moose1@jabber.ru)


e-mail: bulvinkl@gmail.com

4.

a.k.a. eX (gtalk: gorlov.victor@gmail.com)


e-mail: gorlov.victor@gmail.com

5.

a.k.a. HedgeHog
e-mail: gaponik@gmail.com

3.
The GNU General Public License, Version 2

4.
http://gentoo.ru
http://gentoo.org
http://ru.gentoo-wiki.com
http://gentoo.blog.ru
http://www.rugentoo.org
http://linuxforum.ru
http://myfotomx.com
http://linuxshop.ru
http://citkit.ru
http://rus-linux.net


http://lxj.endofinternet.net
http://www.habrahabr.ru/blog/linux
http://perlovka.homelinux.net
http://knotes.ru

5. Gentoo Linux
Gentoo Linux, Linux. , , email (.: 2, )
linuxforum.ru
:
;
;
.
.
:
1.

, ;

2.

, ! ;)
, Gentoo Linux !


a.k.a JohnBat26
2009

: 1.3
: 2.0
, Linux ( Gentoo
). , , , . : " , 5 !"
Linux.
5 Windows ,
. - , Windows, ,
6 . ,
, 200 , Windows
( Gentoo > 1000 :)). , Windows, . ...
OpenSuSE. ,
, , , , ( Smart ,
).
RPM ,
. .... :-(
, , , ,
, -, Gentoo. Gentoo 10 ,
(Dell, Asus, Acer, Sony VAIO)! ,
, .
Gentoo :
1.

2.

IMHO, portage;

3.

, ;

4.

, , gcc, glibc ..;

5.

a.k.a JohnBat26

6.

7.

, , . Gento. : - .
OpenOffice DocBook,
!
,
. , ..
( GPRS ).
Gentoo Linux. : " !" !!!

10

1.
Linux


............................................................................................................................
1. UNIX ......................................................................................................................................
1.1. ......................................................................................................................
1.2. ........................................................................................................................
1.3. ....................................................................................................................
1.4. UNIX ......................................................................................
2. LINUX ....................................................................................................................................
2.1. ......................................................................................................................
2.2. ......................................................................................................................
2.3. ....................................................................................................................
2.4. ..............................................................................................................
Windows- .........................................................................................................................
1. ....................................................................................
2. ..........................................................................................................................
3. ..........................................................................................................................
4. / ...........................................................................................................................
4.1. Chat ..............................................................................................................................
4.2. File managers ................................................................................................................
4.3. FTP ..............................................................................................................................
4.4. Graphics ........................................................................................................................
4.5. Internet .........................................................................................................................
4.6. Mail ..............................................................................................................................
4.7. Multimedia ....................................................................................................................
4.8. Office ...........................................................................................................................
4.9. P2P ...............................................................................................................................

12

13
13
13
14
18
19
20
20
20
21
22
25
26
26
27
28
28
29
29
29
29
30
30
30
31

1. UNIX ..............................................................................................................................................
1.1. ..............................................................................................................................
1.2. ................................................................................................................................
1.3. ............................................................................................................................
1.4. UNIX ..............................................................................................
2. LINUX ............................................................................................................................................
2.1. ..............................................................................................................................
2.2. ..............................................................................................................................
2.3. ............................................................................................................................
2.4. ......................................................................................................................

13
13
14
18
19
20
20
20
21
22

1. UNIX
: 1.3
: 2.0

1.1.
UNIX ( ) , .
UNIX 1960- 1970- Bell Labs
AT&T. UNIX-.
UNIX; , , UNIX- (. Unix-like). UNIX- UNIX, UNIX-
. UNIX- :
1.

13


2.

3.

4.

, .

UNIX ,
. UNIX
, Microsoft Windows. UNIX-
, .

1.2.
1.2.1.
1957 Bell Labs .
( ) BESYS.
Multics, Bell
Labs.

UNIX-.
1964 , BESYS .
, General Electric
Multics. AT&T, Bell Labs,
, 1969 ,
.

14

1.2.2. UNIX
UNIX 1960- Bell Labs, 1969
, , MULTICS, (DEC PDP-7), ,
UNICS (UNIplexed Information and Computing System) MULTICS (MULTIplexed Information and Computing Service).
UNIX. 1971 PDP-11, 1970-
( ). (Edition 1)
. UNIX 1 1970.
UNIX . 1969
(B), ( ) 1966 BCPL. , BCPL, . 19691973
, (C).
1973 UNIX, . 15
, ( Multics,
(/1)), 1975 ,
. 1974 UNIX . 1975 , Bell Labs,
.
1975 ,
(Lions' Commentary on UNIX 6th Edition, with Source Code, [1], [2]). 1978 . 600 , , .
UNIX. Bourne shell. , .

1.2.3.
1978 BSD UNIX, . ,
. 1979 , 3BSD,
. BSD ,
. BSD .
1980- AT&T, Bell Labs, UNIX
UNIX. , 1982 ,
UNIX System III .
UNIX 1980 . TCP/IP. UNIX UUCP ( UNIX- , ).
: Berkley sockets
TLI (. Transport Layer Interface). Berkley sockets
TCP/IP, . TLI
AT&T OSI

15


System V 3. TLI ,
TCP/IP , . TCP/IP System V
4. , ( , ),
UNIX BSD ( ) System V ( AT&T).
, , System V AT&T, UNIX, , AIX, HP-UX, IRIX, Solaris.
1983 4.2BSD, Ethernet Arpanet.
. 1983 1990 BSD , , NFS, VFS,
.
AT&T , System V. 1983 1 (SVR1 System V Release 1), vi, curses, -, inode. 2 (SVR2), 1984,
(file locking), (demand
paging), (copy-on-write). 3 1987 , ,
TLI, RFS. 4 (SVR4),
Sun 18 1988, BSD,
TCP/IP, , csh. ,
, , ksh,
NFS ( SunOS) . .
UNIX, , V BSD .
System V, BSD.

1.2.4. UNIX-
1983 GNU
UNIX- , . , , , GNU
toolchain, Glibc ( ) Coreutils . UNIX, GNU, . GNU Hurd
Mach .
1991 , Linux , , GNU, .
GNU Linux , , GNU/Linux. ( Red Hat Debian), , GNU , .
, UNIX Systems Laboratories Berkeley Software Design Inc., , BSD UNIX, . ,
BSD- UNIX. BSD , , FreeBSD, NetBSD, OpenBSD,
TrustedBSD DragonFlyBSD.
GNU/Linux BSD UNIX- -

16


, .
, , Apple ,
NEXTSTEP ,
NeXT Darwin Apple. BSD Mach. Darwin BSD UNIX Mac OS X
UNIX.

1.2.5.
AT&T, UNIX , , Novell.
1993 Novell
X/Open, Open Software Foundation,
The Open Group. , IBM, Hewlett-Packard, Sun, NASA . , Single UNIX Specification, POSIX. The Open Group,
UNIX , Single UNIX
Specification.
1995 Novell System V Santa Cruz Operation. 2000 Santa Cruz Operation UNIX- Caldera,
SCO Group. SCO, Santa Cruz Operation, .
SCO Group , UNIX
UNIX- ,
. Novell , Santa Cruz Operation
, , SCO Group, Novell, .

1.2.6. UNIX
, UNIX,
. UNIX- .
Multics, UNIX , (
).
, ,
. , ( , ) ,
( IOCTL )
.
UNIX Multics
. , , , .
, Multics.

17


, , , Multics, UNIX. UNIX
, , , ,
, JCL IBM.
, ,
. , . , UNIX, ,
, .
UNIX - , . UNIX . - , UNIX - , .
, , .
. (. pipelines). UNIX , .
, , , Telnet, FTP,
SMTP, HTTP .
UNIX , ed UNIX. , UNIX-,
(POSIX).
,
UNIX, UNIX . ,
. , , , ,
, . . ,
, gets scanf. , , , .
UNIX .
UNIX TCP/IP , . , , ,
UNIX.
UNIX
, , UNIX (. UNIX).

1.3.
UNIX , UNIX. 1980 /usr/
group. 19841985 . :

18


1.

POSIX 1003.1-1988, (API, Application


Programming Interface). UNIX, .
1990 IEEE IEEE 1003.1-1990.

2.

POSIX 1003.2-1992, , .

3.

POSIX 1003.1b-1993, POSIX 1003.1-1988.


.

4.

POSIX 1003.1c-1995, POSIX 1003.1-1988. (threads),


pthreads.

POSIX IEEE 1003.


1990- The Open Group , POSIX Common
API Specification, Spec 1170. , POSIX,
, IEEE .
1998 .
. Single UNIX Specification Version
3 [3].
UNIX- ELF- SVR4 .
.
, , GNU/Linux, Filesystem
Hierarchy Standard. , , GNU/Linux, .

1.4. UNIX
1.

: ls, mv, rm, cp, ln, CD, pwd, mkdir, rmdir, find, du, df.

2.

: touch, more, less, ed, ex, vi, emacs.

3.

: echo, cat, grep, sort, uniq, sed, awk, tee, head, tail, cut, tr, split, printf.

4.

: comm, cmp, diff, patch.

5.

: yes, test, xargs, expr.

6.

: chmod, chown, ps, su, w, who, df, mount, umount.

7.

: mail, telnet, ftp, finger, ssh.

8.

: sh, bash, csh, ksh, tcsh, zsh.

9.

: cc, gcc, ld, nm, yacc, bison, lex, flex, ar, ranlib, make.

10. : compress, uncompress, gzip, gunzip, tar.


11. : od, strings.

19


60 1 UNIX:
ar, as, b, bas, bcd, boot, cat, chdir, check, chmod, chown, cmp, cp, date, db, dbppt, dc, df, dsw, dtf, du, ed, find,
for, form, hup, lbppt, ld, ln, ls, mail, mesg, mkdir, mkfs, mount, mv, nm, od, pr, rew, rkd, rkf, rkl, rm, rmdir, roff,
sdate, sh, stat, strip, su, sum, tap, tm, tty, type, un, wc, who, write

2. LINUX
: 1.3
: 2.0

2.1.
Linux GNU/Linux ( ) UNIX- Linux ,
GNU. Linux,
, ,
Linux, GNU C Library (glibc).
GNU/Linux PC- Intel x86, IA-64, AMD64,
PowerPC, ARM . GNU/Linux ,
, , . , GNU/
Linux . GNU/Linux
, GNU Linux
. GNU/Linux Slackware, Debian
GNU/Linux, Red Hat, Fedora, Mandriva, SuSE, Gentoo, Ubuntu. ALT Linux ASPLinux.

2.2.
GNU Linux Linux GNU/Linux.
, open source 1, free software.
, GNU/Linux ( ), . , GNU Linux , GNU+Linux ( ), GNU-Linux ( ), GNU con Linux
( ), , GNU Linux ( ), ,
Linux GNU.2
TCP/IP Ogg/Vorbis.
1

Jargon File, Linux.


Richard Stallman. Why do you write GNU/Linux instead of GNU Linux? (.). GNU/Linux FAQ. GNU Project (20012007).

20

2.3.
Microsoft Windows (Windows NT), Mac OS (Mac OS X) |UNIX-
, GNU/Linux . ,
; . GNU/Linux
. , , , .
, , . , ,
.

Linux.
, ,
GNU/Linux.
, ,
, , GPL
.
, ,
. Mozilla (Netscape, AOL), OpenOffice.org (Sun),

21


Interbase (Borland) Firebird, SAP DB (SAP). IBM GNU/Linux
.
,
GNU/Linux . GNU/Linux , , Oracle, DB2, Informix, SyBase, SAP R3,
Domino.
GNU/Linux Linux.

2.4.
GNU/Linux .
, , , , .

22

23


GNU/Linux.
:
Debian GNU/Linux (
, - Ubuntu, Kubuntu, Xubuntu).
Red Hat Fedora.
SuSE, Novell.
- Mandriva ( Mandrake Conectiva).
Gentoo.
, , , .
, , .
,
, , , .
LiveCD, GNU/Linux, , Knoppix. LiveCD GNU/Linux -, .
GNU/Linux , source-based , ( ) , LFS,
Gentoo, ArchLinux CRUX.

24

Windows-

1.
2.
3.
4.

............................................................................................
..................................................................................................................................
..................................................................................................................................
/ ...................................................................................................................................
4.1. Chat ......................................................................................................................................
4.2. File managers ........................................................................................................................
4.3. FTP ......................................................................................................................................
4.4. Graphics ................................................................................................................................
4.5. Internet .................................................................................................................................
4.6. Mail ......................................................................................................................................
4.7. Multimedia ............................................................................................................................
4.8. Office ...................................................................................................................................
4.9. P2P .......................................................................................................................................

26
26
27
28
28
29
29
29
29
30
30
30
31

1: http://ru.gentoo-wiki.com/wiki/Windows-
2: http://www.linuxrsp.ru/win-lin-soft/table-rus.html
3: http://blog.r000n.net/win-lin-analogs
4: http://ru.opensuse.org/_
5: http://www.linuxalt.com/
C : 1.0
: 2.0
, , , ? , . .
, gentoo, ,
, .
(.) , (.)

25

Windows-

1.
1. Windows-:

MS Windows

Linux
.

Dr.Web,AVG,NOD32,
ClamAV
Kaspersky, Clamav

clamav
Dr.Web

drweb

crg , rostov

AVG
NOD32
Kaspersky
Trend
ServerProtect
RAV Antivirus
F-Prot

-
/ Kedit (KDE) (.)

Notepad, WordPad, Gedit (Gnome)


TextPad,
Vim,
Kate (KDE)
Xemacs,...
KWrite (KDE)

kedit
gedit
kate
kwrite

Nedit

nedit

jEdit

jedit

Vim

vim

Xemacs

xemacs

Scribes

scribes

leafpad

leafpad

Xcoral
Nvi

nvi

- Vim, Xemacs,- Nano


FAR, - Jed
DN ...
Vim

nano
jed
vim

Xemacs

xemacs

2.
2. Windows-:

CD/DVD

MS Windows

Linux
.

BurnAtOnce,Roxio Graveman
Easy CD Creator,
Nero

graveman

Nero Linux

26

Windows-

MS Windows

Linux
.

K3b (KDE)

k3b

XCDRoast

xcdroast

Eroaster
Arson
tcdr

CD

CD
player, KsCD (KDE)
Winamp, Windows Orpheus (.)
Media Player ...
Sadp

kscd
orpheus

Grip

grip

cdplay (.)

cdplay

mcdp (.)

mcdp

cdplayer

cdplayer

3.
3. Windows-:

MS Windows Linux

Web-

Internet Explorer, Mozilla , Epiphany (.)


Firefox , Opera...
Galeon (.)

Outlook Express, Netscape/


Mozilla, Thunderbird, The
Bat,
Eudora,
Becky,
Datula, Sylpheed/Sylpheedclaws, Opera

epiphany
galeon

Konqueror (.)

konqueror

Links (.)

links

Mozilla (.)

mozilla

Firefox (.)

mozilla-firefox

Nautilus (.)

nautilus

Opera (.)

opera

Evolution (.)

evolution

Mozilla messenger

mozilla

Sylpheed

sylpheed

Sylpheed-claws

sylpheed-claws

Kmail

kmail

Gnus (.)

gnus

Balsa

balsa

Gnumail

gnumail

Opera

opera

Thunderbird

thunderbird

Mutt (.)

mutt

27

Windows-

MS Windows Linux

Pine (.)

pine

ICQ Lite, ICQ Corp, MSN, Licq (ICQ)


(IM)
AIM, Yahoo, ...
Centericq ()(.)
Trillian ICQ (, Micq (ICQ)(.)
3 GnomeICU (ICQ)
Gaim ()
), Miranda, Gaim
Ayttm ()
Kopete

licq
centericq
micq
gnomeicu
gaim
ayttm
kopete

Simple Instant Messenger sim


()
aMSN (MSN)

amsn

YSM (ICQ)(.)

ysm

Yahoo Messenger for Unix

ymessenger

Kmess (MSN)

kmess

- VirtualDub , VirtualDubMod Avidemux

Virtual CD

VirtualDrive,
VirtualCD, mount -o loop "mycd.iso" /
Daemon Tools, ...
mnt/cdrom

Blue Screen of Death

XScreenSaver

avidemux

xscreensaver

4. /
4. Windows-: /

MS Windows Linux

MS Office, StarOffice
OpenOffice, 602Software

/ OpenOffice
Koffice

koffice
openoffice

Word,
StarOffice
/ OpenOffice Writer
OpenOffice Writer, 602Text, KWord
Abiword
AbiWord

openoffice

Excel,
StarOffice
OpenOffice Calc

openoffice

/ OpenOffice Calc

kword
abiword

KSpread

kspread

Gnumeric

gnumeric

4.1. Chat
1.

amsn: alternative for MSN Messenger

28

Windows-
2.

gaim: alternative for Aim, ICQ, IRC, Yahoo!, MSN, Jabber (Google Talk)

3.

irssi: (command line based) alternative for mIRC

4.

kopete: alternative for Aim, ICQ, IRC, Yahoo!, MSN, Jabber

5.

licq: alternative for ICQ

6.

psi: jabber client

7.

xchat: mIRC

8.

KVIrc : mIRC

9.

konversation: alternative for mIRC

10. Skype: Skype has also version in Linux


11. WengoPhone:Wengophone also has a Linux version and is open source
12. SIM-IM: alternative for ICQ, Jabber, MSN, SMS, Yahoo!, AIM

4.2. File managers


1.

krusader: alternative for Total Commander

2.

GNOME Commander

4.3. FTP
1.

gFTP: alternative for FileZilla, SmartFTP

4.4. Graphics
1.

digiKam: alternative for the propriotary digital photo software bundled with your camera

2.

gimp: alternative for Adobe Photoshop

3.

Inkscape : alternative for Adobe Illustrator

4.

gqview: alternative for Irfanview

5.

gwenview : alternative for Irfanview

6.

kuickshow: alternative for Irfanview

4.5. Internet
1.

Konqueror: alternative for Internet Explorer

29

Windows-

2.

Mozilla Firefox: there is no alternative!

3.

Seamonkey (previously called Mozilla): alternative for Internet Explorer

4.

Opera: free but proprietary alternative for Internet Explorer

4.6. Mail
1.

Evolution: alternative for Outlook

2.

Mozilla Thunderbird: alternative for Outlook Express

3.

Kontact / kmail: alternative for Outlook Express

4.7. Multimedia
1.

AmaroK: alternative for iTunes player/WMP

2.

XMMS: alternative for WinAMP http://komnas.com/~ashamril/tips/files/win-vs-lin-soft-EN.shtml

3.

beep-media-player: alternative for WinAMP

1.

kaffeine: alternative for Windows Media Player (also plays DVDs)

2.

MPlayer | gmplayer | kmplayer | kplayer: alternative for Windows Media Player

3.

Xine: alternative for Windows Media Player (also plays DVDs)

4.

vlc: alternative for Windows Media Player

5.

RealPlayer: runs natively on linux!

6.

Totem : alternative for WMP, Menusupport for DVDs

1.

LMMS : "Linux Music Maker Studio" Linux analog of "FL Studio" HomePage:http://
www.lmms.sourceforge.net/

2.

Rosegarden : MIDI/Audio-sequencer HomePage:http://www.rosegardenmusic.com/

3.

Cheese-Tracker : one of the Trackers, use QT

4.8. Office
1.

OpenOffice.org: alternative for MS Word, Excel, Powerpoint and Access, great support for MS formats

2.

KOffice : like above without MS format support. Includes more specialized apps than even the full MS
Office Pro

3.

AbiWord : Only like MS Word. Decent MS Format support. Includes grammar check

30

Windows-

4.

StarOffice: commercial version of OpenOffice.org, includes extras (grammar check)

5.

kpdf, xpdf, epdfview, evince: PDF readers, alternative for Adobe Acrobat Reader

4.9. P2P
1.

Azureus: java bittorrent client (or bittorrent which is written in python)

2.

qtorrent, ktorrent: bittorrent clients

3.

Limewire + gtk-gnutella: Gnutella client

4.

MLDonkey + Sancho: client and interface for bittorrent, Gnutella, FastTrack, etc.

5.

aMule: alternative for eMule

6.

xmule: alternative for eMule

7.

nicotine: soulseek client

8.

Valknut, LinuxDC++ : DC (Direct Connect)

31

2. Gentoo:


Gentoo Linux ...................................................................................................................................
1. ? ................................................................................................................
2. Gentoo Linux ...........................................................................................................................
3. Gentoo ......................................................................................................................
4. Gentoo ..................................................................................................................
Gentoo Linux: .................................................................................................
1. Gentoo Linux .......................................................................................................................
2. ........................................................................................................
3. ...........................................................................................
4. ......................................................................................................
5. ..............................................................................
6. Gentoo ................................................................................................
7. : .................................................................................................
8. : ...................................................................
9. .........................................................................................................
10. ........................................................................................................
Gentoo Linux x86 .........................................................................
1. .................................................................................................................
2. .......................................................................................................................
3. ..................................................................................................................
4. ....................................................................................................................
5. Gentoo ........................................................................................
6. .......................................................................................................................
7. .................................................................................................................
8. ..................................................................................................
9. .............................................................................................................
9.1. Grub .............................................................................................................................
9.2. Lilo ...............................................................................................................................
10. ............................................................................................................
Gentoo Linux ............................................................
1. .................................................................................................................
2. Smart BootManager ...........................................
3. Knoppix .............................................................................................
4. Stage 1 .................................................................................
5. PXE ........................................................................
6. Gentoo Linux- ...............................................................
Gentoo/x86 ........................................................................................
1. 1. .........................................................................................................................
2. 2. ......................................................................................................
3. 3. .........................................................................................................
4. 4. / ...................................................................................................
4.1. ............................................................................
Gentoo .........................................................................................................
1. ...............................................................................................................................
2. .........................................................................................................
3. ..................................................................................
3.1. ..........................................................................................................
3.2. ........................................................................................

33

36
36
37
37
38
41
41
42
43
46
48
49
51
54
55
59
60
60
61
61
61
61
62
62
63
63
64
64
65
66
66
66
67
68
69
73
76
76
76
79
80
80
82
82
82
83
83
83

Gentoo:
3.3. ....................................................................................................... 84
3.4. Gentoo ...................................................................................................... 85
3.5. ................................................................................................................ 86
3.6. ..................................................................................... 86
3.7. ................................................................................................. 87
3.8. UNICODE ........................................................................................... 87
3.9. Gentoo .......................................................................................................... 88
4. ............................................................................................... 88
4.1. ................................................................................................. 88
4.2. ................................................................................................ 89
................................................................................................................. 91
.............................................................................................. 101
1. ........................................................................................................................... 101
2. .................................................................................................................... 101
2.1. ? ........................................................................................... 101
2.2. ? ................................................................................................. 102
2.3. Gentoo Way ................................................................................................................ 102
2.4. root ? ................................................................................ 103
3. ................................................................................................................... 103
3.1. ..................................................................................................... 103
3.2. ? ................................................... 105
3.3. ?
........................................................................................................................................... 105
4. X Window ......................................................................................... 106
4.1. ? ......................................................................................... 106
4.2. ? ............................................................. 106
Gentoo Linux x86 ................................................................................................. 107
1. Gentoo ................................................................................................................. 110
1.1. Gentoo Linux ........................................................................................ 110
1.2. ........................................................... 112
1.3. .......................................................................................................... 119
1.4. ..................................................................................................... 126
1.5. Gentoo .................................................................... 134
1.6. Gentoo ............................................................................ 140
1.7. .......................................................................................................... 145
1.8. ................................................................................. 151
1.9. ....................................................................... 156
1.10. ............................................................................. 159
1.11. Gentoo .................................................................................. 166
1.12. ? .............................................................................................. 167
2. Gentoo .................................................................................................................... 168
2.1. Portage ..................................................................................................... 168
2.2. USE- .................................................................................................................. 176
2.3. Portage ................................................................................................. 181
2.4. .......................................................................................... 184
2.5. ..................................................................................................... 193
3. Portage .................................................................................................................... 197
3.1. ...................................................................................................... 197
3.2. ........................................................................... 200
3.3. ............................................................ 203
3.4. Portage .............................................................................. 205
3.5. ........................................................................ 207

34

Gentoo:
3.6. ebuild .................................................................................................
4. Gentoo ......................................................................................................
4.1. ..................................................................................................
4.2. .............................................................................................
4.3. .......................................................................................
4.4. ......................................................................................................
4.5. ...................................................................................
4.6. ......................................................................................................
Gentoo .........................................................................................................
1. X.org .........................................................................................................................
Portage .................................................................................................................................
1. Portage ..........................................................................................
2. ? .....................................................................................
3. ? .............................................................................................
4. .........................................................................................................
5. ................................................................................................

35

209
212
212
214
216
222
229
231
233
234
235
235
236
236
237
237

Gentoo Linux

1.
2.
3.
4.

? ........................................................................................................................
Gentoo Linux ...................................................................................................................................
Gentoo ..............................................................................................................................
Gentoo ..........................................................................................................................

36
37
37
38

: http://gentoo.ru/about
C : 1.0
Gentoo Pygoscelis papua ( : , , ). 98
(27/).
Gentoo Linux ,
. , Gentoo.
, Gentoo Linux , , , ,
- , . - , Gentoo Linux .

1. ?
Portage Gentoo Linux, . , portage
Gentoo Linux. ,
, Gentoo Linux : emerge --sync
(emerge; / (: emerge , , )).
Portage .
,
Gentoo. Portage 10000 ,
.
Portage . , : emerge _, Portage
, , , .

36

Gentoo Linux
Portage , .
: emerge -u world ,
.

2. Gentoo Linux
Gentoo Linux .
Gentoo Gentoo Linux: ,
Gentoo Linux , : emerge --sync. , Gentoo Linux , .
, Gentoo Linux -, . ,
Gentoo Linux:
1.

x86, AMD64, PowerPC, UltraSparc, Alpha MIPS

2.

x86, AMD64, PowerPC, UltraSparc Alpha LiveCD

3.

KDE GNOME

4.

Linux

5.

GNU

6.

: ReiserFS, XFS, ext3, EVMS, LVM

7.

: NVIDIA, Creative Labs Live! Audigy

8.

OpenGL ( )

9.

10. Gentoo
11. 10000
12.
, Gentoo Linux, .
: !

3. Gentoo
. , ,
... Gentoo Linux. Debian
Linux, , Linux , , -

37

Gentoo Linux
Linux, , Stampede Linux. , Stampede,
. , ,
.
. , ,
. #enoch
irc.freenode.net 10 , . ,
, , . Gentoo Linux.
, Gentoo 1.0 , .
, - Linux , -
Gentoo .
Gentoo... FreeBSD. . . Linux. ,
, Gentoo . Portage.
Gentoo , . Gentoo ,
.
Gentoo - ,
, Gentoo. ( ) . , Gentoo
, Gentoo.
2004 Gentoo.
Gentoo, .
Gentoo , : , , . , ,
Gentoo Gentoo!

4. Gentoo
: http://gentoo.ru/philosophy
: 1.0
: Daniel Robbins Gentoo
:
Gentoo, , .
Linux- - ,
, ,
.
Gentoo (.. Portages), ,
, . -

38

Gentoo Linux
.
, , ebuild.
ebuild (, emerge build file)
. , USE. , ebuild
. emerge , .
Linux- , Gentoo . " ", Gentoo "from source" ( ). , , , . , ,
.
, Linux. (
) ?
Gentoo , .
Gentoo , , . . , , , Gentoo .
, ..
(, RPM . ). Gentoo , , , . , ""
.
Gentoo :
1.

2.

Gentoo ,
.

3.

Gentoo ,
Linux .
, , , .

4.

- , . , , .
Gentoo.

, Gentoo .
, , (, , Unix . ).
, , .

39

Gentoo Linux
Gentoo , , .
, , ?
?
.

40

Gentoo Linux:

1. Gentoo Linux ...............................................................................................................................


2. ................................................................................................................
3. ...................................................................................................
4. ..............................................................................................................
5. ......................................................................................
6. Gentoo ........................................................................................................
7. : .........................................................................................................
8. : ...........................................................................
9. .................................................................................................................
10. ................................................................................................................

41
42
43
46
48
49
51
54
55
59

: http://posix.ru/distro/gentoo_old/
: (alv@linux-online.ru)
: 1.0
: Gentoo, ,
. - , - Gen-To. , . 2006.03.07

1. Gentoo Linux
Gentoo Linux .. Source Based . ,
,
. Gentoo , ,
Red Hat Debian.
Gentoo 2001 . . http://www.gentoo.org. (: http://gentoo.ru)
Gentoo Linux
BSD- ( FreeBSD). , -

41

Gentoo Linux:
BSD- Linux
, Unix System V (
).
Gentoo FreeBSD. , ,
(.. Distribution) .
.. . ( - ) , , ,
. , FreeBSD (packages),
.
Gentoo ( Portages) , FreeBSD. ( )
, , , gcc glib.
Gentoo :
1.

, ( ) ;

2.

(
, i86, Sparc, PowerPC Alpha),
;

3.

( packages FreeBSD),
, host-;

4.

(, ) .

Gentoo .
Gentoo Handbook ( . Gentoo Linux
x86) , .
( "-") . ( Pygoscelis papua), - (, , ).
, - . Gentoo.

2.
Gentoo .
http ftp, , . ,
CD-, .
Gentoo , ()
. iso- CD- , Gentoo .

42

Gentoo Linux:
, , ,
, , , .
, , .
, 200 ( ).
Live CD Linux-, -. , .
.
(*.tar.bz2), ( ) . ( stage1-*,
10 ) (i86, PowerPC, Sparc ..). (stage2-*
stage3-*, 50 80 , ), , PC- , : i486 Pentium-4 (
Athlon). , , .
, -
portage-200XXXXX.tar.bz2, ~/gentoo/snapshots ( ). , ( ), .
, .
: Gentoo
~/gentoo/distfiles ( ~/gentoo/gentoo-sources, ).
, , , .
,
. "" : CD
( , , ) Zip (
250- , ).
-
( ) . stage2-*, stage3-* portage-* ,
.
, Gentoo (, , ). , ,
. .
, ,
.
, , src , .

3.
Linux- . Gentoo
: ,
, Reset, Setup BIOS -

43

Gentoo Linux:
, (,
dmesg.
(login),
root, Enter.
.
. Gentoo,
- ,
. ( ) .
. -, , , . - ( ),
Gentoo , Live CD. - Linux- ( ).
Linux, bash 6 ( , root ).
CD Linux- ,
( ).
. :
1.

SCSI-, IDE-RAID, Zip- (atapifloppy, Linux), , , ;

1.

: ,
FATxx (native)
Linux, XFS, );

2.

, , ;

3.

ppp .

, ( , ) ,
$ modprobe _

,
$ insmod _

( ) /lib/modules/2.6.XX.X/kernel/
.
( ). IP-, DHCP- (
), ,

44

Gentoo Linux:
$ dhcpcd eth0

. IP- , ( ).
. /mnt ,
,
$ mkdir /mnt/zip

Zip-,
$ mkdir /mnt/cd2

CD ( CD /mnt/cdrom, ,
). . zip- " " :
$ mount /dev/hdd4 -t msdos /mnt/zip

, , , /
dev/hdd4: zip- , , .
: devfs Gentoo, zip
.
CD . ,
( , ,
).
, - , :
$ lynx /mnt/mount_point/build.html

, , , ,
- Gentoo ,
, . , ( , , FreeBSD) , ,
, .
wvdial,
Live CD ( /usr/bin). ppp (, ppp_generic, , ppp_async),
$ wvdialconf /etc/wvdial.conf

, , , , . , :
[Dialer Defaults]
Modem = /dev/ttyS0

45

Gentoo Linux:
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem

, .
, , , :
Dial Command = ATDP

:
Phone =


Username =
Password =

, , /etc/hostname
localhost

/etc/resolv.conf: nameserver IP- DNS- .



$ wvdial

.
:
( , )? Gentoo nano ,
.

$ nano -w _

-w , , . ,
:
$ alias nano='nano -w'

, , bash.

4.
, Live CD.
.

46

Gentoo Linux:
, ( , #11, 2002)
.
fdisk, cfdisk, parted,
Live CD. : mkefs ext2fs, mkfs.xfs
XFS, mkswap , .
( IDE-) . 1.
1. 1. Gentoo

100

ext2fs ext3fs

/dev/hda1

128
=<2*RAM=<2 Linux swap

/dev/hda2

1,5

/dev/hda3

XFS, ext3

, . , 1,5 .
- , . /usr .
, , /home
. /
var /tmp.
Gentoo , , RAID-
(LVM Logical Volumes Manager). . , ( ) . LVM ( ,
). , , Live CD RAID LVM. , , IDE-RAID, (
).
(,
). :
$ swapon /dev/hda2

,
.
,
:
$ mkdir /mnt/gentoo

:
$ mount /dev/hda3 /mnt/gentoo

/boot, /usr, /home


, /mnt/gentoo:

47

Gentoo Linux:
$ mkdir /mnt/gentoo{/boot,/usr,/home}

:
$ mount /dev/hda1 /mnt/gentoo/boot

.
$ cd /mnt/gentoo/

Gentoo . , CD:
$ tar -xvjpf /mnt/cdrom/nocompress/stage1-x86-*.tar.bz2

-p : , . /mnt/gentoo (/mnt/gentoo/etc, /mnt/gentoo/proc ..) , ,


ftp- wget. ,
. ,
, , stage2* stage3*.
, ,
, , :
$ tar -xvjpf /mnt/zip/stage2*.tar.bz2

. /mnt/gentoo , , base Linux. , , , /mnt/gentoo .

5.


. , ,
, .
, ,
:
$ cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
$ cp /etc/hostname /mnt/gentoo/etc/hostname
$ cp /etc/wvdial.conf /mnt/gentoo/etc/wvdial.conf

Linux
. (, ,
):
$ mount -o bind /proc /mnt/gentoo/proc

48

Gentoo Linux:
, ,
( ). , ( Live CD ),
:
$ mount /dev/hdd4 /mnt/gentoo/mnt

, . ,
.
, ,
, . , , .
, /mnt/gentoo/usr (
). , ,
:
$ tar -xvjpf /mnt/zip/portage*.tar.bz2

,
. /mnt/gentoo/usr/
portage distfiles :
$ cp /mnt/zip/src/* /mnt/gentoo/usr/portage/distfiles

, ,
( ).
.
. ,
$ chroot /mnt/gentoo /bin/bash

/mnt/gentoo ,
( ).
$ env-update


Regenerating /etc/ld.so.cache...

:
$ source /etc/profile

, Gentoo Linux, , , Live CD.


( /usr/portage) , / , /mnt/gentoo.

6. Gentoo
, Gentoo Linux ( , ). -

49

Gentoo Linux:
( )
, , , .
: )
, ) /usr/portage/distfiles ( /mnt/
gentoo) , ) - ( ). , ,
( /usr/
portage/distfiles) .
? , , (,
FreeBSD, make world) .
apt-get, , . , .
/etc/make.conf.
nano ( -w, ) .
, USE.
. ,
--enable/disable --with/without ./configure,
. , ( ,
USE="gpm"

(, , ).
USE="-gpm"

( , ).
USE /usr/
portage/profiles/default-x86-XX/make.defaults. ( )
use-howto.html.
? ? ...
/etc/make.conf:
CHOST='i686-pc-linux-gnu'

, . , , . , Pentium-...
,
CFLAGS="*"

. ,
. , , . , -O3 ( ) , -mcpu=* -march=* , . , , -mcpu=i686, Pentium Pro (

50

Gentoo Linux:
, P-II, P-III, P-4 ),
Pentium-100, -march=athlon-xp , Athlon' .

CXXFLAGS=

, , ++.
, CFLAGS=
CXXFLAGS="${CFLAGS}"

example-. ( , ftp- ). ,
wget, .
, .
$ cd /usr/portage


$ scripts/bootstrap.sh

binutils, gcc, gettext glibc ( ), glibc binutils, gcc gettext. ,


, ... -.
,
base Linux .
$ emerge -p system

, , /usr/portage/distfiles,

$ emerge system


_ - . ,
, : (
Live- CD)
wvdial ( Live-),
. , , - Gentoo'
, . , , emerge system
distfiles Gentoo, , :-)

7. :
,
: . , -

51

Gentoo Linux:
Linux, user-. Source
Based .
Gentoo . ,
, . ,
, ,
.
, . ,
stage2-3 . ?
: . /
usr/portage, sys-kernel : Sparc, PPC, Alpha,
. , ,
, , .
, , (
vanilla-sources) , . ,
gentoo-sources, ). ac-sources , .
: usermode-sources Linux Linux, .. ( ); openmosix-sources
(openMosix) , ...
.
$ emerge sys-kernel/name-sources

, , , /usr/src/linux .
, , . .
, , : - Gentoo- ( ).
: , ( lynx ), ( ,
, ) .
.
, : ,
V90, . wget
.
, , . , (, ). :
/usr/src, ,
, . .
,
( /var/db/pkg), -

52

Gentoo Linux:
( ,
).
.
( ).
, , , /usr/src/linux ( /usr/src/linux-_-_, ,
).
$ make menuconfig

.
make config .
. . : Linux (
). (procfs), (Virtual Memory Filesystem)
(devfs). , , ,
(, XFS ext3fs ext2fs, ,
). , .
, ( ) :
$
$
$
$
$

make
make
make
make
make

dep
clean
bzImage
modules
modules_install

, , , ; (, , &&). , :
$ make dep && make clean bzImage modules modules_install


$ cp /usr/src/linux/arch/i386/boot/bzImage /boot

. , . , ,
, ,
$ emerge sys-apps/xfsprogs

XFS. , xfsprogs distfiles.


,
, , :
$ emerge sys-libs/gpm

.
PS/2, :

53

Gentoo Linux:
$ gpm -t imps2 -m /dev/psaux

, .

8. :

. ,
. : Source Based
( make ).
:
$ ln -sf /usr/share/zoneinfo/path/timezonefile /etc/localtime

, path/timezonefile
Europe/Kaliningrad Asia/Kamchatka ( -
, , - ). BIOS
, /etc/rc.
conf.
. ? , /etc/fstab. :
$ nano -w /etc/fstab

, , :
/dev/BOOT
/dev/ROOT
/dev/SWAP
/dev/cdroms/cdrom0
proc

/boot
/
none
/mnt/cdrom
/proc

ext2
xfs
swap
iso9660
proc

noauto,noatime
noatime
sw
noauto,ro
defaults

1
0
0
0
0

1
0
0
0
0

#tmpfs

/dev/shm

tmpfs

defaults

0 0

,
, : /dev/hda1, /dev/hda3, /dev/hda2. , , /dev/
discs/disc0/part1 .., #tmpfs. - mount , .
( ) /etc/fstab.
( FAT-, -, zip-
) .
/dev/BOOT noauto,
.
GRUB Gentoo
. , . grub
:
grub> root (hd0,0)

54

Gentoo Linux:
grub> setup (hd0)

:
grub> quit

, ,
/boot. , . , , , /boot .
GRUB . :
$ nano -w /boot/grub/menu.lst

. GRUB :
default 0
timeout [__]
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

, ,
. .
( ).
.
Gentoo.
title=My Love Gentoo Linux
root (hd0,0)
kernel /boot/_ root=/dev/hda3

. ,
. GRUB, Linux: ,
GRUB , . Linux,
Unix' (, FreeBSD OpenBSD).
, , ,
. ,
/boot/bzImage, /boot
. , kernel, , /boot/linux. Linux
, , /dev/hda?.
, GRUB , ( )
/boot/grub/menu.lst .

9.
. . , ( -

55

Gentoo Linux:
) DMA
. /etc/conf.d/local.start.
( )

hdparm -d 1 /dev/hda

. , , :
gpm -t imps2 -m /dev/psaux

. , Gentoo
( ).
, . .
/etc/rc.conf.
Linux. , Gentoo BSD (
System V, Linux, Slackware
). , .
: , ,
/etc/rc.conf. , .

$ nano -w /etc/rc.conf


KEYMAP="us"

- , .
-
$ ls /usr/share/keymaps/i386/qwerty/ru*

:
/usr/share/keymaps/i386/qwerty/ru1.map.gz
/usr/share/keymaps/i386/qwerty/ru2.map.gz
/usr/share/keymaps/i386/qwerty/ru3.map.gz
/usr/share/keymaps/i386/qwerty/ru4.map.gz
/usr/share/keymaps/i386/qwerty/ru-cp1251.map.gz
/usr/share/keymaps/i386/qwerty/ru.map.gz
/usr/share/keymaps/i386/qwerty/ru-ms.map.gz
/usr/share/keymaps/i386/qwerty/ru_win.map.gz
/usr/share/keymaps/i386/qwerty/ru-yawerty.map.gz

, ( ,
Live CD, , ). , ,
( , ), ru4: KOI8R Windows- ( Windows- ,
, )
CapsLock.
KEYMAP="ru4"

56

Gentoo Linux:
, CONSOLEFONT. ,
. ,
, /usr/share/consolefonts. ,
alt-*.psf.gz cp866-*.psf.gz. , ()
CP866 ( , DOS
IBM). KOI8-R ,
( koi8r-*.gz), ? , : , .
"" ,
, .
console-tools-cyrillic ,
- . , ,
CONSOLEFONT="cp866-8x16"

: , KOI8, CP866. , .
/usr/share/consoletrans koi2alt.
CONSOLETRASLATION="koi2alt"

. ,
, , ( ) . , /etc/rc.conf, ,
(
) , - /etc/localtime. ,
CLOCK="UTC"

, , (UTC=GMT). UTC localtime


/etc/rc.conf ( ,
).
. /etc/init.d/local:
, (
). ( ) ( ):
for i in 1 2 3 4 5 6
do
echo -ne '' > /dev/vc/$i
done

i ( )
1 6 ( ), ,
. " " ESC(K ( )
, i, /dev/vc/1 /dev/vc6.
(devfs), ( tmpfs
/etc/fstab) /dev/tty0 - /dev/tty5.
( ) CP1251. . /etc/fstab
(, , ) CP1251->CP866.

57

Gentoo Linux:
( ) Altlinux ASPLinux.
DOS. : VGA- (
VGA, GeForce )
. , ,
, , . , . Midnight Commander
!
.
/etc/init.d/local ( , !):
export

LANG="ru_RU.KOI8-R"

- ( , , , , , , ) ,
. , ,

export

LC_NUMERIC="POSIX"

, , ,
( , ).
, , , ,
( ) Altlinux
ASPLinux. ,
. , "" ,
. " " ( Gentoo)
.
, , etc-update,
(, ). , , . .
, Gentoo exit, Live CD, , (
) .
. . ,
unmount:
$ umount /mnt/gentoo/boot
$ umount /mnt/gentoo

, reboot ( halt,
).
( - ), : Live
CD (, , ,
):

58

Gentoo Linux:
$ cp /cdroot/boot/linux /mnt/gentoo/boot/

, , . , CD:
$ cp -R /cdroot/lib/modules /mnt/gentoo/lib/modules

, . , , , .
. , ,
- .

10.
, , : , , .
.
, , , . ,
- .
( ) CD .
, (,
).
,
, . : - ,
, , ( ,
). Gentoo ,
, .
, , .
. Gentoo ,
, ,
, GIS CAD. ,
. , ,
. Linux, ,
. , ,
...

59


Gentoo Linux x86

1.
2.
3.
4.
5.
6.
7.
8.
9.

.........................................................................................................................
...............................................................................................................................
..........................................................................................................................
............................................................................................................................
Gentoo ................................................................................................
...............................................................................................................................
.........................................................................................................................
..........................................................................................................
.....................................................................................................................
9.1. Grub .....................................................................................................................................
9.2. Lilo .......................................................................................................................................
10. ....................................................................................................................

60
61
61
61
61
62
62
63
63
64
64
65

: http://www.gentoo.org/doc/ru/gentoo-x86-quickinstall.xml
C : 1.0

1.
- . ISO- : releases/<>/<>/-.
; .
-, . F2, , . PCMCIA, pcmcia.
sshd, , irssi
( -) - lynx links2.

60

Gentoo Linux x86

2.
, net-setup.
modprobe.
ADSL, adsl-setup adsl-start. PPTP, /etc/ppp/
chap-secrets /etc/ppp/options.pptp, pptp <ip >.
iwconfig,
net-setup, ifconfig, dhcpcd / route.
-, export
http_proxy, ftp_proxy RSYNC_PROXY.

3.
fdisk cfdisk. ( 82)
Linux ( 83).
Linux- mke2fs, mke2fs -j, mkreiserfs,
mkfs.xfs, mkfs.jfs. mkswap swapon.
/mnt/gentoo.
(, /mnt/gentoo/boot), .

4.
, date MMDDhhmmYYYY.
( /mnt/cdrom/stages).
/mnt/gentoo tar -xvjpf < >.
: /mnt/gentoo/usr tar xvjf /mnt/cdrom/snapshots/< >.
.
, /mnt/cdrom/distfiles/ /mnt/gentoo/usr/
portage/distfiles/.
/mnt/gentoo/etc/make.conf ( USE, CFLAGS CXXFLAGS).
nano.

5. Gentoo
/proc, /etc/resolv.conf ,
(chroot) Gentoo.

61

Gentoo Linux x86


1.
# cp /etc/resolv.conf /mnt/gentoo/etc/
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile

, emerge --sync .
, /etc/make.profile .
; (, 2.4/ , 2.4). ln -sfn.
( ) scripts/
bootstrap.sh /usr/portage.
( ) emerge -e system
( -N, CFLAGS/CXXFLAGS ).

6.
, /etc/localtime /usr/share/zoneinfo ln -sf.
( gentoo-sources vanilla-sources) make menuconfig, make && make modules_install /usr/
src/linux. arch/i386/boot/bzImage /boot, .
emerge genkernel genkernel all.
, Genkernel, emerge coldplug rc-update add
coldplug default.

7.
/etc/fstab; .
2. fstab
/dev/hda1
/dev/hda2
/dev/hda3
none
none
/dev/cdroms/cdrom0

/boot
none
/
/proc
/dev/shm
/mnt/cdrom

ext2
swap
ext3
proc
tmpfs
auto

defaults,noatime
sw
noatime
defaults
nodev,nosuid,noexec
noauto,user

1
0
0
0
0
0

2
0
1
0
0
0

/etc/conf.d/hostname /etc/conf.d/domainname,
rc-update add domainname default, /etc/conf.d/net. net.eth0 (default run level).

62

Gentoo Linux x86


(NIC), net.eth0,
.
/etc/hosts; :
3. /etc/hosts
( IP-)
127.0.0.1
localhost
192.168.0.5
jenny.homenetwork jenny
192.168.0.6
benny.homenetwork benny
192.168.0.7
tux.homenetwork tux
( IP-)
127.0.0.1
localhost.homenetwork tux localhost

(emerge) pcmcia-cs .
root passwd.
: /etc/rc.conf, /etc/conf.d/rc, /etc/conf.d/keymaps, /
etc/conf.d/clock.

8.
2.4 emerge --unmerge udev emerge devfsd.
, syslog-ng, .
cron, , vixie-cron ( ).
(xfsprogs, reiserfsprogs jfsutils),
(dhcpcd rp-pppoe).

9.
(emerge) grub lilo. /boot/grub/grub.conf /etc/lilo.conf, . .

63

Gentoo Linux x86

9.1. Grub
4. grub.conf
default 0
timeout 30
splashimage=(hd0,0)/grub/splash.xpm.gz

# genkernel
title=Gentoo Linux 2.6.11-r3
root (hd0,0)
kernel /kernel-genkernel-x86-2.6.11-gentoo-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/
initrd /initramfs-genkernel-x86-2.6.11-gentoo-r3
# ( initrd)
title=Gentoo Linux 2.6.11 r3
root (hd0,0)
kernel /kernel-2.6.11-gentoo-r3 root=/dev/hda3
#
title=Windows XP
root (hd0,5)
makeactive
chainloader +1

9.2. Lilo
5. lilo.conf
boot=/dev/hda
prompt
timeout=50
default=gentoo
# , genkernel
image=/boot/kernel-2.6.11-gentoo-r3
label=gentoo
read-only
root=/dev/hda3
# genkernel
image=/boot/kernel-genkernel-x86-2.6.11-gentoo-r3
label=gentoo
read-only
root=/dev/ram0
append="init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev"
initrd=/boot/initramfs-genkernel-x86-2.6.11-gentoo-r3
#
other=/dev/hda6
label=windows

GRUB GRUB (MBR)


grub-install /dev/hda /proc/mounts /etc/mtab. LILO /sbin/lilo.
, .

64

Gentoo Linux x86

10.
root,
useradd -m -G <> < >.
, - /mnt/cdrom
export PKGDIR="/mnt/cdrom", , ,
kde, emerge -k < >.
Gentoo!

65


Gentoo Linux

1. .........................................................................................................................
2. Smart BootManager ...................................................
3. Knoppix .....................................................................................................
4. Stage 1 .........................................................................................
5. PXE ................................................................................
6. Gentoo Linux- .......................................................................

66
66
67
68
69
73

: http://www.gentoo.org/doc/ru/altinstall.xml
: 1.0

1.
boot-from-CD ( ), .
Gentoo Linux , . , , "" .
, , , Bugzilla.

2.
Smart BootManager
Smart BootManager http://btmgr.sourceforge.net/download.html. ,
Linux, .exe . -, , ,
NASM.
. , .

66

Gentoo Linux
1. Smart BootManager
sbminst [-t theme] [-d drv] [-b backup_file] [-u backup_file]
-t
, :
us = English
de = German
hu = Hungarian
zh = Chinese
ru = Russian
cz = Czech
es = Spanish
fr = French
pt = Portuguese
-d

-c
-b
-u
-y

, Smart BootManager;
Linux:
/dev/fd0 floppy-,
/dev/hda IDE-.
/dev/sda SCSI-.
DOS:
0
floppy-
128 ;
CD-ROM;
backup_file ( ) ,
;
backup_file Smart BootManager,
;
.

2. sbminst
# sbminst -t us

-d /dev/fd0

fd0 floppy- ( -).

,
, .
Smart BootManager. CD-ROM ENTER . , .
Smart BootManager http://btmgr.sourceforge.net/

3. Knoppix

Knoppix x86.

Knoppix LiveCD,
Gentoo. Tux Racer ,
OpenOffice.
: , - Knoppix, Gentoo, Gentoo. ,
!

67

Gentoo Linux
Knoppix CD. Knoppix 3.6-3.8.2, knoppix26 , 2.6. , chroot
, . , Knoppix 3.9+, ,
2.6 .
KDE. su -, . root Knoppix. , ,
sshd .
3. /mnt/gentoo
# mkdir /mnt/gentoo

, 4. /proc. -:
4. - proc
# mount -o bind /proc /mnt/gentoo/proc

, (FEATURES) knoppix.
userpriv usersandbox. , ,
.

4. Stage
1
- iso-.
snapshot http://distro.ibiblio.org/pub/linux/distributions/gentoo/snapshots/
( ). tarball , , CD.
Gentoo Install Doc chroot /mnt/gentoo 6.
CD-ROM, docache
- CD snapshot- .
(Alt-F2), ,
bootstrap.sh.
: -
passwd .
(Alt-F1, without chroot) CD /mnt/gentoo/mnt/
cdrom2. portage tarball cdrom2 /mnt/gentoo/usr.
5. snapshot cd
#
#
#
#
#
#

umount /mnt/cdrom
mkdir /mnt/gentoo/mnt/cdrom2
mount /dev/cdroms/cdrom0 /mnt/gentoo/mnt/cdrom2
cp /mnt/gentoo/mnt/cdrom2/portage-$date.tar.bz2 /mnt/gentoo/usr
cd /mnt/gentoo/usr
tar -xvjpf portage-$date.tar.bz2

68

Gentoo Linux
. bootstrap.sh, , .
/usr/portage/distfiles ( F2).
Stage1: glibc, baselayout, texinfo, gettext, zlib, binutils, gcc, ncurses
.

, , .
( 2 >)
# emerge -fp glibc baselayout texinfo gettext zlib binutils gcc ncurses 2> stage1.list
# mount -t vfat /dev/fd0 /mnt/floppy
# cp /mnt/gentoo/stage1.list /mnt/floppy
# umount /mnt/floppy

. stage1.list, ,
. , ,
. :
6. Stripping URLs
( emerge,
- !)
# cut -f 1 -d ' ' stage1.list > stage1.download

wget :
7. wget
# wget -N -i stage1.download

, /mnt/gentoo/usr/portage/distfiles.
bootstrap.sh. wget stage2 3.

5.
PXE

, PXE (
3com). BIOS .

: -, , . /diskless, .
'eta'.
8.
# mkdir /diskless
# mkdir /diskless/eta
# mkdir /diskless/eta/boot

69

Gentoo Linux
DHCP TFTP: , DHCP,
TFTP. DHCP emerge
. /etc/dhcp/dhcpd.conf:
9. dhcp.conf
option option-150 code 150 = text ;
ddns-update-style none ;
host eta {
hardware ethernet 00:00:00:00:00:00;
fixed-address ip.add.re.ss;
option option-150 "/eta/boot/grub.lst";
filename "/eta/boot/pxegrub";
}

IP PXE, pxegrub. MAC- , .

DHCPd, emerge dhcp ( DHCP ). ,


/etc/conf.d/dhcp .
TFTP, app-admin/tftp-hpa. /etc/conf.d/in.tftpd:
10. in.tftpd
INTFTPD_PATH="/diskless"
INTFTPD_USER="nobody"
INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"

GRUB: GRUB PXE-. PXE,


GRUB ... . -, GRUB (emerge -f grub tarball /usr/portage/distfiles). tarball /diskless GRUB, pxe .
boot- . grub.lst:
11. grub
# tar zxvf grub-0.92.tar.gz
# cd grub-0.92
# ./configure --help
( .)
( , . $nic)
# ./configure --enable-diskless --enable-$nic
# make
# cd stage2
# cp pxegrub /diskless/eta/boot/pxegrub
# nano -w /diskless/eta/boot/grub.lst

12. grub.lst
default 0
timeout 30
title=Diskless Gentoo
root (nd)
kernel /eta/bzImage ip=dhcp root=/dev/nfs nfsroot=ip.add.re.ss:/diskless/eta
( nfsroot IP ,)
( .)

70

Gentoo Linux
NFS: NFS . /etc/exports:
13. /etc/exports
# nano -w /etc/exports
#/etc/exports: NFS file systems being exported.
/diskless/eta eta(rw,sync,no_root_squash)

See exports(5).

hosts: /etc/hosts.
14. /etc/hosts
127.0.0.1 localhost
192.168.1.10 eta.example.com eta
192.168.1.20 sigma.example.com sigma


Gentoo, , , Gentoo
. , Gentoo Install Howto,
: ( hdaX ,
/diskless). , /diskless/eta.
15.
# mount /dev/hdaX /mnt/gentoo

Stage tarballs chroot: tarball stage3. /proc chroot () .


.

stage tarball. .

16. stage tarball


#
#
#
#
#
#
#

cd /mnt/gentoo/diskless/eta/
tar -xvjpf /mnt/cdrom/gentoo/stage3-*.tar.bz2
mount -t proc /proc /mnt/gentoo/diskless/eta/proc
cp /etc/resolv.conf /mnt/gentoo/diskless/eta/etc/resolv.conf
chroot /mnt/gentoo/diskless/eta/ /bin/bash
env-update
source /etc/profile

: make menuconfig ,
( ):

71

Gentoo Linux
17. menuconfig
- Your network card device support
( , ** !)
- Under "Networking options" :
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support
- Under "File systems --> Network File Systems" :
<*> NFS file system support
[*] Provide NFSv3 client support
[*] Root file system on NFS

/ ( /boot), pxegrub, . /etc/fstab .


18. /etc/fstab
# nano -w /etc/fstab
/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs nodev,nosuid,noexec 0 0

:
19.
# touch /fastboot
# echo "touch /fastboot" >> /etc/conf.d/local.start

nfs-utils, :
20. nfs-utils
# emerge nfs-utils

. , pxegrub. . , : DHCP, TFTPD NFS.


21.
# /etc/init.d/dhcp start
# /etc/init.d/in.tftpd start
# /etc/init.d/nfs start


, bios PXE CD-ROM floppy.
website . IP DHCP PXE- GRUB
TFTP. - GRUB,
, Enter, . , , NFS, . .

72

Gentoo Linux

6. Gentoo
Linux-

Gentoo Linux chroot,
tarball- Gentoo, ISO-. ,
, tarball-. ( , tarball , .tbz .tar.gz). (.) RedHat Linux 7.3 "" ,
. , !

Gentoo, Linux,
, tarball, chroot -, . , ,
, Gentoo.
Gentoo?
, /. mount ,
. df (disk free), ,
. root !
, ,
.
22.
# mount
/dev/hdb2 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw,nodev,nosuid,noexec)
# df -h
Filesystem
Size Used Avail Use% Mounted on
/dev/hdb2
4.0G 1.9G 2.4G 82% /
none
38M
0
38M
0% /dev/shm

, , /, /dev/hdb2 2.4 .
, , 400 , , Gentoo
2 . , , .
!
parted
Parted , GNU foundation, , , , . , . parted, partition editor, http://
www.gnu.org/software/parted/

73

Gentoo Linux

, , / , PartitionMagic(tm) , .
.

parted, ,
, , parted . , , .
- -, Gentoo. , , . . ,
linux- parted /. ,
Linux, , . parted
, . , .

, , , parted!

/ mininux ( - Linux c 2.4 ) http://mininux.free.fr/uk/, , ,


.

, Linux " ".


parted .
boot/root , mininux.
, , , Gentoo, , parted.

23.
# mkfs.minix /dev/fd0
480 inodes
1440 blocks
Firstdatazone=19 (19)
Zonesize=1024
Maxsize=268966912

parted. , .
, .
.
24.
# mkdir /floppy; mount -t minix /dev/fd0 /floppy &&
export CFLAGS="-O3 -pipe -fomit-frame-pointer -static" && ./configure
&& make && cp parted/parted /floppy && umount /floppy

, .
parted GNU website.
. mininux,
, . mount /dev/fd0 /
floppy parted /floppy. . parted

74

Gentoo Linux
. , ,
, Gentoo. , ,
, . , /dev/
hda3, , , /dev/hda.
25. , , mininux
# mount /dev/fd0 /floppy
# cd /floppy; ./parted [, ]
(parted) print
Disk geometry for /dev/hdb: 0.000-9787.148 megabytes
Disk label type: msdos
Minor
Start
End
Type
Filesystem Flags
1
0.031
2953.125 primary
ntfs
3
2953.125
3133.265 primary
linux-swap
2
3133.266
5633.085 primary
ext3
4
5633.086
9787.148 extended
5
5633.117
6633.210 logical
6
6633.242
9787.148 logical
ext3
(parted) help resize
resize MINOR START END
resize filesystem on partition MINOR
MINOR is the partition number used by Linux. On msdos disk labels, the
primary partitions number from 1-4, and logical partitions are 5
onwards.
START and END are in megabytes
(parted) resize 2 3133.266 4000.000

! !
( ), , . 2 30 .

, linux-.
Gentoo: . chroot, :
26. chroot
# env -i HOME=$HOME TERM=$TERM chroot /mnt/gentoo /bin/bash
# /usr/sbin/env-update
# source /etc/profile

75


Gentoo/x86

1.
2.
3.
4.

1.
2.
3.
4.

.................................................................................................................................
..............................................................................................................
.................................................................................................................
/ ...........................................................................................................
4.1. ....................................................................................

76
76
79
80
80

: http://www.gentoo.org/doc/ru/gentoo-x86-tipsntricks.xml
: 1.0

1. 1.

Gentoo/x86. , , .

2. 2.
RAID

RAID, , Software-RAID-HOWTO (.).


RAID LVM2 x86 (.).

76

Gentoo/x86
CD, RAID. , RAID-1:
1. RAID-1
# modprobe raid1

, , fd (Linux raid autodetect), 83 (Linux


native). , t fdisk.
, RAID, :
2.
# mknod
# mknod /dev/md2 b 9 2
# mknod /dev/md3 b 9 3d /dev/md1 b 9 1

, /etc/mdadm.conf (, , CD),
mdadm, RAID. , (RAID-1)
boot, swap root, /dev/sda /dev/sdb, :
3. raid mdadm
# mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
# mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
# mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3

(striping),
RAID-0 or RAID-5.

Linux Software RAID . /proc/


mdstat. , ..
4.
# mdadm --detail --scan > /etc/mdadm.conf

/dev/md1 , /dev/md2 /dev/


md3 .
(chroot), /etc/mdadm.conf /mnt/gentoo/etc.
, RAID ,
.
, mdadm. , CD, Gentoo raid.
MBR , .
ATA RAID c 2.4

77

Gentoo/x86
, CD doataraid. , /dev/ataraid. disc* , ATA RAID. disc, part*.
/dev/ataraid/disc*/*, Gentoo.
/dev/hda, .
, /dev :
5. /dev
# mount -o bind /dev /mnt/gentoo/dev

ATA RAID . , ATA RAID Promise FastTrack built-in RAID


Promise FastTrack Options.
GRUB GRUB. ,
. GRUB , , GRUB
MBR, :
6. GRUB
# cd /boot/grub
# dd if=stage1 of=/dev/fd0 bs=512 count=1
# dd if=stage2 of=/dev/fd0 bs=512 seek=1

grub.conf. ,
, root= ATA RAID.
, GRUB. GRUB. GRUB ATA RAID:
7. GRUB ATA RAID
grub> root (hd0,x)
grub> setup (hd0)
grub> quit

( GRUB ).
LILO .
CD
, - . Gentoo ,
(Alt-F2) ROOT, , (passwd root).
:
8. CD
(${KN}
cdimage ~#
cdimage ~#
cdimage ~#

, - 'gentoo' 'smp')
cp /mnt/cdrom/isolinux/${KN} /mnt/cdrom/isolinux/${KN}.gz /mnt/gentoo/boot
mkdir -p /mnt/gentoo/lib/modules
cp -Rp /lib/modules/`uname -r` /mnt/gentoo/lib/modules

78

Gentoo/x86
, hotplug (emerge hotplug) .
( CD) , (chroot):
9. modules.conf
# cat /proc/modules | cut -d ' ' -f 1 >> \
/etc/modules.autoload.d/kernel-`uname -r | cut -d . -f -2`
# modules-update

3. 3.

, . , , .
, .
. screen. LiveCD,
root screen:

screen LiveCD. , ,
.

10. screen
# screen -S gentoo

screen . , Ctrl-a, d
( control a , d), screen. .
, root
screen:
11. screen
# screen -x gentoo

screen, .
, , (, ./
scripts/bootstrap.sh), nohup, ,
. "&", !
, ( pwd ), .
12. nohup
# pwd
/usr/portage
# nohup ./scripts/bootstrap.sh &

79

Gentoo/x86
(exit) CD. .
, root ( CD) chroot
, :
13. Chroot
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
# cd /usr/portage

less nohup.out, . , less nohup.out F, . ,


.
, Ctrl-C, q. less,
.

4. 4. /

, (
..), -c ext2 ext3
( mke2fs). , .
, -c, /.
14.
# mke2fs -j -c /dev/hda3

4.1.
- Gentoo ,
. , , ,
( , , ), .
, Gentoo Linux chroot. , , . , /mnt/gentoo.
, make.conf , ?
Gentoo Linux, , , , -. , , ,
- .

80

Gentoo/x86
, , grub.conf, ,
/boot/grub/grub.conf.
, , , , . ,
.
:
make.conf, , make.conf
/boot/grub/grub.conf, ,
grub.conf
, , (, /boot!),

/etc/fstab,
, . .

81

Gentoo

1. .......................................................................................................................................
2. .................................................................................................................
3. ..........................................................................................
3.1. ..................................................................................................................
3.2. ................................................................................................
3.3. ...............................................................................................................
3.4. Gentoo ..............................................................................................................
3.5. ........................................................................................................................
3.6. .............................................................................................
3.7. .........................................................................................................
3.8. UNICODE ...................................................................................................
3.9. Gentoo ..................................................................................................................
4. .......................................................................................................
4.1. .........................................................................................................
4.2. ........................................................................................................

82
82
83
83
83
84
85
86
86
87
87
88
88
88
89

: http://ru.gentoo-wiki.com
: Molin
: 1.4

1.
Gentoo ,
.

2.
:

82

Gentoo
1.

2.

3.

, - ...
... LiveCD Linux, :
1.

Gentoo 2007.0 InstallCD

2.

Mandriva Linux One 2008

3.

Cool Linux CD

4.

Debian Live

CD (DVD, USB-drive), , .
... . , Gentoo /dev/sda.

3.
3.1.
1.
# fdisk /dev/sda

(. )

2.
# mkfs -t <_> /dev/sda<_>

..

3.2.
3.

83

Gentoo
# mount /dev/sda<_> /mnt/gentoo/<>

..
4. gentoo
# cd /mnt/gentoo

5.
# wget <>/gentoo/releases/<>/current/stages/stage3-<>-2007.0.tar.bz2

6.
# wget <>/gentoo/snapshots/portage-latest.tar.bz2

7.
# tar xvjpf stage3-i686-2007.0.tar.bz2

8.
# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

3.3.
9. Gentoo
1. : /mnt/gentoo/etc/make.conf
# . make.conf.example
CFLAGS="-O<_> -march=<_> -pipe"
CXXFLAGS="${CFLAGS}"
#
CHOST="<>"
MAKEOPTS="-j<-_+1>"
GENTOO_MIRRORS="http://distro.ibiblio.org/pub/linux/distributions/gentoo/ "
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
# Xorg
INPUT_DEVICES="keyboard mouse"
# Xorg
VIDEO_CARDS="<_>"
# . /mnt/gentoo/usr/portage/profiles/use.desc
# . /mnt/gentoo/usr/portage/profiles/use.local.desc
USE="<>"

10. DNS
2. : /mnt/gentoo/etc/resolv.conf
nameserver <IP__DNS>
nameserver <IP____DNS>

DNS-
# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

11.

84

Gentoo
3. : /mnt/gentoo/etc/fstab
/dev/sda1
/dev/sda<_>
/dev/sda<_>
proc

/
none
<>
/proc

<_>
swap
<_>
proc

defaults
sw
defaults
defaults

0
0
0
0

1
2
2
0

# /tmp
none

/tmp

tmpfs

defaults

0 0

# CD/DVD
# mod CD/DVD
/dev/hd<X> /mnt/cdrom
auto user,ro,noauto,uid=1000,gid=1000,mode=100644
# DVD-RAM
/dev/hd<X> /mnt/dvdram auto user,rw,noauto

0 0

0 0

# -
/dev/fd0
/mnt/floppy auto user,iocharset=cp1251,noauto,rw,noexec,showexec

12.
4. : /mnt/gentoo/etc/conf.d/hostname
HOSTNAME="<_>"

13.
5. : /mnt/gentoo/etc/conf.d/net
# ...
config_eth0=( " 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255" )
routes_eth0=( "default gw 192.168.0.1" )
# ...
config_eth0=( "dhcp" )
dhcp_eth0="nodns nontp nonis"

3.4. Gentoo
14. /proc
# mount -t proc none /mnt/gentoo/proc

15. /dev
# mount -o bind /dev /mnt/gentoo/dev

16.
# chroot /mnt/gentoo /bin/bash

Gentoo

17.

85

0 0

Gentoo
# env-update
# source /etc/profile

18.
# export PS1="(chroot) $PS1"

3.5.
19.
# emerge --sync# emerge-webrsync

20. Gentoo
# USE="-doc symlink" emerge gentoo-sources

21. Gentoo
# cd /usr/src/linux# make menuconfig

(. )

22.
# make && make modules_install

23.
# cp arch/i386/boot/bzImage /boot/linux-<>-gentoo

3.6.
24.
# rc-update add net.eth0 default

25.
# passwd

26.
# emerge syslog-ng
# rc-update add syslog-ng default

27. ( )
# emerge vixie-cron
# rc-update add vixie-cron default

28. DHCP ( )

86

Gentoo
# emerge dhcpcd

29. PPPoE ( )
# USE="-X" emerge rp-pppoe

3.7.
30. LILO
# emerge lilo

31. LILO
6. : /etc/lilo.conf
boot=/dev/sda
prompt
timeout=200
default=gentoo
image=/boot/linux-<>-gentoo
label=gentoo
read-only
root=/dev/sda<X>

32. LILO
# /sbin/lilo

3.8. UNICODE
33.
# emerge terminus-font intlfonts freefonts cronyx-fonts corefonts artwiz-fonts kbd

34.
7. : /etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
ru_RU.CP1251 CP1251
ru_RU.KOI8-R KOI8-R
ru_RU.UTF-8 UTF-8

35. glibc
# emerge -av glibc

36.
# locale-gen

37.

87

Gentoo
8. : /etc/env.d/02locale
LC_ALL=""
LANG="ru_RU.UTF-8"
LC_NUMERIC="C"

38. rc.conf
9. : /etc/rc.conf
UNICODE="yes"

39.
10. : /etc/conf.d/consolefont
CONSOLEFONT="Cyr_a8x16"

40.
11. : /etc/conf.d/keymaps
KEYMAP="-u ru4"
SET_WINDOWKEYS="yes"
EXTENDED_KEYMAPS=""
DUMPKEYS_CHARSET="koi8-r"

3.9. Gentoo
41. Gentoo
# exit

42.
# cd /
# umount /mnt/gentoo/<>
..

43.
# reboot

Gentoo ! . .

4.
4.1.

88

Gentoo

/boot

~30

100-200% ,

)
/

/bin, /etc, /lib, / 0,1-0,5

sbin /sys

ext2, ext3, ReiserFS


(swap-

ext2, ext3, ReiserFS,


XFS

/var

0,5, ext3, ReiserFS, XFS


Gentoo -- 2-4,
.. portage


/var/tmp

/tmp

0,5-2 ( , ext2, JFS, XFS tmpfs



)

/usr

1-10 ( - ext2,
)

XFS ,JFS

/opt

0,1 ( ext2, ReiserFS, XFS,


-
JFS
)

- /home

ReiserFS,

ext3, ReiserFS, XFS,


JFS

/mnt/fat, /mnt/win
Windows
..

FAT32

Windows

NTFS

4.2.
.

Processor type and features --->
Processor family ( ) --->

Processor type and features --->
[*] Paravirtualization support (EXPERIMENTAL)
(KVM)
Device Drivers --->
Virtualization --->
<*> Kernel-based Virtual Machine (KVM) support
SATA
Device Drivers --->
<*> Serial ATA (prod) and Parallel ATA (experimental) drivers
<*>
AHCI SATA support
SATA
PPP
Device Drivers --->
Networking device support --->
<*> PPP (point-to-point protocol) support
<*>
PPP support for async serial ports

89

--->

Gentoo
<*>
PPP support for sync tty ports
PCI-Express
Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->
[*]
PCI Express support
DRM
Device Drivers --->
Character devices --->
<*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)

Device Drivers --->
Graphics support --->
<*> Support for frame buffer devices

(ALSA)
Device Drivers --->
Sound --->
Advanced Linux Sound Architecture --->
<*> Advanced Linux Sound Architecture
<*>
OSS Mixer API
<*>
OSS PCM (digital audio) API
[*]
Verbose procfs contents

File systems --->

90


1. ......................................................................................................................................... 92
1.1. Gentoo, ? .......................................................... 92
1.2. Gentoo ? ............................................................................................ 92
2. ........................................................................................................................................ 92
2.1. , "-O9 -ffast-math -fomitframe-pointer". ? .................................................................................. 92
2.2. root ( )? ............................................ 92
2.3. ? ................................................................................. 92
2.4. root su? ...................................... 93
2.5. devfs? .......................................................................................................... 93
3. ........................................................................................................................................ 93
3.1. Gentoo ? ................................................................. 93
3.2. (), ? ................................................... 93
3.3. - , ? ................................................... 94
3.4. ISO -? ............................................................................ 94
3.5. / ? .............................................. 95
3.6. . ? ......................... 95
3.7. Windows GRUB LILO, . ? ............................................................................................................................... 95
3.8. Gentoo, Stage1 Stage2? ................................................ 96
4. ...................................................................................................................... 96
4.1. ? ..................................................................................... 96
4.2. ./configure . ? .......................................... 97
4.3. emerge, ? .................................................. 97
4.4. , rsync ? ............................................................................. 97
4.5. .
, ? ............................................................... 97
4.6. /usr/portage/distfiles. ? .................. 97
4.7. /var/tmp/portage? /var/tmp/
portage? ........................................................................................................................... 97
5. ................................................................................................................................ 98
5.1. ? ..................................................... 98
5.2. DNS . .............................................. 98
5.3. crontab? ................................. 98
5.4. numlock ? .................................................................................. 98
5.5. ? ....................................................................... 98
5.6. X - root' ( su) ............................................... 98
6. ............................................................................................................................... 99
6.1. ReiserFS , .. ................................................ 99
7. ...................................................................................................................................... 99
7.1. ? ................................................................................ 99
7.2. ? ............................................................ 99
7.3. . ? ........................ 99

91


8. .......................................................................................................................................... 99
8.1. Gentoo Linux? ............................................................................. 99
8.2. CD Gentoo Linux? ................................................................................ 99
8.3. . ? ....................................................... 100

1.
1.1.

Gentoo, ?
Gentoo () , - "gentoo" (-). Pygoscelis papua. Gentoo
() (Islas Malvinas). - Gentoo "".

1.2.

Gentoo ?
Gentoo BSD , Portage (.). Portage
, Gentoo. ( USE-), , ,
( "") , , , .
Gentoo ,
. , , . Gentoo , , .
Gentoo . : , ,
Portage, .

2.
2.1.

, "-O9 -ffast-math -fomit-framepointer". ?


- , -O3 ..
gcc.
, , .
CFLAGS -O2 -march=<your_arch>
.

2.2.

root ( )?
passwd, , . root,
passwd username. : man passwd.

2.3.

?
adduser username "username". ,
, , , :

92


1. useradd
# useradd -m -G users,audio,wheel username

"username". audio audio . wheel wheel, su,


.
2.4.

root su?
, su,
wheel. wheel, - root:
2. wheel
# gpasswd -a username wheel

2.5.

devfs?
Gentoo devfs, udev, /dev.
2.6, , udev. udev udev.
/dev, RC_DEVICES="static" /etc/
conf.d/rc.

3.
3.1.

Gentoo ?
, . Gentoo 1.4
glibc-2.3.x. , emerge --sync && emerge -uDN world,
(latest Gentoo). Gentoo .
Gentoo.

3.2.

(), ?
,
. , Gentoo /dev/hda1 ( /
boot) /dev/hda3 ( /) /dev/hda2:

93


3.
CD

:
# mount /dev/hda3 /mnt/gentoo
# mount /dev/hda1 /mnt/gentoo/boot
# swapon /dev/hda2
# mount -t proc none /mnt/gentoo/proc
chroot
:
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
# cd /usr/src/linux
# make menuconfig
/ /

:
# make && make modules_install
bzImage :
# cp arch/i386/boot/bzImage /boot/<kernel_name>
LILO, lilo; GRUB :
# /sbin/lilo
chroot .
# exit
# umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
# reboot

, ; , / (
).
3.3.

- , ?
Portage , /etc/make.conf:
4. /etc/make.conf
HTTP_PROXY="http://username:password@yourproxybox.org:portnumber"
FTP_PROXY="ftp://username:password@yourproxybox.org:portnumber"
RSYNC_PROXY="rsync://username:password@yourproxybox.server:portnumber"

3.4.

ISO -?
raw-.
CD, CD.
CD; .
:

EasyCD Creator, File, Record CD from CD image.


ISO image file. ISO- Open. Start recording, ISO
.
Nero Burning ROM, , , Burn Image File. Open.
Burn CD.

94


cdrecord, cdrecord dev=/dev/hdc ( /dev/hdc CDRW ), ISO :)
K3B, Tools > CD > Burn CD Image. ISO ,
'Image to Burn'. , Start.
Mac OS X Panther, Disk Utility Applications/Utilities, Open
Images, Burn Images.
Mac OS X Jaguar, Disk Copy Applications/Utilities, Burn Image
File, ISO Burn.
3.5.

/ ?
, . , Pentium-M.
, . , :-).
, "" CD/stage, , i686 x86 ( ). ,
, , .
, ,
Gentoo. -march, gcc guide.

3.6.

. ?
, . ifconfig
-a, eth0 wlan0 ( ). , , . , , /etc/modules.autoload.d/kernel-2.6 ( kernel-2.4,
2.4).
, (
).
, DHCP,
dhcpd (emerge dhcpcd). CD,
dhcpcd.
, , CD, .

3.7.

Windows GRUB LILO, . ?


. Windows / ,
. , ,
, "" Windows, "" .
, Gentoo hda ( ), Windows hdb
(). .

95


5. Windows grub.conf
title Windows XP
map (hd1) (hd0)
map (hd0) (hd1)
rootnoverify (hd1,0)
chainloader +1

6. Windows lilo.conf
other=/dev/hdb1
label=WindowsXP
table=/dev/hdb
map-drive = 0x80
to = 0x81
map-drive = 0x81
to = 0x80

Windows , , . GRUB man lilo.conf,


, .
3.8.

Gentoo, Stage1 Stage2?


Gentoo , , stage3. ,
stage1 stage2. ( Release Engineering stage1, stage3), : stage3 . .
(bootstrapping) ( )
, , .
, stage3. ,
bootstrap.sh , :
7.
# cd /usr/portage/scripts
# vi bootstrap.sh
# ./bootstrap.sh

(
). .. stage3 :
8.
# emerge -e system

. GRP .

4.
4.1.

96


"". Gentoo , , , . , () (snapshots).
Gentoo Ebuild HOWTO (.) ebuild .
ISO-, .tbz2 , .tar.bz2 , . (,
) .
RPM ( Redhat package manager) Gentoo,
RPM .
4.2.

./configure . ?
, , . .. ,
Portage, ebuld-, , ,
ebuild- Portage ( ). , . , . Ebuild HOWTO (.).

4.3.

emerge, ?
proxy, rsync, .

4.4.

, rsync ?
, rsync , emerge-webrsync, Portage HTTP.
proxy , ,
Portage -.

4.5.

. ,
?
. emerge --pretend package, , . , , emerge -fp
package. , . /usr/
portage/distfiles/, emerge package. : .

4.6.

/usr/portage/distfiles. ?
.
; ebuild
. ,
, , . , , ,
. , , . .

4.7.

/var/tmp/portage? /var/tmp/portage?
, Gentoo /var/tmp/portage. , .
, emerge . , pgrep emerge
.

97

5.
5.1.

?
KEYMAP /etc/conf.d/keymaps. , CONSOLETRANSLATION CONSOLEFONT /etc/conf.d/consolefont (
(.).
(reboot), keymaps consolefont:
9. keymaps
# /etc/init.d/keymaps restart
# /etc/init.d/consolefont restart

5.2.

DNS .
/etc/resolv.conf ; chmod, :
10. /etc/resolv.conf
# chmod 0644 /etc/resolv.conf

5.3.

crontab?
cron.

5.4.

numlock ?
,
rc-update add numlock default &&/etc/init.d/numlock start.
GUI ; .

5.5.

?
clear ~/.bash_logout:
11.
$ echo clear >> ~/.bash_logout

, ,
/etc/skel/.bash_logout:
12.
# echo clear >> /etc/skel/.bash_logout

5.6.

X - root' ( su)
, . ,
startx, . Gentoo's PAM, :
/etc/profile.

98


13. XAUTHORITY
export XAUTHORITY="${HOME}/.Xauthority"

6.
6.1.

ReiserFS , ..
ReiserFS , Gentoo reiserfsck --rebuild-tree .
, -
.

7.
7.1.

?
Bugzilla. ,
#gentoo IRC FreeNode

7.2.

?
Gentoo .
, // ISO , Release Engineering Project (.). gentoo-announce. .

7.3.

. ?
, setterm:
14. setterm
# setterm -blength 0

, , /etc/
conf.d/local.start. , . , :
15. setterm (bis)
# setterm -blength 0 >/dev/vc/1

/dev/vc/1 , .

8.
8.1.

Gentoo Linux?
Gentoo http://www.gentoo.org/doc/ru/.

8.2.

CD Gentoo Linux?
Gentoo.
, . , , .

99


Gentoo Linux.
8.3.

. ?
, , , Google
Gentoo. Gentoo,
"lists.gentoo.org --" . , Gentoo, irc : #gentoo on irc.freenode.net.

http://forums.gentoo.org, , , . .

100

1. ................................................................................................................................... 101
2. ............................................................................................................................ 101
2.1. ? ................................................................................................... 101
2.2. ? ......................................................................................................... 102
2.3. Gentoo Way ........................................................................................................................ 102
2.4. root ? ........................................................................................ 103
3. ........................................................................................................................... 103
3.1. ............................................................................................................ 103
3.2. ? .......................................................... 105
3.3. ?
................................................................................................................................................... 105
4. X Window ................................................................................................. 106
4.1. ? ................................................................................................ 106
4.2. ? ..................................................................... 106

1.
Windows Linux .
, .
. .:
Gentoo ,

2.
2.1. ?
.
. RedHat, Mandrake,

101


Fedore Core, ASP Linux, ALT Linux, Debian . Gentoo Linux *BSD.
Gentoo Linux : emerge emerge
, . ,
.
: Gentoo ( ) : emerge --usepkg --getbinpkg : emerge -gk .
.

2.2. ?
( tar.gz, tar.
bz2, tbz2, tgz, ). ,
: tar -xvjf super_proga_0.1.tar.bz2 tar.bz2
( tbz2) tar -xvzf super_proga_0.1.tar.gz tar.gz (tgz).
.
-v . :) Dron
, tar zxvf, bz gz2 jxvf, , j
. =) das
xzf eXtract Zipped File. j bzip2 wt
INSTALL README, : ./configure make. root: make install
Gentoo .

2.3. Gentoo Way


, , , portage. , Gentoo.
, : emerge -s [ ]
: emerge -S [ ] ,
, esearch: emerge esearch eupdatedb
esearch [ ] esearch -S [ ]
. esearch -F mail-client ,
. .
GUI , Porthole (
GTK). KDE Kentoo ( ) Guitoo.
ebuild',
Portage_Overlay.
ebuild , ,
. skel.ebuild'
portage. en:HOWTO Create an Updated Ebuild.

102


ebuild abeni.

2.4. root ?
Windows, root . Windows, root
. , , . , root , . :
.
su. su
[user@gentoo user]$ su
Password:
[root@gentoo user]#

user wheel. .
sudo. , :
$ emerge sudo

su , , , - . :) , root,
. , , sudo
root . ;)
sudo /etc/sudoers.
:
$ sudo

(, sudo ls -l). , root,


:
$ sudo -s

, root ,
$ exit

3.
3.1.
100% , Linux .
100 , , ,

103


. , , ,
.

3.1.1. man
Linux . , man. man whereis whereis, man fstab
/etc/fstab.
, /usr/share/doc ( Gentoo Linux
/usr/doc). .

3.1.2. cd
. . : cd /home/vasya/katalog
, .
(/).
.
, /home/vasya, /home/vasya/katalog
cd katalog. , Linux , "".
, CD-, ..
( /mnt).
pwd.

3.1.3. ls
. , ls
. , , ls /etc.
. "-l" ls -l. ls , ,
, . ls -la "-a" (by morgoth)

3.1.4. cp
. , /home/vasya/katalog/
linux.txt /home/vasya. : cp /home/vasya/katalog/linux.txt /home/vasya.
linux.txt gentoo.txt? : cp /home/vasya/
katalog/linux.txt /home/vasya/gentoo.txt. cp . ,
. /home/vasya/katalog /tmp : cp -R /home/vasya/katalog /tmp. -R
. , : cp -R /home/vasya/katalog /tmp/novoe_imya. cp : -p. (, , suid, sgid).

104


-p, ( ).

3.1.5. rm
. , /home/vasya/katalog/linux.txt: rm /
home/vasya/katalog/linux.txt /home/vasya/katalog , : rm
linux.txt. , , DOS Windows.
/home/vasya/testdir rmdir /home/vasya/testdir. .
( ) rm -r /home/vasya/testdir.

3.1.6. df
df -h. -h
( 1K 234M 2G)

3.2.
?
. . (aka shell) . ? , cd home/vasya/katalog/vtoroi_katalog/ooooooooooooochendlinnoeimyakataloga. , . ;)
shell'. , .
Tab. : cd /h<TAB>/v<TAB>/k<TAB>/v<TAB>/o<TAB>
: Zsh
cd /h/v/k/v/o "Tab". . , , /home 2 /home/vasya /home/vika.
. ,
/home/va<TAB>, . ,
Tab . : ls /home/<TAB><TAB>
/home.

3.3.
?
. ssh
, . nohup. , xmms: nohup xmms. . xmms ,
;) : xmms & .
.

105


screen.

4. X Window
4.1. ?
X Window , Windows.
:

, , .
, OC Windows (Ctrl+C, Ctrl+V), , ,
Ctrl+C , , Ctrl+C, .
.
Ctrl+Insert Shift+Insert
.

4.2. ?
default. : rc-update
add xfs default rc-update add xdm default.
, . ,
xdm /etc/rc.conf.
1. : /etc/rc.conf
..
DISPLAYMANAGER="kdm"
..

xdm kdm.
2. : /etc/rc.conf
..
DISPLAYMANAGER="gdm"
..

xdm gdm .

106


Gentoo Linux x86

1. Gentoo .........................................................................................................................
1.1. Gentoo Linux ................................................................................................
1.2. ...................................................................
1.3. ..................................................................................................................
1.4. .............................................................................................................
1.5. Gentoo ............................................................................
1.6. Gentoo ....................................................................................
1.7. ..................................................................................................................
1.8. .........................................................................................
1.9. ...............................................................................
1.10. ....................................................................................
1.11. Gentoo ..........................................................................................
1.12. ? ......................................................................................................
2. Gentoo ............................................................................................................................
2.1. Portage .............................................................................................................
2.2. USE- ..........................................................................................................................
2.3. Portage .........................................................................................................
2.4. ..................................................................................................
2.5. .............................................................................................................
3. Portage ............................................................................................................................
3.1. ..............................................................................................................
3.2. ...................................................................................
3.3. ....................................................................
3.4. Portage ......................................................................................
3.5. ................................................................................
3.6. ebuild .........................................................................................................
4. Gentoo ..............................................................................................................
4.1. ..........................................................................................................
4.2. .....................................................................................................
4.3. ...............................................................................................
4.4. ..............................................................................................................
4.5. ...........................................................................................
4.6. ..............................................................................................................
: http://www.gentoo.org/doc/ru/handbook/handbook-x86.xml
: 1.0

107

110
110
112
119
126
134
140
145
151
156
159
166
167
168
168
176
181
184
193
197
197
200
203
205
207
209
212
212
214
216
222
229
231

Gentoo Linux x86


:
Gentoo
, Gentoo .
Gentoo Linux
.

Gentoo -. , Gentoo
. .

, .
.

Gentoo, . ,
.
Gentoo
Gentoo (stage3). ,
Portage.
Gentoo

Gentoo. , .

Linux . , .

. , .

, Gentoo .
.

x86 . -.
.
Gentoo
. ( )
. , .
?

108

Gentoo Linux x86


Gentoo. ?
Gentoo
Gentoo: , , Portage ..
Portage
,
.
USE-
USE- ( ) Gentoo. ,
, USE- .
Portage
Portage: ,
.

Gentoo (initscript), , ,
, , .
, , .

Gentoo . ,
, .
Portage
Portage, Gentoo.

Portage, , .

Portage , .

Gentoo
. , ,
.
Portage
Portage ,
Gentoo. dispatch-conf
.

109

Gentoo Linux x86


Portage, , , ..
ebuild
, Portage ,
ebuild.
Gentoo
Gentoo.


.

, .

Gentoo :
DHCP, , , (VLAN) ..

. , .

, .

, .

1. Gentoo
1.1. Gentoo Linux
1.1.1.
1.1.1.1. !
, Gentoo!
! Gentoo . Gentoo : , Gentoo,
..

110

Gentoo Linux x86


Gentoo , . Gentoo
, , .
Portage, Gentoo, Python, . Gentoo (
), Gentoo .
!
, Gentoo .
. , .
1.1.1.2. ?
Gentoo 10 ,
211. :
1.

1: , Gentoo;

2.

2: Gentoo;

3.

3: Gentoo;

4.

4: , (chroot)
;

5.

5: , Gentoo;

6.

6: Linux;

7.

7: Gentoo;

8.

8: ( );

9.

9: ,
Gentoo;

10. 10: Gentoo Linux!


, , . : .
:. , . , .
. :,
Gentoo. , . , ,
.
1.1.1.3. ?
Gentoo . -, , CD (, Knoppix), , ..

111

Gentoo Linux x86


Gentoo, , ,
(netboot). ,
. , ,
Gentoo 2006.1 (.), .
GRP (Gentoo Reference Platform Gentoo,
, Gentoo),
, Gentoo 2006.1 (.).
,
. Gentoo. , ,
(. ), , , .
,
, Gentoo . ,
, , .
1.1.1.4. ?
( ),
(.) , .
, , . ,
() .
, , , , , . ,
Gentoo ( , ). ,
.
, (- , ), (- , /), , #gentoo ( #gentoo-amd64,
#gentoo-ru, #rugentoo) irc.freenode.net. , :)
, Gentoo,
(FAQ), Gentoo. FAQ (.) . , #gentoo, IRC- irc.freenode.net. , - , IRC :-)

1.2.
1.2.1.
1.2.1.1.
, , Gentoo
.

112

Gentoo Linux x86

1.2.1.2.

i486

64

1.5 ( )

256

1.2.2. - Gentoo
1.2.2.1.
- Gentoo ,
Gentoo. Linux -. . Gentoo.
- , ,
Gentoo . -, Gentoo
.
Gentoo , , , , Gentoo 2006.0 (.).
-:
Gentoo, - , ,
Gentoo.
Gentoo, Gentoo.
, , , , .
, ,
.
1.2.2.2. Gentoo
install-x86-minimal-2006.0.iso 49 .
Gentoo .

113

Gentoo Linux x86


stage3, Portage,
,

1.2.2.3. (live) Gentoo


install-x86-universal-2006.0.iso 697 .
Gentoo , ,
Gentoo
:)
Gentoo

, ;

1.2.2.4. Stage3
stage3 , Gentoo,
Gentoo , (
: () .
- Gentoo
. , Gentoo
stage1 stage2, stage3.
Gentoo stage1 stage2, ,
Gentoo, Gentoo, Stage1 Stage2?
stage3 releases/x86/2007.0/stages/
Gentoo; .

1.2.3. ,
Gentoo

, Gentoo. ,
-. , ?
( , )
. releases/x86/2007.0/installcd.
ISO-. -,
CD-R.

114

Gentoo Linux x86


, , MD5 (, install-x86-minimal-2007.0.iso.DIGESTS).
MD5 md5sum Linux/Unix, md5sum (.) Windows.
GnuPG , ( .asc). ,
:
1.
$ gpg --keyserver subkeys.pgp.net --recv-keys 17072058

:
2.
$ gpg --verify < > < >

ISO- - . ,
. cdrecord K3B. .
cdrecord, cdrecord dev=/dev/hdc < iso-> (/dev/hdc
CD-RW).
K3B, Tools CD Burn Image ( - ). 'Image to Burn' (' ') ISO-.
Start ().

1.2.4. -

, , , , , .

-, . -
CD, BIOS. BIOS,
DEL, F1 ESC. BIOS , CD-ROM
. CMOS Setup.
, , CD-ROM.
CD-ROM (-!) . . ENTER, , -: , , ENTER.
? , - .
gentoo. ; -nofb
.
:

115

Gentoo Linux x86

gentoo

2.6 (
)

gentoo-nofb

gentoo,

memtest86

, . , F2 .
3: ,
3. ,
-

agpgart
acpi=on
ide=nodma
doscsi
dopcmcia
nofirewire

agpgart ( , )
ACPI
DMA IDE-
scsi- ( ethernet-)
pcmcia PCMCIA- -
initrd firewire (
- firewire ..)
nokeymap

docache
- ,
/mnt/cdrom
nodetect
hwsetup/kudzu hotplug
nousb
usb initrd, hotplug
nodhcp
dhcp

nohotplug
hotplug
noapic
apic (,
scsi, ..)
noevms
EVMS2
nolvm2
LVM2
hdx=stroke
, BIOS

noload=module1,[module2,[...]]

-, (
gentoo) . , gentoo
dopcmcia:
4.
boot: gentoo dopcmcia

. Gentoo , ALT+F1, , . 10 , ( ), .
Gentoo Linux root (). root (#).
, ALT+F2, ALT+F3 ALT+F4.
ALT+F1.
.

116

Gentoo Linux x86

1.2.5.
-
.
. , . - PCI,
.
8139too ( ):
5.
# modprobe 8139too

PCMCIA, pcmcia:
6. PCMCIA
# /etc/init.d/pcmcia start

:
, ,
IDE hdparm. -tT,
( ):
7.
# hdparm -tT /dev/hda

(
), /dev/hda:
8.
DMA:
# hdparm -d 1 /dev/hda
:
# hdparm -d 1 -A 1 -m 16 -u 1 -a 64 /dev/hda

1.2.6. :
, irssi
( ),
.
passwd:
9.
# passwd
New password: ( )
Re-enter password: ( )

117

Gentoo Linux x86


, .
useradd passwd. john:
10.
# useradd -m -G users john
# passwd john
New password: ( john)
Re-enter password: ( )

(root) su:
11.
# su - john

1.2.7. :

Gentoo ( ,
-), , (. : ). ALT+F2 ,
.
c -, links:
12. -
# links /mnt/cdrom/docs/html/index.html

Gentoo ( , -).
links, ( ,
):
13. ,
# links http://www.gentoo.org/doc/ru/handbook/handbook-x86.xml

ALT+F1.

1.2.8. : SSH
Gentoo
( , ),
, , (
, ).
SSH, :
14. SSH
# /etc/init.d/sshd start

118

Gentoo Linux x86


sshd, . .

1.3.
1.3.1.
1.3.1.1. , ?
Ethernet, DHCP, , . ,
, -, , ssh, scp, ping,
irssi, wget links.
, /sbin/ifconfig lo, , eth0:
15. /sbin/ifconfig
# /sbin/ifconfig
(...)
eth0
Link encap:Ethernet HWaddr 00:50:BA:8F:61:7A
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::50:ba8f:617a/10 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1498792 errors:0 dropped:0 overruns:0 frame:0
TX packets:1284980 errors:0 dropped:0 overruns:0 carrier:0
collisions:1984 txqueuelen:100
RX bytes:485691215 (463.1 Mb) TX bytes:123951388 (118.2 Mb)
Interrupt:11 Base address:0xe800

1.3.1.2. : -
-,
. - : , .
-. , , - proxy.gentoo.org, 8080:
16. -
( - HTTP)
# export http_proxy="http://proxy.gentoo.org:8080"
( - FTP)
# export ftp_proxy="ftp://proxy.gentoo.org:8080"
( - RSYNC)
# export RSYNC_PROXY="proxy.gentoo.org:8080"

- , :

119

Gentoo Linux x86


17. / -
http://_:@proxy.gentoo.org:8080

1.3.1.3.
DNS- (
/etc/resolv.conf), -, ,
, DNS ..
18.
# ping -c 3 google.com

? , .
, , , .

1.3.2.
, net-setup (
), pppoe-setup ( ADSL) pptp (
PPTP; x86, amd64, alpha, ppc ppc64).
, , :
1.

Ethernet : netsetup;

2.

ADSL : RP-PPPoE;

3.

PPTP : PPTP;

1.3.2.1. : net-setup
, net-setup:
19. net-setup
# net-setup eth0

net-setup .
. , .
, Gentoo.
.
, .
1.3.2.2. : RP-PPPoE
PPPoE, ( ) rppppoe. pppoe-setup, .

120

Gentoo Linux x86


ethernet, adsl-, ,
, IP- DNS. ,
(firewall).
20. rp-pppoe
# pppoe-setup
# pppoe-start

- , , ,
/etc/ppp/pap-secrets /etc/ppp/chap-secrets, , ethernet .
, .
, .
, .
1.3.2.3. : PPTP

PPTP x86.

PPTP, pptpclient, . . /etc/


ppp/pap-secrets /etc/ppp/chap-secrets ,
.
21. /etc/ppp/chap-secrets
# nano -w /etc/ppp/chap-secrets

, , PPTP /etc/ppp/options.pptp:
22. /etc/ppp/options.pptp
# nano -w /etc/ppp/options.pptp

, pptp ( ,
options.pptp), :
23.
# pptp <server ip>

1.3.3.
1.3.3.1.
() . -

121

Gentoo Linux x86


. ,
.
net-setup pppoe-setup , ,
. .
, , ls:
24.
# ls /lib/modules/`uname -r`/kernel/drivers/net

, modprobe:
25. modprobe
( pcnet32)
# modprobe pcnet32

, , ifconfig.
, :
26. ()
# ifconfig eth0
eth0
Link encap:Ethernet HWaddr FE:FD:00:00:00:00
BROADCAST NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

, , :
27. ()
# ifconfig eth0
eth0: error fetching interface information: Device not found

, eth0, eth1 .. , , , ,
. , eth0.
, net-setup pppoe-setup
( ), , , ,
.
, :
1.

DHCP IP-;

2.

, ;

3.

: , ;

4.

ifconfig route: ;

122

Gentoo Linux x86

1.3.3.2. DHCP
DHCP (Dynamic Host Configuration Protocol ) (IP-, , , , . .) , DHCP
( DHCP). , dhcpcd:
28. dhcpcd
# dhcpcd eth0
,
, DHCP.

# dhcpcd -HD eth0

( - , , Google),
, . .
1.3.3.3.

iwconfig x86, amd64 ppc.


, linux-wlan-ng
(.).

(802.11),
.
iwconfig. iwconfig :
29.
# iwconfig eth0
eth0
IEEE 802.11-DS ESSID:"GentooNode"
Mode:Managed Frequency:2.442GHz Access Point: 00:09:5B:11:CC:F2
Bit Rate:11Mb/s
Tx-Power=20 dBm
Sensitivity=0/65535
Retry limit:16
RTS thr:off
Fragment thr:off
Power Management:off
Link Quality:25/10 Signal level:-51 dBm Noise level:-102 dBm
Rx invalid nwid:5901 Rx invalid crypt:0 Rx invalid frag:0 Tx
excessive retries:237 Invalid misc:350282 Missed beacon:84

wlan0 ra0, eth0.


iwconfig - .

: ESSID ( ) WEP. ESSID


, WEP, ,

123

Gentoo Linux x86


. ESSID WEP, :
30. ESSID / WEP
( "GentooNode")
# iwconfig eth0 essid GentooNode
( WEP)
# iwconfig eth0 key 1234123412341234abcd
( (ASCII); "s:")
# iwconfig eth0 key s:some-password

, iwconfig.
, , IP, ( ), net-setup,
.
1.3.3.4.

IP-, , , ifconfig route.

, , , . . , - ,
. , , ,
, , .
(, ) IP- ( ).
0 255. , , . , IP- 32 ( ). :
31. IP-
IP- ():
IP- ():

192.168.0.2
11000000 10101000 00000000 00000010
-------- -------- -------- -------192
168
0
2

IP- (. . ,
, IP-). , ,
IP- : .
, .
IP-, , . ,
IP-.
32. /
IP-:

192
168
0
2
11000000 10101000 00000000 00000010
: 11111111 11111111 11111111 00000000
255
255
255
0
+--------------------------+--------+

124

Gentoo Linux x86


, 192.168.0.14 , 192.168.1.2
.
IP- , ,
. IP-. .
33.
IP-:

192
168
0
2
11000000 10101000 00000000 00000010
11000000 10101000 00000000 11111111
:
192
168
0
255
+--------------------------+--------+

, ,
. . , IP-
(, 192.168.0.1).
, IP-.
( IP-), , (, dev.gentoo.org)
IP- (, 64.5.62.82). . ,
/etc/resolv.conf.
.
, .
, :

IP-

192.168.0.2

255.255.255.0

192.168.0.255

192.168.0.1

()

195.130.130.5, 195.130.130.133

1.3.3.5. ifconfig route


. IP- ifconfig.
, route. IP-
/etc/resolv.conf.
IP- IP-, . ,
, ${IP_ADDR} IP-, ${BROADCAST} , ${NETMASK} :
34. ifconfig
# ifconfig eth0 ${IP_ADDR} broadcast ${BROADCAST} netmask ${NETMASK} up

125

Gentoo Linux x86


route. IP-
${GATEWAY}:
35. route
# route add default gw ${GATEWAY}

/etc/resolv.conf ( nano):
36. /etc/resolv.conf
# nano -w /etc/resolv.conf

. ${NAMESERVER1}
${NAMESERVER2} :
37. /etc/resolv.conf
nameserver ${NAMESERVER1}
nameserver ${NAMESERVER2}

. , - (, Google).
, ! Gentoo.
.

1.4.
1.4.1.
1.4.1.1.
Gentoo Linux Linux ,
, . , ,
Gentoo Linux.
, . ,
, Linux IDE-, /dev/hda.
SCSI SATA, /dev/sda.
. , , :
IDE, SCSI - . ,
512- .
1.4.1.2.
Linux ,
.
, . x86 .

126

Gentoo Linux x86


: (primary), (extended) (logical).
, MBR (Master Boot Record
). MBR (512 ),
(, /dev/hda1 /dev/hda4).
( ,
), .
, , .
, . MBR,
.
1.4.1.3.
- 86 EVMS LVM2.
EVMS LVM2 . , , EVMS LVM2 .

1.4.2.
1.4.2.1.
, , :

dev/hda1

ext2

32

/dev/hda1

(swap)

512

/dev/hda3

ext3

, , , . ,
fdisk .
1.4.2.2. ?
. , , , , /home . Gentoo , /var, ..
. , , . /opt, . , /home:
. /usr: ,
, - , Portage,
, 500 .

127

Gentoo Linux x86


, . :
1.

2.

- , -

3.

, .. ( ) ;

4.

, read-only (
), nosuid ( setuid), noexec ( ) ...

, :
, , .
, SCSI SATA 15 .
20 ,
( -, , Gnome ..):
38.
$ df -h
Filesystem
Type
Size
Used
Avail
Use% Mounted on
/dev/hda5
ext3
509M
132M
351M
28% /
/dev/hda2
ext3
5.0G
3.0G
1.8G
63% /home
/dev/hda7
ext3
7.9G
6.2G
1.3G
83% /usr
/dev/hda8
ext3
1011M
483M
477M
51% /opt
/dev/hda9
ext3
2.0G
607M
1.3G
32% /var
/dev/hda1
ext2
51M
17M
31M
36% /boot
/dev/hda6
swap
516M
12M
504M
2% <not mounted>
( : 2 )

/usr, , ( 83%), , /usr


. /var
, , Portage . /var , , 1,
PORTAGE_TMPDIR /etc/make.conf, ,
, OpenOffice.

1.4.3. fdisk
, ,
, :

/dev/hda1

/dev/hda2

/dev/hda3

128

Gentoo Linux x86


.
1.4.3.1.
fdisk . fdisk,
( /dev/hda):
39. fdisk
# fdisk /dev/hda

fdisk :
40. fdisk
Command (m for help):

p, :
41.
Command (m for help): p
Disk /dev/hda: 240 heads, 63 sectors, 2184 cylinders
Units = cylinders of 15120 * 512 bytes
Device Boot
/dev/hda1
/dev/hda2
/dev/hda3
/dev/hda4
/dev/hda5
/dev/hda6
/dev/hda7
/dev/hda8
/dev/hda9

Start

End
1
15
50
71
71
210
349
627
905

14
49
70
2184
209
348
626
904
2184

Blocks
Id
105808+
264600
158760
15981840
1050808+
1050808+
2101648+
2101648+
9676768+

System
83 Linux
82 Linux swap
83 Linux
5 Extended
83 Linux
83 Linux
83 Linux
83 Linux
83 Linux

Command (m for help):

Linux ( System Linux)


( Linux swap).
1.4.3.2.
. d.
/dev/hda1:
42.
Command (m for help): d
Partition number (1-4): 1

. p,
, .
, q ENTER;
.

129

Gentoo Linux x86


, , p
, d , .
:
43.
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot

Start

End

Blocks

Id

System

Command (m for help):

, , , . , . , , , !
1.4.3.3.
. n , p,
, 1 .
. +32M, 32:
44.
Command (m for help): n
Command action
e
extended
p
primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3876, default 1): ( )
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-3876, default 3876): +32M

, p, :
45.
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot
/dev/hda1

Start
1

End
14

Blocks
105808+

Id
83

System
Linux

. a ,
1. p, , boot *.
1.4.3.4.
. n ( ), p
. 2, , /dev/
hda2. . +512M,

130

Gentoo Linux x86


512. , t , 2,
, 82, Linux Swap. p
, :
46.
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot
/dev/hda1 *
/dev/hda2

Start
1
15

End
14
81

Blocks
105808+
506520

Id
83
82

System
Linux
Linux swap

1.4.3.5.
. n ( ), p (
). 3 , /dev/hda3.
. ,
. , p
:
47.
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot
/dev/hda1 *
/dev/hda2
/dev/hda3

Start
1
15
82

End
14
81
3876

Blocks
105808+
506520
28690200

Id
83
82
83

System
Linux
Linux swap
Linux

1.4.3.6.
fdisk, w.
48. fdisk
Command (m for help): w

, , .

1.4.4.
1.4.4.1.
, . ,
, , ,

131

Gentoo Linux x86


. , ,
...
1.4.4.2. ( !)
Linux .
: ext2, ext3, ReiserFS, XFS JFS.
1.

ext2

Linux, . . , , .
, .

2.

ext3

3.

ReiserFS

4.

XFS , -

5.

JFS

ext2, , , . ext3 . (b-tree),


. ,
mke2fs -O dir_index. , ext3 .
, B*-. ,
( 10-15 ) ext2 ext3 ( 4).
ReiserFS ; .
2.4.18, ReiserFS ,
, ,
.
. Linux- SCSI
(fibre-channel), . - , XFS
,
(
, )
.
IBM.
, ,
- .

1.4.4.3.
:

ext2

mke2fs

ext3

mke2fs -j

reiserfs

mkreiserfs

132

Gentoo Linux x86


xfs

mkfs.xfs

jfs

mkfs.jfs

, ( /dev/hda1 ) ext2,
(/dev/hda3 ) ext3, :
49.
# mke2fs /dev/hda1
# mke2fs -j /dev/hda3

(
).
1.4.4.4.
mkswap , :
50.
# mkswap /dev/hda2

swapon:
51.
# swapon /dev/hda2

, , .

1.4.5.
, , , ( ) . mount. . , :
52.
# mount /dev/hda3 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/hda1 /mnt/gentoo/boot

/tmp ,
: chmod 1777 /mnt/gentoo/tmp. /var/tmp.

proc ( ) /
proc. .
Gentoo.

133

Gentoo Linux x86

1.5. Gentoo
1.5.1.
1.5.1.1.
, , ,
. , !
, date:
53.
# date
Fri Mar 29 16:21:18 UTC 2007

, date (: ,
, , ). UTC.
. , 29 , 16:21, 2005 , :
54.
# date 032916212007

1.5.1.2.
stage3 .
, , Gentoo,
. , ,
, .. .
, uname -m.
:
:

1.5.2. :

1.5.2.1.
Gentoo ( /mnt/gentoo):
55. Gentoo
# cd /mnt/gentoo

134

Gentoo Linux x86


, , . links, Gentoo
.
links , lynx. -, http_proxy ftp_proxy:
56. - lynx
# export http_proxy="http://proxy.server.com:port"
# export ftp_proxy="http://proxy.server.com:port"

, links.
releases/, , (, x86/), Gentoo ( 2006.1/), , , stages/.
( ). D .
Q, .
57. links
# links http://www.gentoo.org/main/ru/mirrors.xml
( links -:)
# links -http-proxy proxy.server.com:8080 http://www.gentoo.org/main/ru/mirrors.xml

, stage3- stage1 stage2


.
, md5sum MD5, . , x86:
58.
# md5sum -c stage3-x86-2007.0.tar.bz2.DIGESTS
stage3-x86-2007.0.tar.bz2: OK

1.5.2.2.
. tar, .. :
59.
# tar xvjpf stage3-*.tar.bz2

1.

, ( xvjpf). :

2.

3.

, , (
);

135

Gentoo Linux x86

4.

bzip2;

5.

6.

, , , .

- (, MIPS)
tar BusyBox, v.
xjpf.

1.5.3. :

1.5.3.1.
: x86 , . .
- /mnt/cdrom/stages. , ls:
60.
# ls /mnt/cdrom/stages

, , CD-ROM:
61. CD-ROM
# ls /mnt/cdrom/stages
ls: /mnt/cdrom/stages: No such file or directory
# mount /dev/cdroms/cdrom0 /mnt/cdrom
# ls /mnt/cdrom/stages

Gentoo ( /mnt/gentoo):
62. /mnt/gentoo
# cd /mnt/gentoo

tar . ,
(xvjpf)! v tar.
stage3-<>-2006.1.tar.bz2.
.
63.
# tar xvjpf /mnt/cdrom/stages/stage3-<>-2007.0.tar.bz2

136

Gentoo Linux x86


.

1.5.4.
1.5.4.1.
,
Portage , , ..
1.5.4.2.
( /mnt/gentoo):
64.
# cd /mnt/gentoo

links ( lynx) Gentoo.


snapshots/. ( portage-latest.tar.bz2),
D.
65. Gentoo
# links http://www.gentoo.org/main/ru/mirrors.xml

Q. /mnt/gentoo .
, md5sum, MD5, .
66. Checking integrity of a Portage snapshot
# md5sum -c portage-latest.tar.bz2.md5sum
portage-latest.tar.bz2: OK

. , ;
C, c.
67.
# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

1.5.5.
1.5.5.1.
Gentoo , Portage.
( export), -

137

Gentoo Linux x86


. Portage, /etc/make.conf.
.

/mnt/gentoo/etc/make.conf.
example. Gentoo, ,
.

( nano)
, .
68. /etc/make.conf
# nano -w /mnt/gentoo/etc/make.conf

, make.conf.example :
#, ="" . make.conf . .
1.5.5.2. CHOST
CHOST , .
. , ..
. CHOST, -, , ,
stage3.
1.5.5.3. CFLAGS CXXFLAGS
CFLAGS CXXFLAGS gcc C C
++, . , , ,
. , .
make.conf , , ,
. ; ( , , , ).
. , GNU (.) gcc (info gcc
Linux). make.conf.example:
.
-march=, .
make.conf.example. , x86 Athlon XP:
69. -march GCC
# AMD64, 64-
# , -march=k8
# EM64T -march=nocona
-march=athlon-xp

138

Gentoo Linux x86

(JohnBat26) ( 1.5): 4.2.0 ,


, ( : -march -mtune):
1.

generic: , , x86;

2.

native: . cpuid !

-O ( O, ), gcc.
:
1.

s ;

2.

0 , ;

3.

1, 2 3 ( ,
).

, 2:
70. -O GCC
-O2

-pipe (
).
, -fomit-frame-pointer (
, ) !
CFLAGS CXXFLAGS, ,
:
71. CFLAGS CXXFLAGS (gcc < 4.2.0)
CFLAGS="-march=athlon-xp -pipe -O2"
CXXFLAGS="${CFLAGS}"

# AMD64: -march=k8
# EM64T: -march=nocona
#

1.5.5.4. MAKEOPTS
MAKEOPTS ,
. ( ) , .
72. MAKEOPTS
MAKEOPTS="-j2"

1.5.5.5. , , !
/mnt/gentoo/etc/make.conf ,
( nano CTRL+X). Gentoo.

139

Gentoo Linux x86

1.6. Gentoo
1.6.1.
1.6.1.1. :
. Portage GENTOO_MIRRORS make.conf , . ,
, (
), mirrorselect, .
73. mirrorselect GENTOO_MIRRORS
# mirrorselect -i -o >>/mnt/gentoo/etc/make.conf

IPv6. IPv6.

SYNC make.conf.
rsync ( ),
Portage ( ebuild , , Portage
). SYNC , mirrorselect
:
74. rsync mirrorselect
# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf

mirrorselect, /mnt/gentoo/etc/
make.conf!
1.6.1.2. DNS
, , : DNS ( ) /etc/resolv.conf. , . /etc/resolv.conf , .
75. DNS
( -L ,
)
# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

1.6.1.3. /proc /dev


/proc /mnt/gentoo/proc,
, ,
/dev.

140

Gentoo Linux x86


76. /proc /dev
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev

1.6.1.4.
, , . ,
. , ( - ) ( ).
:
1.

chroot / ( ) /mnt/gentoo ( ).

2.

, env-update, , , .

3.

, source.

77.
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"

! Gentoo Linux. ,
, :-)

1.6.2. Portage
1.6.2.1. Portage
Portage emerge --sync:
78.
# emerge --sync
( , ,
,
--quiet :)
# emerge --sync --quiet

, rsync-, emerge-webrsync, .

141

Gentoo Linux x86


, Portage , emerge portage.
1.6.2.2.
.
Gentoo.
CHOST, CFLAGS , . Gentoo.
. , 86, hppa alpha
: 2.4, 2.6.
2.6. ppc ppc64 .
.
, , :
79.
# ls -FGg /etc/make.profile
lrwxrwxrwx 1 48 Apr 8 18:51 /etc/make.profile -> ../usr/portage/profiles/default-linux/x86/2007.0/

,
2.6. , .
desktop server. 200
7.0/, , . ,
make.defaults desktop, , .
, , , ,
2.4. , , . x86 :
80.
# ls -d /usr/portage/profiles/default-linux/x86/no-nptl/2.4
/usr/portage/profiles/default-linux/x86/no-nptl/2.4

2.4 (..
). ,
, :
81. 2.4
(, ; - x86)
# ln -snf /usr/portage/profiles/default-linux/x86/no-nptl/2.4 /etc/make.profile
( 2.4)
# ls -FGg /etc/make.profile/
total 12
-rw-r--r-- 1 939 Dec 10 14:06 packages
-rw-r--r-- 1 347 Dec 3 2004 parent
-rw-r--r-- 1 573 Dec 3 2004 virtuals

ppc 2006.1 :

142

Gentoo Linux x86


82. PPC
( PPC, PPC-, )
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1 /etc/make.profile
( G3)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G3 /etc/make.profile
( G3 Pegasos)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G3/Pegasos/ /etc/make.profile
( G4 (Altivec))
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G4 /etc/make.profile
( G4 (Altivec) Pegasos)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G4/Pegasos/ /etc/make.profile

ppc64 2006.1 :
83. PPC64
( PPC64 64- , PPC64-)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/64bit-userland /etc/make.profile
( PPC64 32- , PPC64-)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/32bit-userland /etc/make.profile
( , .)
(userland )
( 970 JS20)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/970 /etc/make.profile
( G5)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/970/pmac /etc/make.profile
( POWER3)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power3 /etc/make.profile
( POWER4)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power4 /etc/make.profile
( POWER5)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power5 /etc/make.profile
( )

1.6.3. USE
USE () ,

Gentoo.
. , gtk
qt . , SSL.
(svgalib) X11 (X-).
.
, . Gentoo
, .
USE.
USE , . , ssl ssl , . -X X- ( ).
gnome gtk -kde -qt Gnome gtk,
KDE qt, GNOME.
USE make.defaults . make.defaults
, /etc/make.profile, .
USE USE make.defaults. ,
/etc/make.conf, . -

143

Gentoo Linux x86


USE, . - (
), (
). /etc/make.profile. , ,
Portage!
USE Gentoo USE.
/usr/portage/profiles/use.desc.
84. USE-
# less /usr/portage/profiles/use.desc
( , "q")

, USE , KDE, DVD,


ALSA CD:
85. /etc/make.conf
# nano -w /etc/make.conf

86. USE
USE="-gtk -gnome qt kde dvd alsa cdr"

1.6.4. : GLIBC
, - .
/etc/locale.gen.
87. /etc/locale.gen
# nano -w /etc/locale.gen

(), () (, UTF-8).
88.
en_US/ISO-8859-1
en_US.UTF-8/UTF-8
de_DE/ISO-8859-1
de_DE@euro/ISO-8859-15

locale-gen. ,
/etc/locale.gen.

locale-gen glibc-2.3.6-r4 . glibc,


.

, , .
Gentoo. . .

144

Gentoo Linux x86


.

1.7.
1.7.1.
(time zone), , . /usr/share/zoneinfo, /etc/localtime. , , /usr/share/zoneinfo/Etc/GMT*, . .
. , GMT-8 GMT+8.
89.
# ls /usr/share/zoneinfo
(, GMT)
# cp /usr/share/zoneinfo/GMT /etc/localtime

(JohnBat26): ( ), ( ):
1.

2.

/etc/adjtime. , .

3.

nano -w /etc/conf.d/clock. UTC Local, !!!

1.7.2.
1.7.2.1.
Linux , .
. Gentoo .
Gentoo (.).
x86 , , ,
1.

vanilla-sources ( linux );

2.

gentoo-sources ( , ).

emerge . USE="-doc" ,
xorg-x11 . USE="symlink" , /usr/src/linux:
90.
# USE="-doc symlink" emerge gentoo-sources

145

Gentoo Linux x86


/usr/src, linux,
. ,
gentoo-sources-2.6.12-r10. , .
91.
# ls -l /usr/src/linux
lrwxrwxrwx
1 root

root

12 Oct 13 11:04 /usr/src/linux -> linux-2.6.12-gentoo-r10

. genkernel,
, -. , .
, : .
genkernel, : genkernel.

1.7.3. :
1.7.3.1.
Linux.
, - ;)
: , . , pciutils (emerge
pciutils), lspci. lspci , . , pcilib (: pcilib: cannot
open /sys/bus/pci/devices [pcilib: /sys/bus/pci/devices]), lspci.
lspci . .
lsmod , - (
, ).
make menuconfig.
, ncurses.
92.
# cd /usr/src/linux
# make menuconfig

. ,
( Gentoo , ).
1.7.3.2.
, .
:
93. /,
Code maturity level options --->
[*] Prompt for development and/or incomplete code/drivers"
General setup --->
[*] Support for hot-pluggable devices

146

Gentoo Linux x86


, , (, SCSI), , , .
:
94.
Processor type and features --->
( )
(Athlon/Duron/K7) Processor family

File Systems .
, Gentoo . Virtual
memory /proc file system. 2.4, /dev file system, ..
udev.
95.
( 2.4.x)
File systems --->
[*] Virtual memory file system support (former shm fs)
[*] /proc file system support
[*] /dev file system support (EXPERIMENTAL)
[*]
automatically mount /dev at boot
[ ] /dev/pts file system for Unix98 PTYs
( 2.6.x)
File systems --->
Pseudo Filesystems --->
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)
( )
<*> Reiserfs support
<*> Ext3 journalling file system support
<*> JFS filesystem support
<*> Second extended fs support
<*> XFS filesystem support

BIOS , , :
96.
( 2.4.x)
ATA/IDE/MFM/RLL support --->
IDE, ATA and ATAPI Block devices --->
<*>
Include IDE/ATA-2 DISK support
[ ]
Use multi-mode by default
[*]
Auto-Geometry Resizing support

DMA :
97. DMA
Device Drivers --->
ATA/ATAPI/MFM/RLL support --->
[*] Generic PCI bus-master DMA support
[*]
Use PCI DMA by default when available

147

Gentoo Linux x86


PPPoE ,
:
98. PPPoE
( 2.4.)
Network device support --->
<*> PPP (point-to-point protocol) support
<*>
PPP support for async serial ports
<*>
PPP support for sync tty ports
( 2.6.x)
Device Drivers --->
Networking support --->
<*> PPP (point-to-point protocol) support
<*>
PPP support for async serial ports
<*>
PPP support for sync tty ports

, . PPP over Ethernet rp-pppoe, PPPoE .


, .
Intel HyperTreading , :
99. SMP
Processor type and features --->
[*] Symmetric multi-processing support

USB, (, ),
:
100. USB
USB Support --->
<*>
USB Human Interface Device (full HID) support

, PCMCIA, PCMCIA
, 2.4. pcmcia-cs, , . 2.6 PCMCIA, .
PCMCIA 2.6, PCMCIA
:
101. PCMCIA 2.6
Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->
PCCARD (PCMCIA/CardBus) support --->
<*> PCCard (PCMCIA/CardBus) support
( ( ), 16- PCMCIA)
<*>
16-bit PCMCIA support
[*]
32-bit CardBus support
( )
--- PC-card bridges
<*> CardBus yenta-compatible bridge support (NEW)
<*> Cirrus PD6729 compatible bridge support (NEW)
<*> i82092 compatible bridge support (NEW)
<*> i82365 compatible bridge support (NEW)
<*> Databook TCIC host bridge support (NEW)

148

Gentoo Linux x86


, .
1.7.3.3.
, , .
:
102.
( 2.4)
# make dep && make bzImage modules modules_install
( 2.6)
# make && make modules_install

, /boot. ,
, ,
. <-> .
103.
# cp arch/i386/boot/bzImage /boot/<->

1.7.4. : genkernel
, , genkernel
.
, , genkernel. genkernel ,
-. , genkernel,
, . genkernel , , ,
.
, genkernel. :
104. genkernel
# emerge genkernel

, 2.6, ,
, , genkernel :
105.
( 2.6.)
# zcat /proc/config.gz > /usr/share/genkernel/x86/kernel-config-2.6

, genkernel all. ,
, genkernel , .

149

Gentoo Linux x86


ext2 ext3,
, genkernel --menuconfig all, (.. ). EVMS2 LVM2, , --evms2 --lvm2.
106. genkernel
# genkernel all

genkernel , (initrd).
initrd ,
. , . initrd ,
( , ),
.
107. initrd
# ls /boot/kernel* /boot/initramfs*

: coldplug.
initrd , , coldplug
. coldplug :
108. coldplug
# emerge coldplug
# rc-update add coldplug boot

1.7.5.
1.7.5.1.
, , /etc/modules.autoload.d/
kernel-2.4 ( kernel-2.6). , , .
find, < >
:
109.
# find /lib/modules/<kernel version>/ -type f -iname '*.o' -or -iname '*.ko'

, 3c59x.o kernel-2.4 kernel-2.6, .


110. /etc/modules.autoload.d/kernel-2.4
( 2.4.x)
# nano -w /etc/modules.autoload.d/kernel-2.4

111. /etc/modules.autoload.d/kernel-2.4 kernel-2.6


3c59x

150

Gentoo Linux x86


.

1.8.
1.8.1.
1.8.1.1. fstab?
Linux , , /etc/fstab.
(mountpoints, ),
, ( , ..)

1.8.1.2. /etc/fstab
/etc/fstab . ,
, . :
1.

(partition) ( ).

2.

(mountpoint), .

3.

(filesystem), .

4.

(mountoptions), mount
. , mount (man mount), .
.

5.

dump , dump. 0 ().

6.

fsck (check)
. 1, 2 ( 0, ).

/etc/fstab , Gentoo, .
/etc/fstab.

112. /etc/fstab
# nano -w /etc/fstab

, , /proc, tmpfs,
CD-ROM ( , ).
/etc/fstab:

151

Gentoo Linux x86


auto mount (
,
), user - .
, noatime , ( ):
/etc/fstab, , , .
(JohnBat26): /etc/fstab:
113. /etc/fstab
/dev/sda2
/dev/sda5
/dev/sda3
/dev/sda7
/dev/sr0

/boot
/
none
/home
/mnt/cdrom

# FAT32
/dev/sda1
/windows/c

ext2
xfs
swap
xfs
auto
vfat

# NTFS
/dev/sda6
/windows/d
ntfs
/dev/sda8
/windows/e
vfat
/dev/sda9
/home/media
xfs

defaults,noatime
defaults,noatime
sw
defaults,noatime
noauto,ro,user,iocharset=utf8

1
0
0
0
0

2
1
0
1
0

auto,iocharset=utf8,quiet,user,umask=000,noatime

0 0

auto,nls=utf8,umask=0,user,noatime
auto,iocharset=utf8,user,quiet,umask=000,noatime
defaults,noatime

0 0
0 0
0 1

# NTFS ntfs-3g
/dev/sda10
/mnt/windows/f ntfs-3g -o silent,umask=0,locale=ru_RU.utf8
# NOTE: The next line is critical for boot!
proc
/proc
proc
defaults

0 0

# flash drive
/dev/sdb
/mnt/flash
shm
/dev/shm

0 0
0 0

auto
tmpfs

user,noauto,rw,async,iocharset=utf8
nodev,nosuid,noexec

1.8.2.
1.8.2.1. Hostname, Domainname . .
, .
, Linux-.
, , , . ,
tux, homenetwork.
114.
# nano -w /etc/conf.d/hostname
( HOSTNAME )
HOSTNAME="tux"

-, (domainname) /etc/conf.d/net:

152

Gentoo Linux x86


115.
# nano -w /etc/conf.d/net
( DNSDOMAIN )
dns_domain_lo="homenetwork"

NIS ( , , ),
:
116. NIS-
# nano -w /etc/conf.d/net
( NIS nis_domain)
nis_domain_lo="my-nisdomain"

1.8.2.2.
, : , ! , , , Gentoo.
.

, , ,
, (VLAN) 802.1Q ,
Gentoo.

/etc/conf.d/net. , ,
, . , .
/etc/conf.d/net.example ,
.
DHCP. DHCP , DHCP-,
. DHCP-.
DHCP,
- , DHCP, /etc/conf.d/net
( nano):
117. /etc/conf.d/net
# nano -w /etc/conf.d/net

:
118. /etc/conf.d/net
#
#
#
#
(#
#
#
#

This blank configuration will automatically use DHCP for any net.*
scripts in /etc/init.d. To create a more complete configuration,
please review /etc/conf.d/net.example and save your configuration
in /etc/conf.d/net (this file :]!).

DHCP net.* /etc/init.d.
, , /etc/conf.d/net.example,
/etc/conf.d/net ( :]!).
)

153

Gentoo Linux x86


IP, , config_eth0,
routes_eth0:
119. IP eth0
config_eth0=( "192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255" )
routes_eth0=( "default gw 192.168.0.1" )

DHCP , config_eth0 dhcp_eth0:


120. IP eth0
config_eth0=( "dhcp" )
dhcp_eth0="nodns nontp nonis"

/etc/conf.d/net.example.
, config_eth1, config_eth2 ..
, .
1.8.2.3.
.
PCMCIA, , PCMCIA
PCMCIA.
121. net.eth0 default
# rc-update add net.eth0 default

,
net.eth1, net.eth2 .. ln:
122.
# cd /etc/init.d
# ln -s net.lo net.eth1
# rc-update add net.eth1 default

1.8.2.4.
Linux . /etc/hosts, IP- , .
. , DNS.
123. /etc/hosts
# nano -w /etc/hosts

154

Gentoo Linux x86


124.
( )
127.0.0.1
tux.homenetwork tux localhost
( ,
IP-.)
192.168.0.5
192.168.0.6

jenny.homenetwork jenny
benny.homenetwork benny

, .

1.8.3.
1.8.3.1. root
, root (), :
125. root
# passwd

, root , tts/0 /
etc/securetty:
126. tts/0 to /etc/securetty
# echo "tts/0" >> /etc/securetty

1.8.3.2.
Gentoo /etc/rc.conf. /etc/rc.conf , :)
127. /etc/rc.conf
# nano -w /etc/rc.conf

/etc/rc.conf .
, , . unicode, (, gdm kdm).
Gentoo /etc/conf.d/keymaps.
.
128. /etc/conf.d/keymaps
# nano -w /etc/conf.d/keymaps

(KEYMAP): , .

155

Gentoo Linux x86


/etc/conf.d/keymaps .
Gentoo /etc/conf.d/clock. .
UTC (),
CLOCK="local". .
/etc/conf.d/clock .
.

1.9.
1.9.1.
2.4, Gentoo (stage3),
- . Gentoo udev, 2.4
udev , devfsd, udev.
129. devfsd
( , 2.4.x c )
# emerge --unmerge udev
# emerge devfsd

1.9.2.
stage3,
. , .
, , . Unix Linux , .
.
Gentoo . sysklogd,
, syslog-ng, , metalog . , Portage
: .
sysklogd syslog-ng,
logrotate, .
, emerge,
rc-update. syslogng. :

156

Gentoo Linux x86


130.
# emerge syslog-ng
# rc-update add syslog-ng default

1.9.3. : cron
cron. , , . cron? cron
. , - (,
, ).
Gentoo cron : dcron, fcron vixie-cron.
. , dcron fcron
, crontab /etc/crontab.
, , vixie-cron.
vixie-cron. cron,
.
131. cron
# emerge vixie-cron
# rc-update add vixie-cron default
( dcron fcron) # crontab /etc/crontab

1.9.4. :
, locate,
sys-apps/slocate:
132. slocate
# emerge slocate

1.9.5.
, , ..,
, .
, :

XFS

xfsprogs

emerge xfsprogs

157

Gentoo Linux x86


ReiserFS

reiserfsprogs

emerge reiserfsprogs

JFS

xfsprogs

emerge jfsutils

EVMS, evms:
133. EVMS
# USE="-gtk" emerge evms
USE="-gtk" , . -

evms, evms.

( rp-pppoe dhcp), .

1.9.6.
1.9.6.1. : DHCP
, Gentoo IP- , dhcpcd ( DHCP, DHCP .
). ,
!
134. dhcpcd
# emerge dhcpcd

1.9.6.2. : PPPoE
rp-pppoe, .
135. rp-pppoe
# USE="-X" emerge rp-pppoe

xorg-x11 ( rp-pppoe ;
, rp-pppoe , xorg-x11 : ).
USE="-X"

1.9.6.3. : RAID IBM


POWER5 RAID- SCSI, iprutils, , , ,
.

158

Gentoo Linux x86


136. iprutils
# emerge iprutils

1.10.
1.10.1.
1.10.1.1.
, , , , .
. x86 Gentoo Linux GRUB LILO.
, , , (, ).
Linux (, Gentoo).
1.10.1.2. :
( genkernel), , vga / video .
, .
, Gentoo ( gentoo-sources), vesafb-tng
VESA ( ). vesafb-tng vga . vesafb,
vga .
vga , vesafb.
/usr/src/linux/Documentation/fb/vesafb.txt (
), VESA, .
vga,
.
640x480

800x600

1024x768

1280x1024

256

0x301

0x303

0x305

0x307

32

0x310

0x313

0x316

0x319

64

0x311

0x314

0x317

0x31A

16

0x312

0x315

0x318

0x31B

159

Gentoo Linux x86


video . (vesafb 2.6 vesa 2.4), , . /usr/src/linux/Documentation/fb/vesafb.txt,
:
1.

ywrap

, ( , );

2.

mtrr:n

3.

mode

MTRR; n: 0 - 1 - 2 (write-back) 3 - (write-combining) 4 - (writethrough);


( vesafb-tng) , . ,
1024x768-32@85 1024x768, 32- 85 .

- vga=0x318
video=vesafb:mtrr:3,ywrap
video=vesafb:mtrr:3,ywrap,1024x768-32@85. ( ) ,
.
GRUB LILO.

1.10.2. : GRUB
1.10.2.1. GRUB
GRUB , .
Linux- /dev/hda1, , GRUB (hd0,0).
hd0,0 .
, , ; c , . , hd , atapi-ide,
-. SCSI (
, IDE, , BIOS SCSI).
BIOS (, ),
hd0.
, /dev/hda, CD-ROM /dev/hdb, CD /dev/
hdc, /dev/hdd, SCSI , /dev/hdd7
(hd1,6). , ( ), , , GRUB
TAB, , , GRUB.
, , GRUB.
1.10.2.2. GRUB
GRUB :
137. GRUB
# emerge grub

160

Gentoo Linux x86


GRUB , ,
GRUB MBR, . nano ( ) /boot/grub/grub.conf:
138. /boot/grub/grub.conf
# nano -w /boot/grub/grub.conf

grub.conf . grub.conf . grub.conf . , ,


(initrd).
grub.conf , genkernel
grub.conf , genkernel

JFS, ro kernel, JFS


, -.

139. grub.conf , genkernel


3: grub.conf , genkernel
# : 0 - , 1 - ..
default 0
#
timeout 30
# , :)
# ,
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title=Gentoo Linux 2.6.12-r10
# ( )
root (hd0,0)
kernel /boot/kernel-2.6.12-gentoo-r10 root=/dev/hda3
# Windows
# Windows /dev/hda6
title=Windows XP
rootnoverify (hd0,5)
makeactive
chainloader +1

140. grub.conf , genkernel


default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=Gentoo Linux 2.6.12-r10


root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.12-gentoo-r10 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root
initrd /boot/initramfs-genkernel-x86-2.6.12-gentoo-r10
#
title=Windows XP
rootnoverify (hd0,5)
makeactive
chainloader +1

161

Gentoo Linux x86

udev, kernel,
genkernel, udev ( ).

-, , .
, , GRUB ( (hd0,0)), , . , (hd0,0)/
grub/splash.xpm.gz /boot/grub/splash.xpm.gz, (hd0,0) /boot.

, , /boot ,
/boot, , .
, /boot , boot.
, ,
/boot .
, kernel.
(root=/dev/hda3 real_root=/dev/hda3); ,
, video / vga , .
2.6.7 , - ,
BIOS , hdx=stroke.
, genkernel, , ,
-. , SCSI,
doscsi.
grub.conf . - GRUB
MBR (Master Boot Record), GRUB .
GRUB grub-install. ,
grub-install GRUB .
: GRUB grub-install : GRUB .
1.10.2.3. : GRUB grub-install
GRUB grub-install. , grub-install
, .. . /etc/
mtab, . ,
: /proc/mounts /etc/mtab, rootfs,
. :
141. /etc/mtab
# grep -v rootfs /proc/mounts > /etc/mtab

GRUB, grub-install:
142. grub-install
# grub-install /dev/hda

162

Gentoo Linux x86


GRUB, , GRUB FAQ (.) GRUB
(.).
.
1.10.2.4. : GRUB
, grub. grub> grub. , GRUB
.
143. GRUB
# grub

, --no-floppy, grub
.

GRUB , /dev/hda1, GRUB MBR (Master Boot Record) , , GRUB. , , .


GRUB, TAB. , root
(, TAB, ( hd0). root (hd0, TAB,
( hd0,0).
GRUB . GRUB.
144. GRUB MBR
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

( /boot)
( GRUB MBR)
( GRUB)

GRUB MBR, setup , . , GRUB /dev/


hda3 setup (hd0,2). , .

GRUB, , GRUB FAQ (.)


GRUB (.).

, .
make install: GRUB .

163

Gentoo Linux x86

1.10.3. : LILO
1.10.3.1. LILO
LILO ( LInux LOader)
Linux-. , GRUB ( GRUB). LILO ,
, GRUB . , ,
LILO . , Gentoo , ,
, LILO.
LILO : emerge.
145. LILO
# emerge lilo

1.10.3.2. LILO
LILO /etc/lilo.conf. ( nano) .
146. /etc/lilo.conf
# nano -w /etc/lilo.conf

.
.
:
1.

, genkernel;

2.

, genkernel;

, ,
(initrd).

JFS, ro kernel, JFS


, -.

164

Gentoo Linux x86


147. /etc/lilo.conf
boot=/dev/hda
prompt
timeout=50
default=gentoo

#
#
#
#

LILO MBR


gentoo

# , genkernel
image=/boot/kernel-2.6.12-gentoo-r10
label=gentoo
#
read-only
# ; !
root=/dev/hda3
#
# , genkernel
image=/boot/kernel-genkernel-x86-2.6.12-gentoo-r10
label=gentoo
read-only
root=/dev/ram0
append="init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev"
initrd=/boot/initramfs-genkernel-2.6.12-gentoo-r10
# Windows
# Windows /dev/hda6
other=/dev/hda6
label=windows

udev, kernel,
genkernel, udev ( ).

-, , .

, append. , video :
148. append
image=/boot/kernel-2.6.12-gentoo-r10
label=gentoo
read-only
root=/dev/hda3
append="video=vesafb:mtrr,ywrap,1024x768-32@85"

2.6.7 , - ,
BIOS , hdx=stroke.
, genkernel, , ,
-. , SCSI,
doscsi.
. /sbin/lilo,
LILO , /etc/lilo.conf, (..
). , /sbin/lilo .

165

Gentoo Linux x86


149. LILO
# /sbin/lilo

. make install
; LILO .

1.10.4.
.
, : reboot.
150.
# exit
cdimage ~# cd
cdimage ~# umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
cdimage ~# reboot

, -,
Gentoo.
, Gentoo.

1.11. Gentoo
1.11.1.
1.11.1.1.
root () Unix/Linux , .
.
, . , , , .

audio

cdrom

floppy

games

166

Gentoo Linux x86

portage

emerge --pretend

usb

USB

plugdev

USB-

video

wheel

su

, john, wheel, users


audio, root ( root ),
useradd:
151.
Login: root
Password: ( root)
# useradd -m -G users,wheel,audio -s /bin/bash john
# passwd john
Password: ( john)
Re-enter password: ( )

root,
root su -. sudo,
.

1.12. ?
1.12.1.
! Gentoo. ?
? ? Gentoo , ( )
.
Gentoo, Gentoo, , , , USE-, Gentoo ..
, , , Gentoo. , , (.),
.


Gentoo. . .

167

Gentoo Linux x86


Gentoo (.), .
.

1.12.2. Gentoo
, Gentoo (.), IRC Gentoo (.).
, ,
. .
, :)

2. Gentoo
2.1. Portage
2.1.1. Portage
Portage , Gentoo . ,
Linux.
Portage Python Bash, ,
.
Portage emerge. emerge. emerge,
:
152. emerge
$ man emerge

2.1.2.
2.1.2.1. ebuild
, , Gentoo
. ebuild, , -

168

Gentoo Linux x86


Portage (, , ..)
/usr/portage.
Portage ,
, . , Portage , , ..
2.1.2.2.
rsync (.),
. , rsync emerge :
153.
# emerge --sync

rsync - , -
, . emerge-webrsync:
154. emerge-webrsync
# emerge-webrsync

2.1.3.
2.1.3.1.

emerge. emerge --search ,
( , ) .
, , pdf :
155. pdf
$ emerge --search pdf

--searchdesc ( -S):
156. , pdf
$ emerge --searchdesc pdf

, , .
, :

169

Gentoo Linux x86


157. emerge --search
*

(
*

net-print/cups-pdf
Latest version available: 1.5.2
Latest version installed: [ Not Installed ]
Size of downloaded files: 15 kB
Homepage:
http://cip.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/
Description: Provides a virtual printer for CUPS to produce PDF files.
License:
GPL-2
net-print/cups-pdf
: 1.5.2
: [ ]
: 15 kB
-: http://cip.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/
:
CUPS PDF-.
:
GPL-2 )

(JohnBat26): : eix ( emerge eix).


. update-eix emerge sync ;)

2.1.3.2.
, ,
emerge. gnumeric:
158. gnumeric
# emerge gnumeric

, - . , Portage . , Portage
, --pretend. :
159. gnumeric
# emerge --pretend gnumeric

, Portage (
), /usr/portage/distfiles.
, . , Portage , emerge --fetchonly:
160. gnumeric
# emerge --fetchonly gnumeric

2.1.3.3.
. USE- doc , . USE- doc emerge -vp < >.

170

Gentoo Linux x86


161. USE- doc
(alsa-lib - )
# emerge -vp alsa-lib
[ebuild N
] media-libs/alsa-lib-1.0.9_rc3

+doc -jack 674 kB

USE- doc /etc/make.conf, /etc/portage/package.use. , /etc/


portage/package.use, . USE- .
/usr/share/
doc, . ,
equery, gentoolkit (.) app-portage/gentoolkit.
162.
# ls -l /usr/share/doc/alsa-lib-1.0.9_rc3
total 28
-rw-r--r-- 1 root root 669 May 17 21:54
-rw-r--r-- 1 root root 9373 May 17 21:54
drwxr-xr-x 2 root root 8560 May 17 21:54
-rw-r--r-- 1 root root 196 May 17 21:54

ChangeLog.gz
COPYING.gz
html
TODO.gz

( equery :)
# equery files alsa-lib | less
media-libs/alsa-lib-1.0.9_rc3
* Contents of media-libs/alsa-lib-1.0.9_rc3:
/usr
/usr/bin
/usr/bin/alsalisp
( )

2.1.3.4.
, emerge --unmerge.
, , , . , - .

Portage , ! ,
.

163. gnumeric
# emerge --unmerge gnumeric

, , ,
, . Portage - ,
, emerge --depclean. .
2.1.3.5.
( , ), . Portage -

171

Gentoo Linux x86


, . ,
emerge --update world. --ask, Portage ,
, , :
164.
# emerge --update --ask world

Portage . , , , .
, --deep:
165.
# emerge --update --deep world

, , , ( - , ), .
- USE-, , -newuse. Portage ,
:
166.
# emerge --update --deep --newuse world

2.1.3.6.
, . , kde KDE ,
KDE- .
- , emerge --unmerge
, , , .
Portage ,
, , , , USE-.
emerge --depclean, . , , ,
.
:
167.
# emerge --update --deep --newuse world
# emerge --depclean
# revdep-rebuild

revdep-rebuild gentoolkit; :

172

Gentoo Linux x86


168. gentoolkit
# emerge gentoolkit

2.1.4. Portage ...


2.1.4.1. , , ,
, Portage , ,
. ,
Portage, .
Portage . ,
( freetype
freetype2), Portage (SLOT), . . . , freetype ebuild SLOT="1", SLOT="2".
, , . metalogd, sysklogd syslog-ng . ,
, ,
metalogd, . Portage :
virtual/syslog, virtual/syslog.
.
. ,
, .
, Portage , .
. , , ,
.
Gentoo , , ,
, .
2.1.4.2.
169. ( --pretend)
[blocks B

] mail-mta/ssmtp (is blocking mail-mta/postfix-2.2.2-r1)

170. ( --pretend)
!!! Error: the mail-mta/postfix package conflicts with another package.
!!!
both can't be installed on the same system together.
!!!
Please use 'emerge --pretend' to determine blockers.
( !!! : mail-mta/postfix .
!!! . ,
!!! 'emerge --pretend' . )

173

Gentoo Linux x86


ebuild , Portage . : , DEPEND, , RDEPEND.
,
.

. postfix ssmtp.
, , , . , .
. , , ,
Gentoo.
2.1.4.3.
171.
!!! all ebuilds that could satisfy "bootsplash" have been masked.
(!!! , "bootsplash", .)

172.
!!! possible candidates are:
-

gnome-base/gnome-2.8.0_pre1 (masked by: ~x86 keyword)


lm-sensors/lm-sensors-2.8.7 (masked by: -sparc keyword)
sys-libs/glibc-2.3.4.20040808 (masked by: -* keyword)
dev-util/cvsd-1.0.2 (masked by: missing keyword)
media-video/ati-gatos-4.3.0 (masked by: package.mask)
sys-libs/glibc-2.3.2-r11 (masked by: profile)

( !!! :
-

gnome-base/gnome-2.8.0_pre1 (: ~x86)
lm-sensors/lm-sensors-2.8.7 (: -sparc)
sys-libs/glibc-2.3.4.20040808 (: -*)
dev-util/cvsd-1.0.2 (: )
media-video/ati-gatos-4.3.0 (: package.mask)
sys-libs/glibc-2.3.2-r11 (: profile) )

, , . , , , . , :
1.

~arch: . ;

2.

-arch -*: . ,
, bugzilla;

3.

: . ,
bugzilla;

4.

package.mask: , - , ;

174

Gentoo Linux x86


5.

profile: .
.

2.1.4.4.
173.
emerge: there are no ebuilds to satisfy ">=sys-devel/gcc-3.4.2-r4".
!!! Problem with ebuild sys-devel/gcc-3.4.2-r2
!!! Possibly a DEPEND/*DEPEND problem.
( emerge: , ">=sys-devel/gcc-3.4.2-r4".
!!! ebuild sys-devel/gcc-3.4.2-r2
!!! , DEPEND/*DEPEND. )

, , , .
, , bugzilla, , .
, , .
2.1.4.5.
174. ebuild
!!! The short ebuild name "aterm" is ambiguous. Please specify
!!! one of the following fully-qualified ebuild names instead:
dev-libs/aterm
x11-terms/aterm
( !!! ebuild "aterm" . ,
!!! ebuild:
dev-libs/aterm
x11-terms/aterm )

, , . . Portage .
2.1.4.6.
175. Portage
!!! Error: circular dependencies:
ebuild / net-print/cups-1.1.15-r2 depends on ebuild /
app-text/ghostscript-7.05.3-r1
ebuild / app-text/ghostscript-7.05.3-r1 depends on ebuild /
net-print/cups-1.1.15-r2
( !!! : :
ebuild / net-print/cups-1.1.15-r2 ebuild /
app-text/ghostscript-7.05.3-r1
ebuild / app-text/ghostscript-7.05.3-r1 ebuild /
net-print/cups-1.1.15-r2
)

175

Gentoo Linux x86


, , ,
. , . , ,
, . , bugzilla, ,
.
2.1.4.7.
176. Portage
!!! Fetch failed for sys-libs/ncurses-5.4-r5, continuing...
(...)
!!! Some fetch errors were encountered. Please see above for details.
( !!! sys-libs/ncurses-5.4-r5, ...
(...)
!!! . . )

Portage ( ). - , - , ebuild . ,
, - .
, , .
2.1.4.8.
177. Portage ,
!!! Trying to unmerge package(s) in system profile. 'sys-apps/portage'
!!! This could be damaging to your system.
( !!! . 'sys-apps/portage'
!!! . )

, .
, .

2.2. USE-
2.2.1. USE-?
2.2.1.1. USE-
Gentoo ( , ),
, .
, 3D-.
, ,
. OpenGL,
OpenGL ? KDE,
, ?

176

Gentoo Linux x86


, /, ,
. ,
, Portage, .
2.2.1.2. USE-
USE-. USE- , . - USE-, Portage ,
. , .
kde. USE
, , KDE , . ,
KDE , KDE (
). kde,
KDE, KDE .
, , .
2.2.1.3. USE- ?
USE-: .
USE- . , USE-.
USE- .
USE- /usr/portage/profiles/
use.desc.
USE- /usr/portage/profiles/use.local.desc.

(JohnBat26): USE : Use Flag


EDitor ufed (emerge ufed)

2.2.2. USE-
2.2.2.1. USE-
, USE-, , .
, USE- USE. , USE ,
USE-, , Gentoo. make.defaults .

177

Gentoo Linux x86


, , /etc/make.
profile. , ,
. (/usr/portage/profiles/base).
2004.3:
178. USE make.defaults 2004.3
( base, default-linux,
default-linux/x86 default-linux/x86/2004.3)
USE="x86 oss apm arts avi berkdb bitmap-fonts crypt cups encode fortran f77
foomaticdb gdbm gif gpm gtk imlib jpeg kde gnome libg++ libwww mad
mikmod motif mpeg ncurses nls oggvorbis opengl pam pdflib png python qt
quicktime readline sdl spell ssl svga tcpd truetype X xml2 xmms xv zlib"

, . make.
defaults USE :
Portage!
,
USE. , USE /etc/make.conf.
USE-, . ,
(-).
, KDE QT, ldap, /etc/
make.conf USE :
179. USE /etc/make.conf
USE="-kde -qt ldap"

2.2.2.2. USE-
USE- ,
. /etc/portage ( ) /etc/portage/package.use.
, berkdb, mysql:
180. /etc/portage/package.use
dev-db/mysql berkdb

, USE- . ,
java PHP:
181. /etc/portage/package.use
dev-php/php -java

2.2.2.3. USE-
- USE- . , /etc/make.conf ( USE, ),

178

Gentoo Linux x86


USE . , (
) !
, java USE mozilla.
182. USE
# USE="-java" emerge mozilla

2.2.2.4.
, USE. USE="-java" , , java -
. USE (
) :
1.

USE , make.defaults ;

2.

, /etc/make.conf ;

3.

, /etc/portage/package.use ;

4.

, .

, USE Portage, emerge --info. ( USE), Portage.


183. emerge --info
# emerge --info

2.2.2.5. USE-
USE-
USE, emerge --newuse:
184.
# emerge --update -deep --newuse world

Portage depclean, ,
, USE-.

emerge --depclean , .
, . -p, depclean , .

185.
# emerge -p --depclean

179

Gentoo Linux x86


depclean , revdep-rebuild, , , . revdep-rebuild
gentoolkit, .
186. revdep-rebuild
# revdep-rebuild

,
USE-.

2.2.3. USE-
2.2.3.1. USE-
, , mozilla USE- ? ,
emerge --pretend --verbose:
187. USE
# emerge --pretend --verbose mozilla
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild
R
] www-client/mozilla-1.7.12-r2 USE="crypt gnome java mozsvg ssl
truetype xprint -debug -ipv6 -ldap -mozcalendar -mozdevelop -moznocompose
-moznoirc -moznomail -moznoxft -postgres -xinerama" 0 kB

emerge . , . equery gentoolkit.


:
188. gentoolkit
# emerge gentoolkit

USE- - equery uses.


gnumeric:
189. equery USE-
#
[
[
[
[
[

equery uses =gnumeric-1.6.3 -a


Searching for packages matching =gnumeric-1.6.3... ]
Colour Code : set unset ]
Legend
: Left column (U) - USE flags from make.conf ]
: Right column (I) - USE flags packages was installed with ]
Found these USE variables for app-office/gnumeric-1.6.3 ]
U I
- - debug
: Tells configure and the makefiles to build for debugging.
Effects vary across packages, but generally it will at
least add -g to CFLAGS. Remember to set FEATURES=nostrip too
- - gnome
: Adds GNOME support
+ + python
: Adds support/bindings for the Python language
- - static
: !!do not set this during bootstrap!! Causes binaries to be
statically linked instead of dynamically

180

Gentoo Linux x86

2.3. Portage
2.3.1. Portage
Portage (features),
Gentoo. , , , ..
Portage /etc/
make.conf FEATURES, , , . .
, Portage. make.conf:
190. make.conf
$ man make.conf

, , emerge --info FEATURES ( grep):


191.
$ emerge --info | grep FEATURES

2.3.2.
2.3.2.1. distcc
distcc , , , . distcc distcc ( distccd), .
.
distcc ( Gentoo)
distcc Gentoo.
2.3.2.2. distcc
Distcc ( ), ,
. Gnome, gnome

181

Gentoo Linux x86


USE. Gnome, ,
gtk USE.
192. distcc
# emerge distcc

2.3.2.3. Portage
distcc FEATURES /etc/make.conf.
MAKEOPTS, . -jX, X , distccd ( ) ; .
distcc-config distcc. ,
, DistCC 192.168.1.102 ( ), 192.168.1.103
192.168.1.104 ( ):
193. distcc distcc
# distcc-config --set-hosts "192.168.1.102 192.168.1.103 192.168.1.104"

distccd:
194. distccd
# rc-update add distccd default
# /etc/init.d/distccd start

2.3.3.
2.3.3.1. ccache
ccache . , , , , . 5
10 .
ccache, , ccache.
2.3.3.2. ccache
ccache, emerge ccache:
195. ccache
# emerge ccache

182

Gentoo Linux x86

2.3.3.3. Portage
/etc/make.conf ccache FEATURES.
CCACHE_SIZE ( ), 2G:
196. CCACHE_SIZE /etc/make.conf
CCACHE_SIZE="2G"

ccache, ccache. - , Portage


ccache, CCACHE_DIR:
197. ccache
# CCACHE_DIR="/var/tmp/ccache" ccache -s

ccache /var/tmp/ccache; , CCACHE_DIR /etc/make.conf.


, ccache , ${HOME}/.ccache, (Portage) ccache CCACHE_DIR.
2.3.3.4. ccache Portage
ccache Portage, /usr/lib/ccache/bin PATH ( /usr/bin). , /etc/env.d/00basic,
, PATH:
198. /etc/env.d/00basic
PATH="/usr/lib/ccache/bin:/opt/bin"

2.3.4.
2.3.4.1. ( )
Portage . , Gentoo
( GRP), Portage .
, quickpkg, , emerge --buildpkg --buildpkgonly.
, Portage , , buildpkg FEATURES.
catalyst. catalyst, , catalyst (.) catalyst (.).

183

Gentoo Linux x86

2.3.4.2.
Gentoo , . , Portage
PORTAGE_BINHOST. ,
ftp://buildhost/gentoo:
199. PORTAGE_BINHOST /etc/make.conf
PORTAGE_BINHOST="ftp://buildhost/gentoo"

, emerge --getbinpkg --usepkg. emerge c , ,


emerge,
.
, gnumeric :
200. gnumeric
# emerge --usepkg --getbinpkg gnumeric


emerge:
201. emerge
$ man emerge

2.4.
2.4.1.
2.4.1.1.
. , ,
. .
-, , .
. ,
, init.
, ( /etc/fstab)
. , /etc/init.d,
, .

184

Gentoo Linux x86


, , , init (
, ALT+F1, ALT+F2 ..), agetty. login.
2.4.1.2.
init /etc/init.d .
, /etc/init.d, , .
/etc/runlevels.
-, init /etc/init.d, /etc/
runlevels/boot. , , .
, /etc/runlevels/boot, , init , /etc/runlevels/default.
, ; .
2.4.1.3. init
, init . ,
. /etc/inittab.
, , , init . /etc/inittab, :
202. /etc/inittab
si::sysinit:/sbin/rc sysinit

init /sbin/rc sysinit . /sbin/rc, , init


.
-, init , /etc/runlevels/boot.
:
203. ,
rc::bootwait:/sbin/rc boot

rc. , , rc
(boot), /etc/runlevels.
init , , . /etc/inittab :
204. initdefault
id:3:initdefault:

185

Gentoo Linux x86


( Gentoo) 3. , init ,
3:
205.
l0:0:wait:/sbin/rc shutdown
l1:S1:wait:/sbin/rc single
l2:2:wait:/sbin/rc nonetwork
l3:3:wait:/sbin/rc default
l4:4:wait:/sbin/rc default
l5:5:wait:/sbin/rc default
l6:6:wait:/sbin/rc reboot

, 3, rc (
default). -, , , rc,
/etc/runlevels.
rc, init ,
:
206.
c1:12345:respawn:/sbin/agetty
c2:12345:respawn:/sbin/agetty
c3:12345:respawn:/sbin/agetty
c4:12345:respawn:/sbin/agetty
c5:12345:respawn:/sbin/agetty
c6:12345:respawn:/sbin/agetty

38400
38400
38400
38400
38400
38400

tty1
tty2
tty3
tty4
tty5
tty6

linux
linux
linux
linux
linux
linux

2.4.1.4. ?
, init , .
, ,
( [initscript]), ,
.
Gentoo : . sysinit, shutdown reboot. , ,
: , .
, /etc/runlevels:
boot, default, nonetwork single. boot , . : default , nonetwork ,
, single .
2.4.1.5.
, rc, .
/etc/init.d start, stop, restart, pause, zap, status, ineed, iuse,
needsme, usesme broken.

186

Gentoo Linux x86


, ( , ) start,
stop restart:
207. postfix
# /etc/init.d/postfix start

, . (, , ) .

, ,
pause:
208. postfix
# /etc/init.d/postfix pause

(, , ..), status:
209. postfix
# /etc/init.d/postfix status

, , , , stopped
(), zap:
210. postfix
# /etc/init.d/postfix zap

, , iuse ineed. ineed , . , iuse , , .


211. , Postfix
# /etc/init.d/postfix ineed

, (needsme) (usesme):
212. , Postfix
# /etc/init.d/postfix needsme

, , , :
213. , Postfix,
# /etc/init.d/postfix broken

187

Gentoo Linux x86

2.4.2. rc-update
2.4.2.1. rc-update?
Gentoo , . . . , ,
, ,
.
rc-update, . rcupdate depscan.sh .
2.4.2.2.
Gentoo default.
, , , default ,
. rc-update , : add (), del
() show ().
, , rc-update add del,
. :
214. Postfix default
# rc-update del postfix default

rc-update show
:
215.
# rc-update show

2.4.3.
2.4.3.1. ?
. , .. .
, , . , .
, , .

188

Gentoo Linux x86

2.4.3.2. /etc/conf.d
Gentoo : ,
, /etc/conf.d . , ,
apache2 ( /etc/init.d/apache2) /etc/conf.d/apache2,
, Apache 2 :
216. , /etc/conf.d/apache2
APACHE2_OPTS="-D PHP4"

( /etc/make.conf),
. ( ).

2.4.4.
2.4.4.1. ?..
, , .. Gentoo
. , - , Portage; , , .

, , Gentoo:
Gentoo , !

2.4.4.2.
.
217.
#!/sbin/runscript
depend() {
( )
}
start() {
(, )
}
stop() {
(, )
}
restart() {
(, )
}

189

Gentoo Linux x86


start(). .
2.4.4.3.
: use () need (). ,
need- , use-.
, , (virtual) .
, , -
. ,
(metalogd, syslog-ng, ..). ( ),
.
postfix.
218. Postfix
depend() {
need net
use logger dns
provide mta
}

, postfix:
1.

(net): , , , /etc/init.d/net.eth0;

2.

(logger): , , , /etc/init.d/
syslog-ng;

3.

(dns): , , , /etc/init.
d/named);

4.

(mta): , .

2.4.4.4.
, ( ) , ( : )
( : ). , before () after ().
, Portmap:
219. depend() Portmap
depend() {
need net
before inetd
before xinetd
}

190

Gentoo Linux x86


*, ,
.
220.
depend() {
before *
}

2.4.4.5.
depend() start(). , . ebegin eend
, :
221. start()
start() {
ebegin " - _"
start-stop-daemon --start --quiet --exec /path/to/my_service
eend $?
}

start(), , , /etc/init.d. start-stopdaemon, , , :


222. start-stop-daemon
# man start-stop-daemon

, stop() restart(). ! , , , start-stop-daemon.


, Gentoo, (Bourne Again
Shell bash), bash-
.
2.4.4.6.
, ,
opts , .
, restartdelay:
223. restartdelay
opts="${opts} restartdelay"
restartdelay() {
stop
sleep 3
# 3
start
}

191

Gentoo Linux x86

2.4.4.7.
/etc/conf.d : (.., ):
/etc/conf.d/< >
/etc/conf.d/basic
/etc/rc.conf
(, net),
, (, /etc/conf.d/net).

2.4.5.
2.4.5.1. ?
: net.eth0, ,
net.eth0 ( ). Gentoo
.
,
. , .
2.4.5.2. (softlevel)
, . ,
offline:
224.
# mkdir /etc/runlevels/offline

. ,
default, net.eth0:
225.
( default offline)
# cd /etc/runlevels/default
# for service in *; do rc-update add $service offline; done
( offline)
# rc-update del net.eth0 offline
( , offline)
# rc-update show offline
( )
acpid | offline
domainname | offline
local | offline
net.eth0 |

192

Gentoo Linux x86


, offline. , /boot/grub/grub.conf:
226. offline
title Gentoo Linux
root (hd0,0)
kernel (hd0,0)/kernel-2.4.25 root=/dev/hda3 softlevel=offline

, . , , default
offline.
2.4.5.3. (bootlevel)
. , boot default.

2.5.
2.5.1.
2.5.1.1. ?
, ,
.
( Linux) . : , .
2.5.1.2.
, Linux. .

PATH

, , . , ls, rc-update emerge), ,


(, ,
, , /bin/ls).

ROOTPATH

, PATH,
,
root.

193

Gentoo Linux x86

LDPATH

, , .

MANPATH

, , man .

INFODIR

, , info info.

PAGER

, , less more.

EDITOR

, , vi
nano.

KDEDIRS

, , KDE.

CLASSPATH

, , Java.

CONFIG_PROTECT

, Portage , .

CONFIG_PROTECT_MASK

, Portage ,

:
227.
PATH="/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/games/bin"
ROOTPATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
LDPATH="/lib:/usr/lib:/usr/local/lib:/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3"
MANPATH="/usr/share/man:/usr/local/share/man"
INFODIR="/usr/share/info:/usr/local/share/info"
PAGER="/usr/bin/less"
EDITOR="/usr/bin/vim"
KDEDIRS="/usr"
CLASSPATH="/opt/blackdown-jre-1.4.1/lib/rt.jar:."
CONFIG_PROTECT="/usr/X11R6/lib/X11/xkb /opt/tomcat/conf \
/usr/kde/3.1/share/config /usr/share/texmf/tex/generic/config/ \
/usr/share/texmf/tex/platex/config/ /usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf"

2.5.2.
2.5.2.1. /etc/env.d
, , Gentoo /etc/env.d.
, , 00basic, 05gcc , ,
, .

194

Gentoo Linux x86


, gcc ebuild 05gcc, :
228. /etc/env.d/05gcc
PATH="/usr/i686-pc-linux-gnu/gcc-bin/3.2"
ROOTPATH="/usr/i686-pc-linux-gnu/gcc-bin/3.2"
MANPATH="/usr/share/gcc-data/i686-pc-linux-gnu/3.2/man"
INFOPATH="/usr/share/gcc-data/i686-pc-linux-gnu/3.2/info"
CC="gcc"
CXX="g++"
LDPATH="/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3"

/
etc/profile - . Gentoo, , ( Portage) , , .
, gcc, /etc/env.
d/05gcc.
Portage, , . - . , , http_proxy. , /etc/profile, (/etc/env.d/99local)
:
229. /etc/env.d/99local
http_proxy="proxy.server.com:8080"

,
.
2.5.2.2. env-update
PATH /etc/env.d. , :
env-update , ( ) , .
env-update , /etc/env.d, . .
230. , env-update
00basic
99kde-env
99local
+-------------+----------------+-------------+
PATH="/bin:/usr/bin:/usr/kde/3.2/bin:/usr/local/bin"

, : KDEDIRS, PATH, CLASSPATH,


LDPATH, MANPATH, INFODIR, INFOPATH, ROOTPATH, CONFIG_PROTECT, CONFIG_PROTECT_MASK,
PRELINK_PATH PRELINK_PATH_MASK. , ( /etc/env.d).

195

Gentoo Linux x86


env-update , /etc/profile.env ( /etc/profile). , LDPATH /etc/ld.so.conf.
ldconfig, /etc/ld.so.cache, .
, env-update , . , Gentoo, ,
:
231.
# env-update && source /etc/profile

, .
, X11, source /etc/profile , X, .
, root /etc/init.d/xdm
restart. , , X , .

2.5.3.
2.5.3.1.
. ,
/home/my_user/bin ( ) PATH,
, PATH .
, ~/.bashrc ~/.bash_profile:
232. PATH ~/.bashrc
( )
PATH="${PATH}:/home/my_user/bin:"

PATH , .
2.5.3.2.
. ,
~/.bashrc .
PATH export. , .
233.
# export PATH="${PATH}:/home/my_user/tmp/usr/bin"

196

Gentoo Linux x86

3. Portage
3.1.
3.1.1. Portage
3.1.1.1.
Portage /etc/make.globals. , , . ,
.
, Portage , . /etc/make.profile. Portage c make.defaults . /etc/make.profile
.
, /etc/make.
globals make.defaults. /etc/make.conf, . /etc/make.conf.example.
, Portage .
Portage ,
.
3.1.1.2. ,
/etc/make.profile. ,
, , /usr/portage/profiles,
. , , , .
Portage, , ,
, ( ) ,
..
3.1.1.3. ,
Portage ,
, /etc/portage.
/etc/portage, Portage
!
/etc/portage :
1.

package.mask,

, Portage ;

197

Gentoo Linux x86


2.

package.unmask,

, ,
Gentoo ;

3.

package.keywords, , , -

4.

package.use,

, ();

USE-, , .

/etc/portage, ,
, Portage:
234. Portage
$ man portage

3.1.1.4. Portage
Portage . Portage
: , , Portage,
..
, , /etc/make.conf. , Portage ,
.
. ,
, Portage make.conf:
235. Portage make.conf
$ man portage
$ man make.conf

3.1.2.
3.1.2.1. Portage
Portage , , /usr/portage.
PORTDIR. Portage - ( ), /etc/make.profile.
PORTDIR, :
PKGDIR, DISTDIR, RPMDIR, PORTDIR.
Portage.
3.1.2.2.
, Portage , . Portage -

198

Gentoo Linux x86


, /usr/portage/packages. PKGDIR.
3.1.2.3.
/usr/portage/distfiles . DISTDIR.
3.1.2.4. RPM
, Portage RPM-,
ebuild (. Ebuild). Portage RPM /usr/portage/rpm,
RPMDIR.
3.1.2.5. Portage
Portage ( , . .) /var/db/pkg. !
Portage.
3.1.2.6. Portage
Portage ( , , . .) /var/cache/edb. :
, , Portage.

3.1.3.
3.1.3.1. Portage
Portage /var/tmp. PORTAGE_TMPDIR.
PORTAGE_TMPDIR,
BUILD_PREFIX, PORTAGE_TMPDIR. Portage.
3.1.3.2.
Portage /var/tmp/portage. BUILD_PREFIX.
3.1.3.3.
Portage (/), , ROOT.
.

199

Gentoo Linux x86

3.1.4.
3.1.4.1. Ebuild
Portage ebuild, ,
PORT_LOGDIR , Portage ( portage).
.

3.2.
3.2.1. Portage
, Portage ,
/etc/make.conf.
make.conf:
236. make.conf
$ man make.conf

3.2.2.
3.2.2.1.
Portage , :
1.

CFLAGS

2.

CHOST

3.

MAKEOPTS

CXXFLAGS C C++;

make . make
make.

USE , .
3.2.2.2.
Portage (merge) ,
. Portage 5-
. 5 CLEAN_DELAY.

200

Gentoo Linux x86

3.2.3.
3.2.3.1. , Portage
Portage , , ,
.
CONFIG_PROTECT. , . .
, , ,
() .
CONFIG_PROTECT emerge --info:
237. CONFIG_PROTECT
$ emerge --info | grep 'CONFIG_PROTECT='

, Portage,
emerge:
238.
$ emerge --help config

3.2.3.2.
, CONFIG_PROTECT_MASK.

3.2.4.
3.2.4.1.
, Portage
.
:
GENTOO_MIRRORS , (distfiles);
PORTAGE_BINHOST ,
(prebuilt packages) ;
rsync,
:
SYNC , Portage .
GENTOO_MIRRORS SYNC mirrorselect.
, , , emerge mirrorselect. mirrorselect:

201

Gentoo Linux x86


239. mirrorselect
# mirrorselect --help

-,
HTTP_PROXY, FTP_PROXY RSYNC_PROXY.
3.2.4.2.
Portage , wget. FETCHCOMMAND.
Portage . wget, RESUMECOMMAND.
, FETCHCOMMAND RESUMECOMMAND
. \${URI} \${DISTDIR}, distfiles, .
, FETCHCOMMAND_HTTP, FETCHCOMMAND_FTP, RESUMECOMMAND_HTTP, RESUMECOMMAND_FTP, ..
3.2.4.3. rsync
rsync, Portage ,
, :
1.

RSYNC_EXCLUDEFROM

, / , rsync
.

2.

RSYNC_RETRIES

3.

RSYNC_TIMEOUT

, rsync ,
SYNC. 3.
, rsync , rsync . 180,
, ,
300 .

3.2.5. Gentoo
3.2.5.1.
ACCEPT_KEYWORDS. . Gento .
3.2.5.2. Portage
Portage FEATURES. Portage
.

202

Gentoo Linux x86

3.2.6. Portage
3.2.6.1.
PORTAGE_NICENESS nice,
Portage. PORTAGE_NICENESS nice.
nice :
240. nice
$ man nice

3.2.6.2.
NOCOLOR ( false) , Portage .

3.3.
3.3.1.
3.3.1.1.
ACCEPT_KEYWORDS , .
, x86
. ,
Gentoo, http://bugs.gentoo.org, .
3.3.1.2.
, . Portage , ~ .
: .
, , , ,
. , - .
, .
, ,
( / ), ( ) . ,
Gentoo ,
.

203

Gentoo Linux x86


, x86, /etc/make.conf
:
241. ACCEPT_KEYWORDS
ACCEPT_KEYWORDS="~x86"

, , . , , ,
(, ).

3.3.2.

3.3.2.1. package.keywords
, Portage ,
. ,
, /etc/portage/package.keywords.
( ) , . , gnumeric:
242. /etc/portage/package.keywords gnumeric,
app-office/gnumeric ~x86

3.3.2.2.
, , Portage
,
package.keywords . =.
, <=, <, > >=.
, , .
, .
Portage gnumeric-1.2.13:
243. gnumeric
=app-office/gnumeric-1.2.13 ~x86

3.3.3.
3.3.3.1. package.unmask
Gentoo . , . , package.unmask /
package.mask, . .

204

Gentoo Linux x86


Gentoo,
, package.mask ( /usr/
portage/profiles), /etc/portage/package.unmask (
, ).
, =net-mail/hotwayd-0.8 , ,
package.unmask :
244. /etc/portage/package.unmask
=net-mail/hotwayd-0.8

3.3.3.2. package.mask
, Portage - ,
, /etc/portage/package.
mask ( ).
, , , Portage , gentoosources-2.6.8.1, package.mask:
245. /etc/portage/package.mask
>sys-kernel/gentoo-sources-2.6.8.1

3.4. Portage
3.4.1. etc-update
etc-update , ._cfg0000_<>.
. ._cfg0000_<> Portage, ,
CONFIG_PROTECT.
etc-update :
246. etc-update
# etc-update

, , . :
247. etc-update
Please select a file to edit by entering the corresponding number.
(-1 to exit) (-3 to auto merge all remaining files)
(-5 to auto-merge AND not use 'mv -i'):
(, , .
(-1 - ) (-3 - )
(-5 'mv -i'): )

205

Gentoo Linux x86


-1, etc-update , . -3 -5,
. ,
, .
, .
, /etc/pear.conf:
248.
Beginning of differences between /etc/pear.conf and /etc/._cfg0000_pear.conf
[...]
End of differences between /etc/pear.conf and /etc/._cfg0000_pear.conf
1) Replace original with update
2) Delete update, keeping original as is
3) Interactively merge original with update
4) Show differences again

. , , 1. , , , 2.
, 3.
. ,
, .
( , ) ,
:
249. ,
ed:
eb:
el:
er:
e:
l:
r:
s:
v:
q:

,







,

,
. etc-update , , .

3.4.2. dispatch-conf
dispatch-conf , . dispatch-conf RCS.
etc-update, , , . ,
dispatch-conf :
1.

, ;

2.

, .

206

Gentoo Linux x86


, /etc/dispatch-conf.conf ,
archive-dir.
dispatch-conf:
250. dispatch-conf
$ man dispatch-conf

3.4.3. quickpkg
quickpkg , . . quickpkg : ,
.
, curl, arts procps:
251. quickpkg
# quickpkg curl arts procps

$PKGDIR/All ( /usr/portage/packages/All). , , $PKGDIR/<>.

3.5.
3.5.1. Portage
3.5.1.1. /
/, /. / rsync
emerge --sync.
, ,
RSYNC_EXCLUDEFROM /etc/make.conf.
252. /etc/make.conf
RSYNC_EXCLUDEFROM=/etc/portage/rsync_excludes

253. /etc/portage/rsync_excludes
games-*/*

, , ,
, .

207

Gentoo Linux x86

3.5.2. ebuild
3.5.2.1.
Portage , Portage.
( , /usr/local/portage), ebuild . , !
PORTDIR_OVERLAY /etc/make.conf, . Portage,
, / emerge --sync.
3.5.2.2.
, ,
ebuild , app-portage/gentoolkit-dev
gensync, .
gensync, . /etc/gensync/ .syncsource,
, , ..
, java (
, java) entapps ( , ). :
254. gensync
# gensync java entapps

3.5.3. , Portage
3.5.3.1. Portage
, , Portage, ,
Portage. nVidia. Portage , , .
, Portage /etc/portage/profile/
package.provided.
, Portage, vanilla-sources-2.6.11.6 ,
/etc/portage/profile/package.provided:
255. package.provided
sys-kernel/vanilla-sources-2.6.11.6

208

Gentoo Linux x86

3.6. ebuild
3.6.1. Emerge Ebuild
ebuild Portage.
ebuild. , .
ebuild ,
(.). , , ebuild Portage , - ,
.

3.6.2.
3.6.2.1.
, ebuild - ebuild-,
Manifest files/digest-<>-<>.
.
ebuild, :
256.
# ebuild //-ebuild fetch

md5 , Manifest,
files/digest<>,
, :
257. ebuild
!!! File is corrupt or incomplete. (Digests do not match)
>>> our recorded digest: db20421ce35e8e54346e3ef19e60e4ee
>>> your file's digest: f10392b7c0b2bbc463ad09642606a7d6
(!!! . ( ) )

.
, ebuild ,
, Manifest digest-<e>, digest ebuild:
258. Manifest digest
# ebuild //-ebuild digest

209

Gentoo Linux x86

3.6.2.2.
/var/tmp/portage ( , /etc/
make.conf), unpack ebuild:
259.
# ebuild //-ebuild unpack

src_unpack() ebuild ( , src_unpack() ).


.
3.6.2.3.
.
src_compile() . , .
260.
# ebuild //-ebuild compile

, src_compile().
, Portage, , ebuild
. .compile
.
261. Portage
# touch .compiled

3.6.2.4.
.
, . ,
ebuild, src_install() .
262.
# ebuild //-ebuild install

3.6.2.5.

Portage. ebuild qmerge, :
1.

pkg_preinst(), ;

2.

210

Gentoo Linux x86


3.

Portage;

4.

pkg_postinst(), ;

qmerge ebuild, :
263.
# ebuild //-ebuild qmerge

3.6.2.6.
, , clean ebuild:
264.
# ebuild //-ebuild clean

3.6.3. Ebuild
3.6.3.1.
merge ebuild, , , , :
265.
# ebuild //-ebuild merge

3.6.3.2.
.
, , , . , config() ,
config ebuild:
266.
# ebuild //-ebuild config

3.6.3.3. (RPM)
Portage RPM , package rpm, . :
1.

package merge, (, , , ) ;

211

Gentoo Linux x86

2.

rpm RPM install


ebuild.

267.
(c , Portage)
# ebuild //-ebuild package
( RPM)
# ebuild //-ebuild rpm

RPM, , ebuild.

3.6.4.
Portage, ebuild ebuild
man:
268.
$
$
$
$

man
man
man
man

portage
emerge
ebuild
5 ebuild

( Portage)
( emerge)
( ebuild)
( ebuild)

, , , (.).

4. Gentoo
4.1.
4.1.1.

, , . , eth0,
eth1, wlan0 ..

, baselayout-1.11.11 .

, Gentoo RC.
net.lo net.eth0 /etc/init.d.

212

Gentoo Linux x86


269. net.lo net.eth0
# cd /etc/init.d
# ln -s net.lo net.eth0

Gentoo RC . , . /etc/conf.d/net.
DHCP .
270. /etc/conf.d/net
# DHCP
config_eth0=( "dhcp" )
# IP-, CIDR
config_eth0=( "192.168.0.7/24" )
routes_eth0=( "default via 192.168.0.1" )
# IP-,
config_eth0=( "192.168.0.7 netmask 255.255.255.0" )
routes_eth0=( "default gw 192.168.0.1" )

, DHCP.

CIDR Classless InterDomain Routing ( ). , IPv4 A, B C.


, . CIDR , IP-
IP-. IP- CIDR IP- ; , 192.168.0.0/16. CIDR RFC 1519.

, , :
271.
# /etc/init.d/net.eth0 start
# /etc/init.d/net.eth0 stop

RC_VERBOSE="yes" /etc/conf.d/rc
.

, , ,
Gentoo. . rc Gentoo,
.
272.
# rc-update add net.eth0 default
# rc

213

Gentoo Linux x86

4.2.
4.2.1.
config_eth0 . ( , eth0).
. , .
:

null

noop

,
.

an IPv4 or IPv6 address

dhcp, adsl or apipa( - , . ,


)
dhcp , . , dhcp , DHCP, dhcpcd, udhcpc, dhclient pump.

.
.
. .
273.
# IPv4
config_eth0=(
"192.168.0.2/24"
"192.168.0.3/24"
"192.168.0.4/24"
)
# IPv4 IPv6
config_eth0=(
"192.168.0.2/24"
"4321:0:1:2:3:4:567:89ab"
"4321:0:1:2:3:4:567:89ac"
)
# , , .
# DHCP. DHCP ,
# , APIPA
config_eth0=(
"noop"
"dhcp"
)
fallback_eth0=(
"null"
"apipa"
)

214

Gentoo Linux x86

ifconfig ,
. , , , eth0, eth0:1 eth0:2. , ,
eth0:1 eth0:2 eth0.

! null, apipa noop.

APIPA DHCP .

4.2.2.
/etc/init.d (net). RC_NET_STRICT_CHECKING /etc/conf.
d/rc, net .

none

net

no

, net.*, net.lo, . , WIFI


, , .

lo

, no, net.lo.
, ,
.

yes

, net .

net.br0, net.eth0 net.eth1? net.eth1 , . /etc/init.d/net.br0, net.lo.


depend() /etc/conf.d/net.
274. net.br0 /etc/conf.d/net
# (use, after, before),
#
depend_br0() {
need net.eth0 net.eth1
}

215

Gentoo Linux x86



Gentoo.

4.2.3.
. variable_${interface|
mac|essid|apmac}. , dhcpcd_eth0 dhcpcd eth0,
dhcpcd_essid dhcpcd,
ESSID essid.
, , , ethx. , wlanx, rax ethx. ,
, , , , , foo. , , -; ,
ESSID.
, Gentoo bash,
bash - .
, , -,
: _.
bash : ,
\. : ", ' \.
ESSID,
. ESSID My "\ NET:
275.
# ,
dns_domain_My____NET="My \"\\ NET"
# dns My "\ NET
# ESSID My "\ NET.

4.3.
4.3.1.
. , , .
, , , . ,
, , .
, , , , .

216

Gentoo Linux x86

/etc/conf.d/net, .

276.
# iproute2, ifconfig
modules=( "iproute2" )
#
# udhcpc, dhcpcd
modules_eth0=( "udhcpc" )
# , : ,
# , supplicant linux-wlan-ng
# ,
# ESSID
modules=( "!iwconfig" )

4.3.2.
: ifconfig iproute2.
.
1.

ifconfig Gentoo , .

2.

iproute2 , .

277. iproute2
# emerge sys-apps/iproute2
# iproute2, ifconfig,
modules=( "iproute2" )

ifconfig iproute2 , . , , .
278. ifconfig iproute2
config_eth0=( "192.168.0.2/24" )
config_eth0=( "192.168.0.2 netmask 255.255.255.0" )
#
config_eth0=( "192.168.0.2/24 brd 192.168.0.255" )
config_eth0=( "192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" )

4.3.3. DHCP
DHCP ( IP, DNS, ..) .
, DHCP, ,

217

Gentoo Linux x86


DHCP, . ,
( , - ..), DHCP.
DHCP dhclient, dhcpcd, pump udhcpc. DHCP
: .
DHCP

dhclient

net-misc/dhcp

ISC, - , BIND DNS. ,


.
,
NTP DHCP,
.

dhcpcd

net-misc/dhcpcd

Gentoo - , ,
.
,
.

pump

net-misc/pump

,
.
, ,
,

NIS DHCP.

udhcpc

net-misc/udhcp

;

DHCP, .



; 3
.

DHCP , , ;
dhcpcd, .
DHCP, _eth0="..." ( DHCP, , dhcpcd_eth0).
DHCP : ,
, dhcp_eth0. .
release IP-
nodns /etc/resolv.conf
nontp /etc/ntp.conf
nonis /etc/yp.conf
279. DHCP /etc/conf.d/net
# DHCP
modules=( "dhcpcd" )
config_eth0=( "dhcp" )
dhcpcd_eth0="-t 10" # 10
dhcp_eth0="release nodns nontp nonis" #

218

Gentoo Linux x86

, dhcpcd, udhcpc pump DHCP,


.

4.3.4. ADSL
ADSL.
280. rp-pppoe
# emerge net-dialup/rp-pppoe

baselayout-1.11.x PPPoE. , PPPoA.

, eth0 ADSL-, ,
/etc/conf.d/net.
281. eth0 ADSL /etc/conf.d/net
config_eth0=( "adsl" )
adsl_user_eth0="-"

, /etc/ppp/pap-secrets.
282. /etc/ppp/pap-secrets
# *
"" *

""

4.3.5. APIPA ( IP-)


2APIPA 169.254.0.0-169.254.255.255,
arp. , .
, DHCP, ,
APIPA.
APIPA net-misc/iputils net-analyzer/arping.
283. APIPA /etc/conf.d/net
# DHCP, APIPA
config_eth0=( "dhcp" )
fallback_eth0=( "apipa" )
# APIPA
config_eth0=( "apipa" )

219

Gentoo Linux x86

4.3.6.
(bonding) net-misc/ifenslave.
.
, , ,
, .
284. /etc/conf.d/net
#
slaves_bond0="eth0 eth1 eth2"
# IP
config_bond0=( "null" )
# eth0, eth1 eth2,
#
depend_bond0() {
need net.eth0 net.eth1 net.eth2
}

4.3.7. ( 802.1d)
net-misc/bridge-utils.
. , ,
ADSL-,
ADSL . , .
285. /etc/conf.d/net
# : "man btctl"
brctl_br0=( "setfd 0" "sethello 0" "stp off" )
# br0
bridge_br0="eth0 eth1"
# "null", dhcp
config_eth0=( "null" )
config_eth1=( "null" )
# , ; DHCP
config_br0=( "192.168.0.1/24" )
# eth0 eth1,
#
depend_br0() {
need net.eth0 net.eth1
}

220

Gentoo Linux x86

4.3.8. MAC-
MAC- ,
sys-apps/baselayout-1.11.14 , MAC- - .
, MAC- , baselayout ,
emerge net-analyzer/macchanger.
286. MAC-
# MAC-
mac_eth0="00:11:22:33:44:55"
# 3
mac_eth0="random-ending"
#
# (, , )
mac_eth0="random-samekind"
#
# (, , )
mac_eth0="random-anykind"
# ; , MAC-,
# , ,
mac_eth0="random-full"

4.3.9.
,
.
287. /etc/conf.d/net
# GRE
iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255"
# IPIP
iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"
#
config_vpn0=( "192.168.0.2 peer 192.168.1.1" )

4.3.10. ( 802.1q)
VLAN, net-misc/vconfig.
(VLAN) , ,
, . VLAN
VLAN .

221

Gentoo Linux x86


288. VLAN configuration in /etc/conf.d/net
# VLAN
# , , VLAN
vlans_eth0="1 2"
# VLAN
# man vconfig
vconfig_eth0=( "set_name_type VLAN_PLUS_VID_NO_PAD" )
vconfig_vlan1=( "set_flag 1" "set_egress_map 2 6" )
#
config_vlan1=( "172.16.3.1 netmask 255.255.254.0" )
config_vlan2=( "172.16.2.1 netmask 255.255.254.0" )

VLAN
.

4.4.
4.4.1.
wireless-tools
wpa_supplicant. , ,
.
1.

wpa_supplicant , .
wpa_suppliant. , wpa_supplicant
, SSID .

2.

wireless-tools , , WPA.

linux-wlan-ng baselayout. - , linuxwlan-ng , .


linux-wlan-ng, , wireless-tools; ,
linux-wlan-ng baselayout.

4.4.2. WPA
WPA (WPA Supplicant) ,
WPA. , ,
-.
289. wpa_supplicant
# emerge net-wireless/wpa_supplicant

222

Gentoo Linux x86

wpa_supplicant CONFIG_PACKET.

/etc/conf.d/net wpa_supplicant
wireless-tools ( , , wireless-tools).
290. /etc/conf.d/net wpa_supplicant
# wpa_supplicant
modules=( "wpa_supplicant" )
# wpa_supplicant, ,
#
wpa_supplicant_eth0="-D-wifi"

: host-ap,
(managed mode), wpa_supplicant.
iwconfig_eth0="mode managed" /etc/conf.d/net.
, ? , wpa_supplicant, . , . /etc/wpa_supplicant.conf.example, wpa_supplicant.

223

ap_scan=1
# : WPA-PSK, - ,
#
Gentoo Linux x86
network={
ssid=""
psk=" "
#
,

291.
/etc/wpa_supplicant.conf
priority=5
}
# , SSID
# ( , SSID)
network={
ssid=" ssid"
scan_ssid=1
psk=" "
priority=2
}
# WPA-PSK;
network={
ssid=""
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
priority=2
}
# ( WPA, IEEE #802.1X)
network={
ssid="--"
key_mgmt=NONE
}
# WEP ( WPA, IEEE #802.1X)
network={
ssid="--wep"
key_mgmt=NONE
wep_key0="abcde"
wep_key1=0102030405
wep_key2="1234567890123"
wep_tx_keyidx=0
priority=5
}
# WEP ( WPA, IEEE #802.1X),
# c IEEE 802.11
network={
ssid="2--wep"
key_mgmt=NONE
wep_key0="abcde"
wep_key1=0102030405
wep_key2="1234567890123"
wep_tx_keyidx=0
priority=5
auth_alg=SHARED
}
# IBSS/ad-hoc WPA-None/TKIP
network={
ssid=" adhoc"
mode=1
proto=WPA
key_mgmt=WPA-NONE
pairwise=NONE
group=TKIP
psk=" "
}

224

Gentoo Linux x86

4.4.3. Wireless tools


4.4.3.1.
Wireless Tools ,
WEP. WEP , .
Wireless Tools . , , , . ,
.
-.
292. wireless-tools
# emerge net-wireless/wireless-tools

/etc/conf.d/wireless, /etc/conf.d/net.

293. iwconfig /etc/conf.d/net


# iwconfig wpa_supplicant
modules=( "iwconfig" )
# WEP ESSID1 ESSID2
# 4 WEP, 1
# , [1], [1],
# , [1].
# , ESSID WEP-,
# [1].
#
# s: , , #
#
# enc open ( )
# enc restricted ( )
key_ESSID1="[1] s:-- key [1] enc open"
key_ESSID2="[1] aaaa-bbbb-cccc-dd key [1] enc restricted"
#
# .
# ,
#
preferred_aps=( "ESSID1" "ESSID2" )

4.4.3.2.
,
.

225

Gentoo Linux x86


, , . , , , . associate_order.
:

any

preferredonly

forcepreferred

forcepreferredonly

forceany

, forcepreferred +

, blacklist_aps unique_ap. blacklist_aps preferred_aps.


unique_ap yes no, , , .
294. blacklist_aps unique_ap
#
#
blacklist_aps=( "ESSID3" "ESSID4" )
# , ,
#
# - "yes" "no"
# - "yes"
unique_ap="yes"

4.4.3.3.
(ad hoc),
, .
295.
adhoc_essid_eth0=" "

Ad-Hoc (master),
? ! WEP-,
.

226

Gentoo Linux x86


296. ad-hoc/master
# : managed (, ),
# ad-hoc () master ().
#
mode_eth0="ad-hoc"
# ESSID
#
# ESSID,
essid_eth0=" "
# , 3
channel_eth0="9"

BSD wavelan, NetBSD.


14 . , 1 11
, 1 13 , 10 13 ,
14 . ,
. (
ad-hoc). ,
, 3; , 11; ,
14.

4.4.3.4. wireless tools


, , - . , :

iwconfig_eth0

iwconfig iwconfig.

iwpriv_eth0

iwpriv
iwpriv

sleep_scan_eth0

. ,
.

sleep_associate_eth0


( )

associate_test_eth0

MAC


MAC-, ,
.
-

227

Gentoo Linux x86

. : MAC,
quality all.

scan_mode_eth0


ad-hoc.
,
ad-hoc.

iwpriv_scan_pre_eth0

iwpriv .
iwpriv.

iwpriv_scan_post_eth0

iwpriv .
iwpriv.

4.4.4. ESSID
IP ESSID1, DHCP ESSID2. ,
ESSID. :

: WPA Supplicant Wireless Tools.

297. ESSID
config_ESSID1=( "192.168.0.3/24 brd 192.168.0.255" )
routes_ESSID1=( "default via 192.168.0.1" )
config_ESSID2=( "dhcp" )
fallback_ESSID2=( "192.168.3.4/24" )
fallback_route_ESSID2=( "default via 192.168.3.1" )
# .
# : DHCP ,
dns_servers_ESSID1=( "192.168.0.1" "192.168.0.2" )
dns_domain_ESSID1="some.domain"
dns_search_domains_ESSID1="search.this.domain search.that.domain"
# - ;
# , ESSID
config_001122334455=( "dhcp" )
dhcpcd_001122334455="-t 10"
dns_servers_001122334455=( "192.168.0.1" "192.168.0.2" )

228

Gentoo Linux x86

4.5.
4.5.1. -
, (start) (stop).
,
.
, ,
preup() predown() (). preup()
, . predown() , .
postup() postdown() , .
1.

${IFACE}

/ .

2.

${IFVAR}

${IFACE}, , bash.

229

Gentoo Linux x86


298. / /
preup() {
# .
#
# mii-diag.
if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then
ewarn " ${IFACE} , "
return 1
fi
# .
#
# ethtool.
if ethtool ${IFACE} | grep -q 'Link detected: no'; then
ewarn " ${IFACE} , "
return 1
fi
# 0
return 0
}
predown() {
# - NFS
# . ,
# predown(), .
# , ...
if is_net_fs /; then
eerror " - ${IFACE} "
return 1
fi
# 0
return 0
}
postup() {
# , ,
# DNS. - /
# .
return 0
}
postdown() {
# ... ,
# ;-)
return 0
}

4.5.2. - wireless tools

WPA Supplicant, ${ESSID} ${ESSIDVAR}


postup().

, (associate).
,
.

230

Gentoo Linux x86


, , preassociate() (). preassociate() , .
postassociate() , .
${ESSID}

${ESSID},

ESSID , . ${ESSIDVAR}
, bash.

299. /
preassociate() {
# , leap_user_ESSID
# leap_pass_ESSID. ESSID,
# CISCO LEAP
local user pass
eval user=\"\$\{leap_user_${ESSIDVAR}\}\"
eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\"
if [[ -n ${user} && -n ${pass} ]]; then
if [[ ! -x /opt/cisco/bin/leapscript ]]; then
eend " LEAP, emerge net-misc/cisco-aironet-client-utils"
return 1
fi
einfo " LEAP \"${ESSID//\\\\//}\""
if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then
ewarn " ${user} "
return 1
fi
fi
return 0
}
postassociate() {
# ... ,
# ;-)
return 0
}

${ESSID} ${ESSIDVAR} predown() postdown().

4.6.
4.6.1.
,
Ethernet . , , Ethernet .
, .

231

Gentoo Linux x86

ifplugd, , ,
quickswitch.

4.6.2. ifplugd
ifplugd , Ethernet. c
.
300. ifplugd
# emerge sys-apps/ifplugd

ifplugd . : /etc/conf.
d/ifplugd. man ifplugd.
301. ifplug
#
INTERFACES="eth0"
AUTO="no"
BEEP="yes"
IGNORE_FAIL="yes"
IGNORE_FAIL_POSITIVE="no"
IGNORE_RETVAL="yes"
POLL_TIME="1"
DELAY_UP="0"
DELAY_DOWN="0"
API_MODE="auto"
SHUTDOWN="no"
WAIT_ON_FORK="no"
MONITOR="no"
ARGS=""
# ifplugd .
# , ,
#
MONITOR_wlan0="yes"
DELAY_UP_wlan0="5"
DELAY_DOWN_wlan0="5"

232

Gentoo

1. X.org ................................................................................................................................. 234


: http://ylsoftware.com/?action=news&na=viewfull&news=130
C : 1.0
: MooSE
: 22.11.2006
Gentoo . .
, Gentoo.
.
Gentoo Handbook ( Gentoo . :
).
Gentoo , . Gentoo "" , .
Gentoo
.
Handbook Gentoo. ( X ALSA) Gentoo Wiki.
(WiKi) ( : ) ( -) ( : , , (FAQ), -(HOWTO)).
:
1.

. .

2.

- (), .

3.

4.

, .

233

Gentoo
5.

, ,
, . .

6.

( ) .

- .
, , .
. Wiki , ; -
.
ALSA, Advanced Linux Sound Architecture Linux, - MIDI- (Musical Instrument Digital Interface ) Linux. ALSA 2.6, OSS (Open Sound System ),
2.4
X- ( )
. Gentoo
( Linux ), ? , , :-). Linux
, .
, : , .
Linux - . , .
, , , ,
X Window System, X11 X. Unix, Linux
Unix- .
, Linux X11, Xorg-X11, XFree86.
XFree86 , , GPL, Xorg. XFree86 .

1. X.org
X.org X11 . , X11.
Xorg
. , Xorg ,
, .
,
IRC.

234

Portage

1.
2.
3.
4.
5.

Portage ..................................................................................................
? .............................................................................................
? .....................................................................................................
.................................................................................................................
........................................................................................................

235
236
236
237
237

Gentoo , Portage, .
, (
, ). Portage USE- .
KDE GNOME USE /etc/make.conf "kde -gnome". USE- Gentoo Handbook.
Portage emerge. moo
: emerge moo. Portage , , . ,
ebuild', . ebuild'
/usr/portage.

1. Portage
Gentoo USE. Midnight
Commander X.Org X. KPDF KDE?
KDE pdf ( KGhostScript).
emerge --ask --verbose ( emerge -av)
USE- . gentoolkit (emerge gentoolkit) euse,
USE1. euse -i flag "flag". man- euse ( . :-)).
1

: ufed (: emerge ufed) USE

235

Portage
USE-
USE="some flags" emerge moo. , . USE- /etc/portage/package.use, echo "category/moo some flags" >> /etc/portage/package.use .
ACCEPT_KEYWORDS /etc/portage/package.keywords. Portage 2.1
package.use package.keywords .

2. ?
ebuild', () Portage
, Portage. , Portage. ebuild Portage
CVS. , ebuild bugzilla. , ebuild.
ebuild .
ebuild', () Portage.
ebuild' (/usr/portage),
.
, , /usr/portage. ebuild. PORTDIR_OVERLAY="/path/to/local/overlay" /etc/make.
conf.
/usr/local/overlays. ebuild'
/usr/local/overlays/local. /usr/local/overlays.
, , , ebuild', . xgl-coffee ,
XGL. /usr/local/overlays/xgl-coffee
SVN.
Gentoo Wiki.
.

3. ?
. .
packages.gentoo.org gentoo-portage.com ( RSS).
!
, emerge some-package, /var/lib/
portage/world. emerge --update --deep world

236

Portage
. .
.
- world.
, , wxWidgets, world. emerge --update (...)
world, emerge --depclean.
wxWidgets world .
, world .
world --oneshot.
- .

4.
emerge /var/log/emerge.log.
tail /var/log/emerge.log. genlop (emerge genlop)
. genlop -c

.

5.
/var/tmp/
portage. .
/var/tmp/portage .
/usr/portage/distfiles. eclean gentoolkit. .
, . ( eclean-dist ecleanpkg ). man .
Gentoo .

.
.

237

3. Gentoo


Gentoo Linux ................................................................................................................. 243
1. Gentoo ..................................................................................... 243
1.1. Gentoo .................................................................................................. 243
1.2. ...................................................................................... 244
1.3. ...................................................................... 245
HOWTO .............................................................................................. 247
1. /var/lib/portage/world ........................................................................ 247
2. profile ............................................................................................................... 248
3. USE- .......................................................................................................................... 248
4. ( toolchain) ....................................... 248
5. emerge -U -u .................................................. 248
6. toolchain ........................................................... 249
7. . ................................................................................................... 250
8. . .................................................................................... 250
9. . ........................................................................................................ 251
Gentoo Linux GCC ............................................................................... 252
1. ............................................................................................................................... 252
1.1. GCC ....................................................................................................... 252
2. ........................................................................................... 253
2.1. .................................................................................................................... 253
3. GCC-3.3 3.4 .......................................................................... 254
3.1. .................................................................................................................... 254
3.2. .................................................................................................................... 254
3.3. revdep-rebuild ..................................................................................... 255
3.4. emerge -e ........................................................................................... 255
4. GCC ................................................................................... 256
4.1. .................................................................................................................... 256
4.2. revdep-rebuild ..................................................................................... 257
4.3. emerge -e ........................................................................................... 257
4.4. ...................................................................................................................... 258
5. ................................................................................................................... 258
5.1. ................................................................ 258
Gentoo ( 2) ........................................................................................ 260
1. Gentoo ............................................................. 260
1.1. Portage .......................................................................................................... 261
1.2. Portage ...................................................................................................... 261
1.3. ............................................................................ 262
1.4. ? ................................................................................... 262
1.5. .......................................................................................... 263
1.6. . ................................................................................................. 263
1.7. Portage ............................................................................................................... 264
1.8. ...................................................................................... 264
1.9. .............................................................................................. 264
1.10. ........................................................................ 265
1.11. ............................................................................................. 265
1.12. ................................................................... 265
................................................................................... 267
1. : ............................................................................................... 268

239

Gentoo
2. . ..........................................................................................................
3. USE- ............................................................................................................................
4. =) ......................................................................
4.1. : ................................................................................
5. "Masked" . ..................................................................................................................
6. . ', DE. ...............................................................................................
Gentoo ..................................................................................................................................
1. 2.6: ..............................................................................................
1.1. .................................................................................
2. Gentoo Linux ............................................
2.1. ....................................................................................................................
2.2. ...........................................................
2.3. .....................................................................................
2.4. ...............................................................
2.5. ................................................................................................................
3. ..................................................................
3.1. ....................................................................................................................
4. mplayer ................................................................................................................................
5. XMMS ..................................................................................................................................
6. Mozilla .................................................................
6.1. Navigator(Seamonkey/Firefox) .....................................................................................
6.2. Firefox Seamonkey .................................................................
6.3. .................................................................................
6.4. Firefox Seamonkey. ..................................................................
6.5. Thumbnail' .......................................................
7. IDE hdparm ................................................................
7.1. ....................................................................................................................
7.2. IDE ................................................................................
7.3. ...................................................................................................................
7.4. ..............................................................................................................
8. .................................................................................................
8.1. ....................................................................................................................
8.2. .................................................................................................
8.3. ...........................................................................................................
8.4. .................................................
8.5. ..............................................................
rpm- Gentoo ...............................................................................................
UTF-8 Gentoo ........................................................................................................
1. .....................................................................
2. .............................................................................................................................
2.1. ? .................................................................................................
2.2. .....................................................................................
2.3. ? ....................................................................................................
2.4. UTF-8 .........................................................................................................................
2.5. UTF-8 ..............................................................................
3. UTF-8 Gentoo Linux ........................................................................................
3.1. UTF-8 ...........................................................................
3.2. .......................................................................................................
4. ....................................................................................................
4.1. , NTFS FAT .......................................................................................
4.2. .....................................................................................................
4.3. ncurses slang ............................................................................................................

240

269
269
271
271
272
273
274
274
275
275
276
277
278
279
281
281
281
281
282
282
282
283
283
284
284
284
284
285
286
287
287
288
288
288
289
290
291
294
294
295
295
295
296
296
296
297
297
297
298
299
300
300

Gentoo
4.4. KDE, GNOME Xfce ................................................................................................. 301
4.5. X11 ........................................................................................................... 301
4.6. ............................................................ 302
4.7. Vim, Emacs, Xemacs Nano ....................................................................................... 302
4.8. .................................................................................................. 302
4.9. Irssi ............................................................................................................................. 303
4.10. Mutt .......................................................................................................................... 303
4.11. Man ........................................................................................................................... 303
4.12. elinks links ............................................................................................................. 303
4.13. Samba ....................................................................................................................... 304
4.14. ................................................................................... 304
4.15. ......................................................................................................... 304
Gentoo Linux .......................................................................... 306
1. ............................................................................................................................... 306
1.1. .................................................................................. 306
1.2. ..................................................................................... 307
2. ............................................................................................. 307
2.1. .................................................................................................................... 307
2.2. ..................................................................................... 307
2.3. ............................................................................... 308
2.4. (mapscreen) ................................................................. 309
2.5. ............................................................................... 309
3. locale ....................................................................................................... 310
3.1. locale ru_RU.KOI8-R ................................................................................. 310
4. ..................................................................................................... 312
4.1. .................................................................................... 312
4.2. ...................................................................... 312
5. X .......................................................................................... 312
5.1. .................................................................................................................... 312
5.2. xf86config ................................................... 313
5.3. ........................................................................... 314
5.4. .................................................. 315
udev Gentoo .......................................................................................................... 316
1. udev? .................................................................................................................... 316
1.1. /dev .............................................................................................................. 316
1.2. namedev ...................................................................................................................... 317
1.3. libsysfs ........................................................................................................................ 318
1.4. udev ............................................................................................................................ 318
2. udev Gentoo ........................................................................................... 318
2.1. ................................................................................................ 318
2.2. ............................................................................................................ 319
3. ............................................................................................................ 320
3.1. .......................................... 320
3.2. udev nvidia .............................................................................................................. 320
3.3. LVM2 ...................................................................................... 321
3.4. DevFS udev ................................................................... 321
3.5. ....................................................................................................... 322
4. .................................................................................... 322
............................................................................. 323
1. devfs? .................................................................................................................... 323
1.1. (?) ......................................................................................... 323
1.2. ................................................................................................................... 324

241

Gentoo
1.3. ..................................................................................................................... 324
1.4. devfs ? ............................................................................ 324
2. ....................................................................................... 325
2.1. ................................................................................................................ 325
2.2. o devfsd ............................................................. 326
3. .................................................................................. 326
3.1. devfsd ................................................................................................... 326
3.2. compatibility symlinks .................................................................................. 326
3.3. ............................................. 327
4. , ............................................................................. 327
4.1. / PAM ............................................... 327
4.2. / devfsd ............................................. 328
4.3. devfsd .......................................................... 328
HOWTO fbsplash ............................................................................................................................... 330
1. .............................................................................................................................. 331
1.1. gensplash? ................................................................................................... 331
1.2. fbsplash (framebuffer splash)? ...................................................................... 331
1.3. frame buffer? ............................................................................ 331
2. fbsplash splashutils ............................................................................................. 331
2.1. ................................................................................................ 332
2.2. .................................................................................................... 332
2.3. () ...................................................................................... 332
2.4. / ( genkernel) ............................... 333
2.5. splashutils ................................................................................................... 333
2.6. / ( ) ..................................................... 333
3. initramfs .................................................................................................... 334
3.1. initramfs? .................................................................................................... 334
3.2. initramfs ................................................ 334
3.3. initramfs ....................................................................... 335
3.4. gensplash ................................................................... 335
3.5. bootsplash gensplash ................................................................... 336
3.6. gensplash ................................................................ 336
4. .......................................................................................................... 337
4.1. ......................................................................................................... 337
4.2. Grub ....................................................................................... 338
4.3. Lilo ........................................................................................ 338
5. ......................................................................................... 339
6. Gensplash ................................................................................... 339
6.1. ............................................................................................... 339
6.2. 3 .......................................................................... 340
7. ................................................................................................................. 340
7.1. /usr .................................................................................. 340
7.2. ............................................................................. 340
8. .................................................................................................................................. 341

242

Gentoo Linux

1. Gentoo .............................................................................................
1.1. Gentoo ..........................................................................................................
1.2. ..............................................................................................
1.3. ..............................................................................

243
243
244
245

1. Gentoo
: http://www.gentoo.org/doc/en/gentoo-upgrading.xml
: 1.2
: vnp, , , ., a.k.a JohnBat26

1.1. Gentoo
1.1.1.
, Gentoo, , Linux. ,
, ,
: , , , , , .
( Gentoo), , .
apt apt-rpm, , ,
.
Gentoo, Gentoo
.

243

Gentoo Linux
, , : Portage Gentoo, ,
. , , .

1.1.2.
Gentoo : ,
?". :
.
GRP, ,
(stage3 + ), .
, ,
.
, , , , ,
.
, /usr/portage/profiles, ebuild , (USE) ,
, , .
/etc/make.profile,
/usr/portage/profiles, . , x86 2007.0
/usr/portage/profiles/default-linux/x86/2007.0. (, , ). .
, , /usr/portage/profiles , .
deprecated. , . Portage
.
:
(, baselayout, gcc, glibc), USE- , , , .

1.2.
1.2.1.
Gentoo, , , :).
,
Gentoo.

244

Gentoo Linux

1.2.2.
(, , 2007.0 x86),
.
, , ,
, Gentoo.
, Gentoo , . , , . ,
.
. , , .
, /etc/make.profile, , .
. , .

1.2.3.
, Gentoo
eselect (emerge eselect) :
1.
# eselect profile list

1.3.
1.3.1. .

, !

, emerge eselect. eselect


.
2. eselect
( )
# eselect profile list
( )
# eselect profile set < >

245

Gentoo Linux
, :
3. .
# rm /etc/make.profile
# ln -s ../usr/portage/profiles/< > /etc/make.profile

: desktop server.
, ,
.

1.3.2. 2007.0 2006.1


, , Unicode. , UNICODE="yes" /etc/rc.conf. Unicode
. , UTF-8 guide .
, , UNICODE="no"
/etc/rc.conf. (re-emerge) baselayout (
) USE : -unicode. -unicode baselayout
, USE /etc/make.
conf.
4. : Unicode.
( Unicode baselayout)
# echo "sys-apps/baselayout -unicode" >> /etc/portage/package.use
# emerge -a baselayout
( Unicode )
# nano -w /etc/make.conf
USE="-unicode"
# emerge -a baselayout

2007.0 SPARC, GCC Upgrading


Guide

246

HOWTO

1. /var/lib/portage/world ................................................................................
2. profile .......................................................................................................................
3. USE- ..................................................................................................................................
4. ( toolchain) ...............................................
5. emerge -U -u ..........................................................
6. toolchain ...................................................................
7. . ...........................................................................................................
8. . ............................................................................................
9. . ................................................................................................................

247
248
248
248
248
249
250
250
251

:
http://ru.gentoo-wiki.com/HOWTO___
: 1.2

1. /
var/lib/portage/world
world , ,
"system" (.. ).
1.

world , .., ,
- ( / ,
- ) ;

2.

, "system", world

3.

world , /etc/portage/package.
mask;

4.

regenworld world /var/log/emerge.log world ( world!) ;

247

HOWTO
5.

dep -p -w ( udept) world ( world system);

6.

/etc/portage/*, ..
.

2. profile
1.

Gentoo release profile (, 2004.1 profile).

2.

profile , ( ,
"" (deprecated) emerge ).

3.

profile : http://www.gentoo.org/doc/ru/gentooupgrading.xml /etc/make.profile.

3. USE-
1.

emerge -uDpv --newuse world USE-


,

USE- /etc/make.conf /etc/portage/package.use.

4. (
toolchain)
1.

emerge -puDav --newuse world

toolchain (linux-headers, glibc, binutils gcc),


.
:
emerge -uDav --newuse world

5.
emerge -U -u
1: SLOT

248

HOWTO
, , , gimp-2 gimp-1.2.
, gimp-1.2 stable SLOT 1, gimp-2 unstable SLOT
2. ACCEPT_KEYWORDS=~x86 emerge gimp gimp-2.
, , - "emerge
-U world", gimp-1.2, , gimp world-, "-U"
SLOT .
2: , ebuild- Portage-.
, Portage 2 foo, foo-1.4 ( stable) foo-1.6 ( unstable). unstable emerge, gimp. world ,
foo-1.6 foo-1.6.1. .
1.

foo-1.6 Portage. foo-1.4, ""


"-U"

2.

, foo-1.6 Portage - : foo-1.6


(, ) ,
stable - foo-1.6.

: ACCEPT_KEYWORDS=~x86 emerge foo http://www.gentoo.org/doc/ru/gentoo-amd64-faq.xml#keyword.

6.
toolchain
1.

- linux-headers, glibc, binutils gcc,


, system, world.

toolchain toolchain
. system/world
, (
toolchain . ).
system/world toolchain. system world - , .. world system.

1.

gcc, gcc-config gcc


" ", .

2.

system toolchain toolchain system. world system

249

HOWTO
system world. ,
[1], `emerge -k` (
).
3.

, :

1.
# , `emerge -k`
#
# (., /tmp/portage-packages)
pkgdir=$(portageq pkgdir)
mv $pkgdir /tmp/portage-packages1
install -d -o portage -g portage $pkgdir
# toolchain
emerge linux-headers glibc binutils gcc-config gcc
# gcc
gcc-config ____gcc
# . `gcc-config -l`
source /etc/profile
# toolchain
emerge -b glibc binutils gcc portage
# glibc, binutils gcc
emerge -bke system
# ( system)
emerge -bke world

: binutils-config, - gcc-config.

7. .

: emerge -uDav --newuse world


!
glsa-check -l | grep '\[N\]'
emerge ... #

8. .
, . , .. emerge -uDav --newuse world.

250

HOWTO
emerge -a depclean # !!!

1.

, :

: glsa-check, revdep-rebuild gentoolkit

rm /root/.revdep-rebuild*.?_*
revdep-rebuild -p
revdep-rebuild

9. .
dispatch-conf
1.

runit-init baselayout, /sbin/init:

ls -l /sbin/*init*
if (/sbin/init , ) {
mv /sbin/init /sbin/init-sysv
ln -s runit-init /sbin/init
}

1.

emerge world ,
, .
log- emerge world.
enotice, portlog-info.

251

Gentoo
Linux GCC

1. .......................................................................................................................................
1.1. GCC ...............................................................................................................
2. ...................................................................................................
2.1. ............................................................................................................................
3. GCC-3.3 3.4 ..................................................................................
3.1. ............................................................................................................................
3.2. ............................................................................................................................
3.3. revdep-rebuild .............................................................................................
3.4. emerge -e ...................................................................................................
4. GCC ..........................................................................................
4.1. ............................................................................................................................
4.2. revdep-rebuild .............................................................................................
4.3. emerge -e ...................................................................................................
4.4. ..............................................................................................................................
5. ...........................................................................................................................
5.1. ........................................................................

252
252
253
253
254
254
254
255
255
256
256
257
257
258
258
258

: http://www.gentoo.org/doc/ru/gcc-upgrading.xml
: 1.0

1.
1.1. GCC
? , GCC ,
. GCC , - , ,
. , , GCC Gentoo.

252

Gentoo Linux GCC


GCC, . , . , Portage , .
, , Gentoo. GCC 3.3 3.4
libstdc++. ,
Gentoo (stage3), GCC.

, GCC-3.4 GCC-4.0
, GCC-3.4 GCC-4.0
(ABI). , gcc-config, .

2.
2.1.

GCC-3.3 GCC-3.4 ,
.

GCC ,
.

, (bugfix release), 3.3.5 3.3.6, : , libtool. , GCC ,


, , .
, ,
. ,
( 3.3.5 3.3.6), multislot,
. ,
c.

253

Gentoo Linux GCC


1. GCC
# emerge -uav gcc
( "i686-pc-linux-gnu-3.4.5"
GCC CHOST)
# gcc-config i686-pc-linux-gnu-3.4.5
# source /etc/profile
( libtool)
# emerge --oneshot -av libtool

, world, .
2.
# emerge -eav system
# emerge -eav world

GCC. ,
( , =sys-devel/gcc-3.3* , ):
3. GCC
# emerge -aC =sys-devel/gcc-3.3*

3. GCC-3.3
3.4
3.1.
GCC-3.3 3.4 ,
C++ (ABI).
libstdc++.

3.2.

GCC SPARC, (ABI) GCC


.

. revdep-rebuild gentoolkit, , -

254

Gentoo Linux GCC


GCC. , .
.

3.3. revdep-rebuild
, gentoolkit, .
GCC . libtool,
.
4. gentoolkit GCC
# emerge -an gentoolkit
# emerge -uav gcc
( "i686-pc-linux-gnu-3.4.5"
GCC CHOST)
# gcc-config i686-pc-linux-gnu-3.4.5
# source /etc/profile
( libtool)
# emerge --oneshot -av libtool

, revdep-rebuild. revdep-rebuild
. , .
5. revdep-rebuild
# revdep-rebuild --library libstdc++.so.5 -- -p -v
# revdep-rebuild --library libstdc++.so.5

, - ,
. revdep-rebuild --packagenames. , ,
.

C++ ,
revdep-rebuild , sys-libs/libstdc++-v3 ,
GCC 3.3 .
6. libstdc++-v3 GCC
# emerge --oneshot sys-libs/libstdc++-v3
# emerge -aC =sys-devel/gcc-3.3*

3.4. emerge -e
, ,
, , , . GCC libtool,
.

255

Gentoo Linux GCC


7. GCC
# emerge -uav gcc
( "i686-pc-linux-gnu-3.4.5"
GCC CHOST)
# gcc-config i686-pc-linux-gnu-3.4.5
# source /etc/profile
( libtool)
# emerge --oneshot -av libtool

C++,
sys-libs/libstdc++-v3.
8. libstdc++-v3
# emerge --oneshot sys-libs/libstdc++-v3

system, world. ,
:
, , . , ,
.
9. system world
# emerge -e system
# emerge -e world

GCC, :
10.
# emerge -aC =sys-devel/gcc-3.3*

4. GCC
4.1.
GCC (stage3) . , GCC , .
GCC-3.3 3.4 . GCC - .
, , revdep-rebuild, GCC 3.3, ,
libstdc++-v3.
- ,
GCC . , GCC-3.3 3.4,
. , GCC-3.3 3.4, ,
. , revdep-rebuild

256

Gentoo Linux GCC


gentoolkit, . revdep-rebuild
, GCC,
GCC,
. , .
, .
11. GCC
# emerge -uav gcc
( "i686-pc-linux-gnu-3.4.5"
GCC CHOST)
# gcc-config i686-pc-linux-gnu-3.4.5
# source /etc/profile
( libtool)
# emerge --oneshot -av libtool

C++,
sys-libs/libstdc++-v3.
12. libstdc++-v3
# emerge --oneshot sys-libs/libstdc++-v3

4.2. revdep-rebuild
, gentoolkit, . revdep-rebuild, ,
.
13. gentoolkit revdep-rebuild
# emerge -an gentoolkit
# revdep-rebuild --library libstdc++.so.5 -- -p -v
# revdep-rebuild --library libstdc++.so.5

, - ,
. revdep-rebuild --packagenames. , ,
.

4.3. emerge -e
, , , ,
. , ,
CFLAGS make.conf, .
, world, . -

257

Gentoo Linux GCC


, , , world
system.
14. system
# emerge -e system

4.4.
GCC, . ---GCC
, :
15.
# emerge -aC "<sys-devel/gcc----GCC"

5.
distcc.
. ccache,
.
GCC .
world GCC, (, app-emulation/qemu-softmmu)
. , , GCC.
GCC SPARC, silo -f
world, .

5.1.
- libtool: link: `/usr/lib/gcc-lib/i686-pc-linuxgnu/3.3.6/libstdc++.la' is not a valid libtool archive, /sbin/fix_libtool_files.sh 3.3.6
( 3.3.6 ).
error: /usr/bin/gcc-config: line 632: /etc/env.d/gcc/i686-pc-linux-gnu-3.3.5:
No such file or directory, /etc/env.d/gcc/config-i686-pc-linux-gnu
gcc-config, source /etc/profile. ,
-.
emerge -e system emerge -e world ,
emerge --resume. , , emerge -resume --skipfirst. emerge, , .

258

Gentoo Linux GCC


spec failure: unrecognized spec option,
, GCC_SPECS :
16.
#
#
#
#

gcc-config 1
source /etc/profile
unset GCC_SPECS
emerge -uav gcc

259


Gentoo ( 2)

1. Gentoo ....................................................................
1.1. Portage ..................................................................................................................
1.2. Portage ..............................................................................................................
1.3. ....................................................................................
1.4. ? ...........................................................................................
1.5. ..................................................................................................
1.6. . .........................................................................................................
1.7. Portage .......................................................................................................................
1.8. ..............................................................................................
1.9. .....................................................................................................
1.10. ................................................................................
1.11. .....................................................................................................
1.12. ...........................................................................

260
261
261
262
262
263
263
264
264
264
265
265
265

: http://lxj.endofinternet.net/column/gentoo-tips/
C : 1.5
:
: 12.02.2008
Linux.com Gentoo (Gentoo Portage
secrets Tips for new Gentoo users), ,
digg, !
(, ,
90%), . , , ,
:)

1.
Gentoo
, . , Gentoo
, Gentoo Handbook.

260

Gentoo ( 2)
, , , Sabayon, .
, Gentoo
Gentoo .
Handbook Gentoo. ALSA,
Gentoo Documentation Resources.
, Gentoo wiki.
-, Gentoo wiki , ,
IRC-.
, .
, , - . : Handbook, , Gentoo Wiki.
Gentoo Gentoo.ru (
IRC-), Linux LinuxForum.

1.1. Portage
. . Handbook,
? .

1.2. Portage
Gentoo USE-.
, USE-. Midnight Commander X.org? X. KDE KPDF?
pdf. ( - KGhostScript?
, KDE4 )
, , , emerge ask verbose (-av) (ask pretend ,
). gentoolkit , euse,
USE-. euse -i flag, ,
, . man euse, (,
, ).
- USE-,
USE="some flags" emerge moo, :
. USE-
/etc/portage/package.use ( , , . ).
moo category some flags, echo "category/
moo some flags" >> /etc/portage/package.use .
ACCEPT_KEYWORD /etc/portage/package.keywords.
Portage 2.1, package.keywords,
, /etc/portage/package.keywords.
/etc/portage.

261

Gentoo ( 2)

1.3.
( ), ( ) Portage.
, ebuild, CVS-.
ebuild Gentoo Bugzilla. , -
ebuild, .
, , ebuild .
ebuild, Portage. ebuild /usr/portage . , , /usr/
portage. ebuild . /etc/make.conf, PORTDIR_OVERLAY="/path/to/local/overlay".
/usr/local/overlays, /usr/
local/overlays/local. /usr/local/overlays?
, .
/usr/local/overlays, ( ,
Portage, emerge --sync).
rsync, svn git, .
, layman.
rsync/svn/git layman -a -, , layman , ; layman -S, .
, layman , , Gentoo wiki. , , Unsupported software
Gentoo.

1.4. ?
emerge --sync layman -S . , , . http://packages.gentoo.org/
http://gentoo-portage.com/ ( RSS-), , ,
Portage ,
.
, glsa-check
gentoolkit. , glsa-check Portage. , , glsacheck -l affected. glsa-check -d < >,
( glsa-check -d affected)
, . ,
, .

262

Gentoo ( 2)
Gentoo Monthly Newsletter, , . RSS-
gentoo.org ( gentoo.ru) .
update :
1.

emerge;

2.

- , :
, ,
;

3.

( X B Y: emerge ,
A, update )

1.5.
, - , /var/lib/portage/
world. , - emerge --update --deep world
. , ; , , . -
, world.
, , wxWidgets,
, world.
, wxWidgets, emerge --update (...) world;
, emerge --depclean.
wxWidgets, , world.
udept world:
# emerge udept
# dep -aw

, , oneshot (-1). , , - .

1.6. .
, emerge --unmerge , .
emerge --depclean, ,
.
, , , , .
, .
, revdep-rebuild gentoolkit.

263

Gentoo ( 2)

1.7. Portage
emerge /var/log/emerge.log. , ,
, tail /var/log/emerge.log. python- ( tail /var/log/
emerge.log | formatlog).
genlop (emerge genlop) -.
, genlop -c , , .
elog.
, , emerge.
make.conf :
# This sets what to log
PORTAGE_ELOG_CLASSES="warn error log"
# And this is how to do it
PORTAGE_ELOG_SYSTEM="save"

/var/log/portage/elog.
. elog,
/etc/make.conf.example. .

1.8.
, /var/tmp/portage . , .
/usr/portage/distfiles. eclean gentoolkit, , . , ( eclean-dist
eclean-pkg ). .

1.9.
Portage (/ ), emerge
--search emerge --searchdesc, . eix.
Eix ( updateeix), ( , eix moo ,
moo ). , eix , emerge.
Eix , , ,
, .
, man.

264

Gentoo ( 2)

1.10.
. Portage. Deltup,
,
. 90% . Deltup Gentoo Wiki.
Deltup, , . , ,
, (, deltup,
. ,
deltup , ). Deltup , . , . ,
deltup , .
, Portage emerge-delta-webrsync:
, ,
emerge --sync ( ,
). emerge emerge-delta-webrsync, emerge-deltawebrsync ( ,
man?).
Gentoo wiki -.
, : parallel-fetch FEATURES /etc/make.conf, emerge , . ,
emerge .

1.11.
Gentoo. ,
, .
, Distcc .
Windows !
Ccache , , .
emerge, . Distcc Ccache.

1.12.
.
Handbook etc-update,
dispatch-conf. -

265

Gentoo ( 2)
, ( , ), ,
. , .
bash.org :
<@insomnia> it only takes three commands to install Gentoo
<@insomnia> cfdisk /dev/hda && mkfs.xfs /dev/hda1 && mount /dev/hda1 /mnt/gentoo/ &&
chroot /mnt/gentoo/ && env-update && . /etc/profile && emerge sync && cd /usr/portage &&
scripts/bootsrap.sh && emerge system && emerge vim && vi /etc/fstab && emerge gentoo-devsources && cd /usr/src/linux && make menuconfig && make install modules_install && emerge
gnome mozilla-firefox openoffice && emerge grub && cp /boot/grub/grub.conf.sample /boot/grub/
grub.conf && vi /boot/grub/grub.conf && grub && init 6
<@insomnia> thats the first one

266

1.
2.
3.
4.

: .......................................................................................................
. ..................................................................................................................
USE- ....................................................................................................................................
=) .............................................................................
4.1. : ........................................................................................
5. "Masked" . ..........................................................................................................................
6. . ', DE. .......................................................................................................

268
269
269
271
271
272
273

: http://gentoo.blog.ru/6345603.html#comments
C : 1.5
: gentoo
: 21.02.2008
http://gentoo.blog.ru/6345603.html

(, , )),
"! ! !")) , , -
, ,
;) , (!) (
) . , "
", ,
)) , ,
- , .
, , .
( emerge --sync), ( emerge -epv
world). , ', direct rendering, DE/WM. . , use-,
eix, elogv, , =)

267

: "desktop", use-,
desktop-.
,
desktop ,
( use-), -
.

: , emerge "pv" ( "av" ).


, () USE- .

1. :
# emerge emerge-delta-webrsync (
),
( ).
# emerge eix ( ) .
# eix-sync -Wv , emerge-delta-webrsync
&& update-eix portage ( , ,
).
# emerge -uDNvp world ( -uDNva) (
, ).
. , , , .
# emerge elogv
, . , (/etc/make.conf):
PORTAGE_ELOG_CLASSES="warn error log qa"
PORTAGE_ELOG_SYSTEM="save"

:
PORT_LOGDIR=/var/log/portage,


( , elogv).

: , (', Gnome, KDE) elogv , .


, . elogv dd, F1.

268


# emerge gentoolkit eclean, equery, eread, euse, glsa-check, revdep-rebuild.
Must have.

2. .
.
- :
* IMPORTANT: 2 config files in '...' need updating.

. etc-update,
dispatch-conf. , ,
, . , , .
- , , ( - ,
, , ).

3. USE-
3.1. C ... , ?
................................................................................................................................................
3.2. .. ? .......................................................................................
3.3. emerge gnome -pv ...................................................................................
3.4. .. ? .....................................................
3.5. : .......................................................................................................
3.6. >, , , ? ......................
3.1.

269
269
269
270
270
271

C ... , ?
, kopete (IM-).
, "irc" "yahoo". irc
yahoo, .

3.2.

.. ?
, . USE- , .

3.3.

emerge gnome -pv


.., ... ?
% . , () , () ,
, .
.
( ).

269


* , ,
.
:
[ebuild

UD] app-emulation/wine-0.9.49 [0.9.57]

wine ( 0.9.57,
use- "gecko" "samba", , 0.9.49).
"java" , ,
, .USE- ()
.
3.4.

.. ?
, , /etc/make.conf, ( ). _, - :
# emerge <_> -pv

use- , . (). ( ). =)
make.conf ,
. /etc/portage/package.use : / [ -]
(app-misc/mc 7zip -X -gpm -ncurses slang)
.
make.conf (X, kde, gnome, alsa, etc...)
- package.use. use- .
make.conf ", kde, gnome, samba" .. (, "
"), - mc
... =) , ,
.
, ufed.
make.conf , emerge,
, : EMERGE_DEFAULT_OPTS="--ask --verbose"
, make.conf package.use.
, , make.conf,
package.use. .
- make.conf.
:
# emerge ufed ncurses-based use-.
() ufed /etc/make.conf.
, ( ), .
3.5.

:
270


# USE="" emerge <>

, , , ( ) USE="-" emerge <> .


3.6.

>, , , ?
, , -...
)) ))
deltup, yandex make.conf:
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/ ";

( ).

4.
=)
, world (/var/lib/portage/world), B C D,
,
.
# emerge -a depclean

.
:
# emerge -C _

B C D , .
,
# emerge -a -depclean

4.1. :
revdep-rebuild , ( ) () .

emerge -a -depclean.

271

5. "Masked" .
5.1. rawstudio, .
. , . ................................................................................................................. 272
5.1.

rawstudio, .
. , .
. ()
. , , ,
, 364 ;)
, :

1.

2.

.
:
# eix rawstu
* media-gfx/rawstudio
Available versions:
Homepage:
Description:

~0.6 ~0.7
http://rawstudio.org
a program to read and manipulate raw images from digital cameras.

, .. .
/ ~x86 /etc/portage/package.keywords, :
media-gfx/rawstudio ~x86
( ~x86 ~amd64, **)

: [M] .
# eix kde-meta
* kde-base/kde-meta
Available versions:
(3.5)
3.5.8 ~3.5.9
(kde-4) [M]~4.0.1 [M]~4.0.2

kde-4 ( ~), (M), .. .


... ;) , / /etc/portage/
package.unmask, :
kde-base/kde-meta

( , ).

272

6. . ', DE.
.
, ', - DE, .
emerge gnome emerge kde use-
, ', , . , ,
=)
:
emerge xorg-x11 ', , direct rendering'.
emerge ffmpeg imagemagick xine-lib mplayer , ( - ).
, / ,
. samba cups.
:
emerge gnome ( kde-meta) , KDE, .
, :
tail -f /var/log/emerge.log
, - =)
! , : http://www.gentoo.org/
doc/ru/handbook/
HandBook 2006.1 ru, HandBook 2007.0 en, Gentoo
http://gentoo.blog.ru/6345603.html

273

Gentoo

1. 2.6: ......................................................................................................
1.1. ........................................................................................
2. Gentoo Linux ....................................................
2.1. ............................................................................................................................
2.2. ...................................................................
2.3. .............................................................................................
2.4. .......................................................................
2.5. ........................................................................................................................
3. ..........................................................................
3.1. ............................................................................................................................
4. mplayer ........................................................................................................................................
5. XMMS ..........................................................................................................................................
6. Mozilla .........................................................................
6.1. Navigator(Seamonkey/Firefox) .............................................................................................
6.2. Firefox Seamonkey .........................................................................
6.3. .........................................................................................
6.4. Firefox Seamonkey. ..........................................................................
6.5. Thumbnail' ...............................................................
7. IDE hdparm ........................................................................
7.1. ............................................................................................................................
7.2. IDE ........................................................................................
7.3. ...........................................................................................................................
7.4. ......................................................................................................................
8. .........................................................................................................
8.1. ............................................................................................................................
8.2. .........................................................................................................
8.3. ...................................................................................................................
8.4. .........................................................
8.5. ......................................................................

1. 2.6:
: http://ru.gentoo-wiki.com/_2.6
: 1.5

274

274
275
275
276
277
278
279
281
281
281
281
282
282
282
283
283
284
284
284
284
285
286
287
287
288
288
288
289
290

Gentoo

1.1.
Linux : , , , .
/proc/sys/vm/swappiness , ( ) /proc/sys/vm/autoswappiness
. , ,
:
# echo 0 > /proc/sys/vm/autoswappiness

.
/proc/sys/vm/swappiness 0 100.
,
. :
# echo 100 > /proc/sys/vm/swappiness

60, 0,
. . 100 . ,
, , Andrew Morton, Linux, ,
(, ) 100, .. ,
. ,
, Linux , , 100 . , , . ,
, ;)
, , /etc/
sysctl.conf
1. : /etc/sysctl.conf
vm.swappiness=100

, 100 , .

2.
Gentoo Linux
: http://www.gentoo.org/doc/ru/prelink-howto.xml
C : 1.0
: 1.5

275

Gentoo

2.1.
2.1.1. (Prelink)
?
.
, .
. , C++, , .
, , , .
, ,
. , ld-linux.so glibc; glibc >= 2.3.1-r2
. , KDE 50% . ,
.

2.1.2.
, , , prelink.
, .
, , ,
.
, prelink
undo.
portage , prelink, MD5 mtime .
glibc-2.3.1-r2 ,
binutils-2.13.90.0.xx .

276

Gentoo

2.2.

2.2.1.

, Gentoo-1.4, gcc-3.2
binutils-2.13.90.0.xx. , .

glibc 2.3.1 , prelink


!

, .
2.
# emerge sync

, , portage-2.0.26 . ,
portage . .. MD5
.
3.
# emerge ">=portage-2.0.46"

emerge . emerge , .
4.
# emerge prelink

, , emerge prelink.
, , . , binutils, gcc
glib. emerge .
: , prelink (./configure ; make ; make check).
*.log . .

277

Gentoo
, , Stefan Jones.

2.2.2.
Portage /etc/prelink.conf, prelink
.
, ,
binutils. ,
, /opt. , ,
prelink .
5. /etc/env.d/99prelink
PRELINK_PATH_MASK="/opt"

, , .

2.3.
2.3.1.
, /etc/prelink.conf.
6.
# prelink -afmR

, , . . file readelf
. df -h.

:
1.

-a

2.

-f

All, .

,
. .. prelink
, .

278

Gentoo
3.

-m

. , ,
.

4.

-R

Random, -- ,
.

, man prelink

2.4.
2.4.1. "
, PIC"
,
gcc -fPIC.
,
emerge, .
7.
( ORBit /usr/lib/libIIOP.so.0.5.17)
# emerge ">=sys-apps/tcp-wrappers-7.6-r4" ORBit
( zlib /usr/lib/libz.so.1.1.4)
# emerge ">=sys-libs/zlib-1.1.4"
( svgalib, /usr/lib/libsvga.so.xx)
# emerge ">=media-libs/svgalib-1.9.16"
( XFree openGL, libGLU.so.1)
# emerge ">=x11-base/xfree-4.2.1-r2"
( libpcap.so.0.6)
# emerge ">=net-libs/libpcap-0.7.1-r2"
( lcms, /usr/lib/liblcms.so.1)
# emerge ">=media-libs/lcms-1.09"

zlib / tcp-wrappers,
emerge , , emerge .

Qt/KDE,
x11-base/xfree 4.2.1-r2 x11-libs/qt 3.1.0-r1 . QT
, xinerama, myconf="no-xinerama ${myconf}" ebuild qt.
, :
1.

wine, windex.
MS Windows.

279

Gentoo
2.

media-video/mjpgtools, /usr/lib/liblavfile-1.6.so.0

, , , , -fPIC CFLAGS.

2.4.2. ,
, : "1631 Aborted ...."
-f prelink; ..
. prelink -af.

2.4.3. ": <file>: error while loading shared libraries:


unexpected reloc type..."
sys-libs/glibc-2.3.1-r2 2002/11/18, emerge glibc,
.
prelink -u -a -m ; prelink -a -m . ,
prelink -u <file>.

2.4.4. Nvidia openGL


openGL nvidia-glx ,
prelink . ,
o - nvidia. xfree libGL.so, 3D. xfree nvidia .

2.4.5. ,

glibc, 100% . glib,


. Dick Howell.
" ,
. , Linux, ,
GLIBC, . "libnss" (name service switch - , , network secutiry system - ) , . . , GLIBC
. "libnss" . , , , -
GLIBC , "libpthread, "libm" "libc",
"libnss""

280

Gentoo

2.4.6.
"prelink: dso.c:306: fdopen_dso: Assertion `j == k'
failed."
, . prelink
UPX. prelink-20021213
, .
, , .

2.5.
. . , .. , -
. glibc ,
, prelink. , !

3.

: http://ru.gentoo-wiki.com/
: 1.5

3.1.
Linux - "", ..
. ,
, Linux - . . , .
(hdparm, -)

4. mplayer
1.

-vo xvidix -vo xv, CPU -

281

Gentoo
2.

mplayer ( emerge
mplayer -pv - ), mplayer .

3.


# hdparm -u1 -A1 -a 128 /dev/hda ( hda)

4.

nice mplayer -5 -10

5. XMMS
1.

mplayer XMMS

2.

output-buffer (- 2500-3000)
Preferences Output Plugin Configure Buffering Buffer size(ms)
,

()

3.

6.
Mozilla
: http://ru.gentoo-wiki.com/ Mozilla
: 1.5

6.1. Navigator(Seamonkey/Firefox)
Mozilla , ,
URL 'about:config'.
:
1.

network.http.pipelining

2.

network.http.pipelining.firstrequest

3.

network.http.pipelining.maxrequests

4.

network.http.proxy.pipelining

282

Gentoo

5.

nglayout.initialpaint.delay

pipelining .
- . , network.http.pipelining,
network.http.pipelining.firstrequest network.http.proxy.pipelining true.
network.http.pipelining.maxrequests . , .. ,
12. , , nglayout.initialpaint.delay ,
.
0 .. .
:
. , ( New ).
browser.turbo.enabled

'true'

1.

network.http.max-connections-per-server

2.

network.http.max-persistent-connections-per-proxy

3.

network.http.max-persistent-connections-per-server

'8'

6.2. Firefox Seamonkey


Firefox 1.5.x Seamonkey 1.0.x
.
..
, about:config
1.

browser.cache.memory.enable

false.

2.

browser.cache.memory.capacity

, - integer, . , (memory disk)


about:cache .

6.3.
/ :

283

Gentoo
1.

browser.chrome.favicons

boolean

2.

browser.chrome.site_icons

boolean

( , [favicon.ico , site_icon ]). gentoo.ru favicon, mult.ru ( , )


favicons site_icons.

6.4. Firefox Seamonkey.


Firefox
. Seamonkey ,
,
.
1.

browser.chrome.load_toolbar_icons

integer

6.5. Thumbnail'

thumbnail
,
, favicon( ).
1.

browser.chrome.image_icons.max_size

, 1024 ( ?),
, 0.

7. IDE
hdparm
: http://www.opennet.ru/base/sys/htparm_tune.txt.html
: 1.5

7.1.
- IDE ,
.

284

Gentoo
IDE ,
.

7.2. IDE
IDE :
# hdparm -i /dev/hda

/dev/hda IDE

Max Mult Sect: , .


Mult Sect: , .
PIO modes DMA modes: , . ,
(*), .
Advanced PM: 'yes' , APM (Advanced Power
Management ).
, :
darkstar:$ hdparm /dev/hda

:
/dev/hda:
multcount = 0 (on)
I / O? support = 0 (16-bit)
unmaskirq = 0 (off)
using_dma = 0 (off)
keepsettings = 0 (off)
nowerr = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 2482/255/63, sectors = 39876480, start = 0

...
1.

multcount , ;

2.

I/O support (16/32/32sync);

3.

using_dma , DMA ;

4.

keepsettings , ( , , );

5.

readonly 1 CD-ROM,
read-only ;

6.

readahead ;

285

Gentoo

7.3.

, .

7.3.1. I/O Support


-0

16- (-)

-c1

32- ( , )

-c3

32- ( , )

7.3.2. Multicount
( ). , Max Mult Sect hdparm -i. .

7.3.3. DMA
HDD DMA .
DMA , .
, DMA , , , .
-d0

DMA

-d1

DMA

7.3.4. DMA mode PIO mode


.
-X<>

PIO DMA

multiword DMA:
32 ( ) + :
-X32

mdma0

-X33

mdma1

-X34

mdma2

286

Gentoo
PIO 8, Ultra DMA? 64.
-X64

udma0

-X65

udma1

-X66

udma2

-X67

udma3

-X68

udma4

-X69

udma5

7.3.5. Readahead ( )
. , .
, multicount.
-aN

7.4.
:
# hdparm -t < >

, .
- , :
# hdparm -u1c1d1m8a8 < >

:
# hdparm -t < >

.
-a -m,
, . , ,
( IDE-,
), multicount (-m) , read-ahead (-a)
multicount.

8.
: http://ru.gentoo-wiki.com/

287

Gentoo
: 1.5

8.1.
Gentoo Linux - , . . ( ) .
.

8.2.
, ,
. /etc/conf.d/rc NO YES RC_PARALLEL_STARTUP.
8. : /etc/conf.d/rc
...
RC_PARALLEL_STARTUP="YES"
...

, baselayout emerge -u baselayout.

(
, ), NO.

() baselayout
echo "sys-apps/baselayout ~x86" >> /etc/portage/package.keywords emerge sync && emerge sys-apps/
baselayout -u
initng
# emerge sys-apps/initng

8.3.
, , (, , ).
ifplugd, , (,
). :
# emerge -n ifplugd

ifplugd :
# rc-update add ifplugd boot

288

Gentoo

8.4.

Gentoo , ,
, .
, .
:
9. : /etc/init.d/modules -
...
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
...

10. : /etc/init.d/modules -
...
if [ /etc/modules.d -nt /etc/modules.conf ]
then
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
else
einfo "Module dependencies are up-to-date"
fi
...

:
11. : /etc/init.d/bootmisc -
...
if [ -x /sbin/env-update.sh ]
then
ebegin "Updating environment"
/sbin/env-update.sh >/dev/null
eend 0
fi
...

12. : /etc/init.d/bootmisc -
...
if [ -x /sbin/env-update.sh ]
then
if [ /etc/env.d -nt /etc/profile.env ]
then
ebegin "Updating environment"
/sbin/env-update.sh >/dev/null
eend 0
else
einfo "Environment up-to-date"
fi
fi
...

289

Gentoo

baselayout, .. , .

8.5.
localmount,
, .
:
13. : /etc/init.d/localmount -
...
mount -at ... >/dev/null
...

14. : /etc/init.d/localmount -
...
mount -aFt ... >/dev/null
...

290

rpm Gentoo
: http://ylsoftware.com/?action=news&na=viewfull&news=402
: .. a.k.a. MooSe
: 1.5.
: 15.02.2008
Gentoo -
a.k.a JohnBat26. rpm- Gentoo. , ,
emerge. rpm ,
( ).
. rpm-:
1.

rpm .

2.

ebuild rpm-.

, --nodeps
. .
, .
prog-0.1.i386.rpm. ,
rpm:
emerge rpm

. :
rpm -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" prog-0.1.i386.rpm

:
/bin/bash
/bin/sh
/bin/sh
/bin/sh
/bin/sh
libX11.so.6
libXext.so.6
libXt.so.6
libc.so.6
libc.so.6(GCC_3.0)

291

rpm- Gentoo
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.2)
libc.so.6(GLIBC_2.1.3)
libc.so.6(GLIBC_2.2)
libc.so.6(GLIBC_2.3)
libdl.so.2
libdl.so.2(GLIBC_2.0)
libdl.so.2(GLIBC_2.1)
libfontconfig.so.1
libfreetype.so.6
libglib-2.0.so.0
libgobject-2.0.so.0
libgtk-x11-2.0.so.0
libm.so.6
libm.so.6(GLIBC_2.0)
libpthread.so.0
libpthread.so.0(GLIBC_2.0)
libpthread.so.0(GLIBC_2.1)
libpthread.so.0(GLIBC_2.2)
libpthread.so.0(GLIBC_2.2.3)
libpthread.so.0(GLIBC_2.3.2)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1

. - -
. , , rpm-:
rpm -Uvh --nodeps prog-0.1.i386.rpm

. . - ebuild. rpm portage rpm.


, /usr/portage/eclass/rpm.eclass. ebuild'
rpm:
# rpm
inherit rpm
#
DESCRIPTION="Cool prog"
HOMEPAGE="http://example.com"
SLOT="0"
KEYWORDS="~x86"
IUSE=""
RESTRICT="nomirror"
#
DEPENDS="x11-libs/qt"
#
SRC_URI="http://example.com/files/prog-0.1.i386.rpm"
# . .
# :
src_install() {
cp -vR ${S}/* ${D}/
}

ebuild ( portage) :
ebuild /path/to/file.ebuild digest
ebuild /path/to/file.ebuild merge

292

rpm- Gentoo
. . Gentoo ( ).
Alex .

293

UTF-8 Gentoo

1. ............................................................................. 294
2. ..................................................................................................................................... 295
2.1. ? ......................................................................................................... 295
2.2. ............................................................................................. 295
2.3. ? ............................................................................................................ 296
2.4. UTF-8 ................................................................................................................................. 296
2.5. UTF-8 ...................................................................................... 296
3. UTF-8 Gentoo Linux ................................................................................................ 297
3.1. UTF-8 ................................................................................... 297
3.2. ............................................................................................................... 297
4. ............................................................................................................ 298
4.1. , NTFS FAT ............................................................................................... 299
4.2. ............................................................................................................. 300
4.3. ncurses slang .................................................................................................................... 300
4.4. KDE, GNOME Xfce ......................................................................................................... 301
4.5. X11 ................................................................................................................... 301
4.6. .................................................................... 302
4.7. Vim, Emacs, Xemacs Nano ............................................................................................... 302
4.8. ......................................................................................................... 302
4.9. Irssi ..................................................................................................................................... 303
4.10. Mutt .................................................................................................................................. 303
4.11. Man ................................................................................................................................... 303
4.12. elinks links ..................................................................................................................... 303
4.13. Samba ............................................................................................................................... 304
4.14. ........................................................................................... 304
4.15. ................................................................................................................. 304
: http://www.gentoo.org/doc/ru/utf-8.xml
: 1.0

1.

Gentoo- . UTF-8.

294

UTF-8 Gentoo
.
UTF-8. .
, Gentoo,
( :)) :
gentoo-wiki
Gentoo
Gentoo
, .

2.
2.1. ?
. .
, (
), .

2.2.
( ) ASCII ( , American Standard Code for Information Interchange).
, ASCII
. ASCII 1986 (ANSI X3.4, RFC 20, ISO/IEC 646:1991,
ECMA-6) (American National Standards
Institute, ANSI).
ASCII , , ,
0 127. ASCII 32 ( 0
31) DEL ( delete) 127.
32 126 , , .
ASCII
. , 0. , ASCII
.
ASCII , , , .
ISO 8859. ASCII,
127 . ISO 8859
, . 15
ISO 8859 ( 8859-1 8859-15). ASCII- .
, Microsoft

295

UTF-8 Gentoo
Windows-1252, Windows. ISO
8859-1, . ASCII.
ASCII
, EUC (Extended Unix Coding), ( ) , , -
, Shift-JIS ISO-2022-JP. , , KOI8-R ( ) KOI8-U ( ), ISO 8859-5 Windows-1251. ASCII ( KOI8 ,
, ASCII ).
, . .

2.3. ?
. 17 ,
65 536 . ,
1 114 112. (Basic Multilingual Plane BMP) ,
, , 16- .
, UTF (Unicode
Transformation Format) UCS (Universal Character Set). UTF
, UCS . UTF-8
- () ,
.

2.4. UTF-8
UTF-8 . , . UTF-8 ASCII,
UTF-8 ASCII. UTF-8 , ASCII , .
(, ), ,
, 50 %.

2.5. UTF-8
UTF-8
, . UTF-8
-ASCII , , IRC- . , UTF-8 . , ,
Usenet UTF-8 , -ASCII
UTF-8.

296

UTF-8 Gentoo

3. UTF-8 Gentoo Linux


3.1. UTF-8
, , UTF-8 .
UTF-8 glibc . /etc/locale.gen.
, , .
Gentoo.
, , UTF-8 .
1. UTF-8
( "ru_RU" )
# locale -a | grep 'ru_RU'
ru_RU
ru_RU.UTF-8

, .UTF-8.
, , UTF-8.

, UTF-8 .

2. UTF-8
( "ru_RU" )
# localedef -i ru_RU -f UTF-8 ru_RU.UTF-8

UTF-8 /etc/locale.gen
locale-gen.
3. /etc/locale.gen
ru_RU.UTF-8/UTF-8

3.2.
, , UTF-8 : LANG
( LC_ALL).
. UTF-8 , ~/.profile ( /bin/sh), ~/.bash_profile
~/.bashrc ( /bin/bash).

297

UTF-8 Gentoo
.
/etc/init.d/xdm, , .
/etc/env.d/02locale. :
4. /etc/env.d/02locale
( , "ru_RU.UTF-8" )
LANG="ru_RU.UTF-8"

LC_ALL LANG. , .
. , LC_ALL . , LC_ALL, ,
GNU.

.
5.
# env-update
>>> Regenerating /etc/ld.so.cache...
* Caching service dependencies ...
# source /etc/profile

locale , , :
6.
# locale
LANG=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=ru_RU.UTF-8

. UTF-8,
.

4.
,
, C, .

298

UTF-8 Gentoo
UTF-8 . ,
!

4.1. , NTFS FAT


Linux NLS, !
, UTF-8 NLS
NLS utf8.
7. UTF-8 NLS
File Systems -->
Native Language Support -->
(utf8) Default NLS Option
<*> NLS UTF8
( <*> , FAT Joilet CD-ROM)

NTFS, nls=. FAT, codepage=. FAT . , codepage, ,


.
8. FAT
File Systems -->
DOS/FAT/NT Filesystems -->
(866) Default codepage for fat

Default iocharset for fat UTF-8, . utf8=true FAT. ,


man mount /usr/src/linux/Documentation/filesystems/vfat.txt.
, app-text/convmv.
9. convmv
# emerge --ask app-text/convmv
( )
# convmv -f <current-encoding> -t utf-8 <filename>
( koi8-r , )
# convmv -f koi8-r -t utf-8 filename

, iconv, glibc:
10. iconv
( koi8-r , )
( )
# iconv -f koi8-r -t utf-8 filename
( , )
# iconv -f koi8-r -t utf-8 filename > newfile

app-text/recode.

299

UTF-8 Gentoo

4.2.

>=sys-apps/baselayout-1.11.9 .

UTF-8 /etc/rc.conf
UNICODE="yes". ,
( ).
/etc/conf.d/keymaps KEYMAP Unicode.
11. /etc/conf.d/keymaps
( "ru4" )
( -u . )
KEYMAP="-u ru4"
( . )
DUMPKEYS_CHARSET="koi8-r"

, . X11 .

, .
12. /etc/conf.d/consolefont
( CONSOLEFONT)
CONSOLEFONT="ter-k14n" # terminus-font

4.3. ncurses slang

slang,
.

unicode USE- /etc/make.conf,


sys-libs/ncurses sys-libs/slang. Portage
:
13.
# emerge --update --deep --newuse world

, , USE . (revdep-rebuild) gentoolkit.

300

UTF-8 Gentoo
14. , ncurses slang
# revdep-rebuild --soname libncurses.so.5
# revdep-rebuild --soname libslang.so.1

4.4. KDE, GNOME Xfce



, , . , (Qt
GTK+2) UTF-8. , , ,
UTF-8 .
Xlib GTK+1. GTK+1 iso-10646-1 FontSpec ~/.gtkrc,
-misc-fixed-*-*-*-*-*-*-*-*-*-*-iso10646-1. , Xlib
Xaw, FontSpec, .

gnome1, .
iso10646-1.

15. ~/.gtkrc ( GTK+1), -


style "user-font"
{
fontset="-misc-fixed-*-*-*-*-*-*-*-*-*-*-iso10646-1"
}
widget_class "*" style "user-font"

Xorg 6.8.2 . Fantoo Gentoo-wiki Xorg 6.8.0.

Qt GTK+2, GTK+2 GUI .

4.5. X11

XFree86 x11-base/xorg-x11 , .

TrueType , , Xorg,
,
. (
Bitstream Vera) X-, USE- cjk. ,
.

301

UTF-8 Gentoo
Portage .
16. : -
# emerge terminus-font intlfonts freefonts cronyx-fonts corefonts

4.6.
, GTK Qt, ,
Xft. Xft, FontSpec,
.
, Xft, .
Konsole gnome-terminal, Portage x11-terms/rxvt-unicode, xfce-extra/terminal,
gnustep-apps/terminal, x11-terms/mlterm x11-terms/xterm, USE- unicode
uxterm. app-misc/screen UTF-8,
screen -U, ~/.screenrc:
17. ~/.screenrc UTF-8
defutf8 on

4.7. Vim, Emacs, Xemacs Nano


Vim UTF-8 UTF-8.
Vim :help mbyte.txt.
Emacs 22.x UTF-8. Xemacs 22.x .
Emacs / Xemacs app-emacs/mule-ucs / app-xemacs/
mule-ucs ~/.emacs CJK- UTF-8:
18. Emacs CJK UTF-8
(require 'un-define)
(require 'jisx0213)
(set-language-environment "Japanese")
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)

Nano UTF-8 1.3.6.

4.8.
bash GNU readline. Z
, .

302

UTF-8 Gentoo
C, tcsh ksh UTF-8.

4.9. Irssi
Irssi UTF-8, .
19. UTF-8 Irssi
/set term_charset UTF-8

, -ASCII -UTF-8 ,
/recode . /help recode .

4.10. Mutt
Mutt . UTF-8 Mutt,
- . Mutt
, , ( )
UTF-8.

Mutt. - , ,
. , .

.Mutt Wiki .

4.11. Man
Man- Linux. ,
, /etc/man.conf .
20. man.conf
( )
NROFF
/usr/bin/nroff -Tascii -c -mandoc
( )
NROFF
/usr/bin/nroff -mandoc -c

4.12. elinks links


, , UTF-8 .
elinks links Setup ()

303

UTF-8 Gentoo
. , -
elinks links Alt+S. (Setup Menu), (Terminal options), T.
UTF-8 I/O, Enter. . links
, Alt+S, S . .
21. UTF-8 elinks/links
( elinks /etc/elinks/elinks.conf ~/.elinks/elinks.conf )
set terminal.linux.utf_8_io = 1
( links ~/.links/links.cfg )
terminal "xterm" 0 1 0 us-ascii utf-8

4.13. Samba
Samba , SMB (Server Message Block) UNIX-
(Mac, Linux FreeBSD). Common Internet File System
(CIFS). Samba NetBIOS,
Windows-.
22. UTF-8 Samba
( /etc/samba/smb.conf [global])
dos charset = 866
unix charset = UTF-8
display charset = UTF-8

4.14.
, UTF-8. net-www/w3m, net-www/links, net-www/elinks, net-www/
lynx, , Mozilla ( Firefox) UTF-8. Konqueror
Opera UTF-8.
, ,
.
, , ,
. ,
UTF-8.
1.

W3C UTF-8

2.

4.15.
Dead keys , , X-.
, Alt ( AltGr), -

304

UTF-8 Gentoo
, (),
. Dead key . Shift
AltGr .
dead keys X, , .
dead keys . , . ,
en_US us. /etc/X11/xorg.conf:
23. /etc/X11/xorg.conf
Section "InputDevice"
Identifier "Keyboard0"
Driver
"kbd"
Option
"XkbLayout" "en_US" # "us"
( Xkb)
EndSection

,
, dead keys . - .

X-. ,
setxkbmap, , setxkbmap en_US.
dead keys . ,
. , , .
AltGr [, a .
AltGr [, e, . AltGr ;, , AltGr ;,
e, .
AltGr, Shift [, a, .
AltGr, Shift [, [ .
(U+02DA) (U+00B0), .
AltGr and [, [ .
AltGr . , AltGr
m : . AltGr s : . AltGr 4 ( E ), , ( ).

305


Gentoo Linux

1. ....................................................................................................................................... 306
1.1. .......................................................................................... 306
1.2. ............................................................................................. 307
2. ..................................................................................................... 307
2.1. ............................................................................................................................ 307
2.2. ............................................................................................. 307
2.3. ....................................................................................... 308
2.4. (mapscreen) ........................................................................ 309
2.5. ....................................................................................... 309
3. locale ............................................................................................................... 310
3.1. locale ru_RU.KOI8-R ......................................................................................... 310
4. ............................................................................................................. 312
4.1. ............................................................................................ 312
4.2. .............................................................................. 312
5. X .................................................................................................. 312
5.1. ............................................................................................................................ 312
5.2. xf86config ........................................................... 313
5.3. ................................................................................... 314
5.4. .......................................................... 315
: http://www.gentoo.org/doc/ru/guide-localization.xml
: 1.0

1.
1.1.
(
, ) , , ( locale).

306

Gentoo Linux
, , , , , .

( Linux-) ( X) .

1.2.
(charsets), , . Unix- , : Unix- ( Linux) KOI8R, ISO-8859-5 ( ), Unix-,
CP1251 ( Windows). , CP866 ( DOS). ,
UTF-8.
Gentoo Linux ( , ) KOI8-R,
. ISO-8859-5 CP1251
, . UTF-8, ,
, .

2.
2.1.
,
.
PC , ,
. , .

2.2.
, , /etc/rc.conf

1. ,
CONSOLEFONT="default8x16"

"" -
, , cp866-8x16 DOS koi8r-8x16
KOI8-R. ,

307

Gentoo Linux
2. cp866
CONSOLEFONT="cp866-8x16"


3. KOI8-R
CONSOLEFONT="koi8r-8x16"

( ) /usr/share/consolefonts/
*.gz, *.psf.gz *.psfu.gz. , ""
.

Linux' , , cp866 ( , ).
, , (, Midnight Commander) .

, Gentoo Linux,
( , Unix-). console-tools-cyrillic .

4.
CONSOLEFONT="UniCyr-sans"

2.3.
/etc/rc.conf
5. ,
KEYMAP="us"

, us
- ( KOI8-R) . ( *.map.gz) /usr/share/keymaps/i386/qwerty, KOI8R , , ru1-ru4.
(DOS Windows ) /. ru4
Windows- , CapsLock (
Shift+CapsLock).
:
6.
KEYMAP="ru4"

308

Gentoo Linux

,
"" .

cp1251 (, ru_win).

(mapscreen) cp1251->cp866.

, , , cp1251.

2.4. (mapscreen)
(KOI8-R) (cp866),
(mapscreen).
/etc/rc.conf. , , :
7. ,
#CONSOLETRANSLATION="cp437_to_iso01"

, ( #), "" ,
/usr/share/consoletrans koi2alt:
8. cp866->KOI8-R
CONSOLETRANSLATION="koi2alt"

, CONSOLETRANSLATION
:-)

- KOI8R, , , .

2.5.
, ( KOI8-R), (.. ) . ( Gentoo Linux

309

Gentoo Linux
5),
Escape- \033(K ( \ ,
). . , /etc/init.d/ consoletrans
:
9. mapscreen
for i in 1 2 3 4 5 6; do
echo -ne '\033(K' > /dev/vc/$i
done

6- . , in, , .

, baselayout-1.8.x ,
/etc/init.d/consolefont.

chmod a+x /etc/init.d/consoletrans , (default runlevel):


10. mapscreen
# rc-update add consoletrans default

, , (final
steps) Gentoo Linux, .

3. locale
3.1. locale ru_RU.KOI8-R
- , . Gentoo Linux -

310

Gentoo Linux
env-update,
.
/etc/env.d/02locale
11. LANG
LANG="ru_RU.KOI8-R"

locale, - .
env-update, /etc/profile,
source /etc/profile. locale

12. locale LANG
LANG=ru_RU.KOI8-R
LC_CTYPE="ru_RU.KOI8-R"
LC_NUMERIC="ru_RU.KOI8-R"
LC_TIME="ru_RU.KOI8-R"
LC_COLLATE="ru_RU.KOI8-R"
LC_MONETARY="ru_RU.KOI8-R"
LC_MESSAGES="ru_RU.KOI8-R"
LC_PAPER="ru_RU.KOI8-R"
LC_NAME="ru_RU.KOI8-R"
LC_ADDRESS="ru_RU.KOI8-R"
LC_TELEPHONE="ru_RU.KOI8-R"
LC_MEASUREMENT="ru_RU.KOI8-R"
LC_IDENTIFICATION="ru_RU.KOI8-R"
LC_ALL=

, ( ru),
(_RU) KOI8-R.
, env-update.

env-update , (login shell)


/bin/bash.
. , login shell zsh, ~/.zshenv .

LANG=ru_RU.KOI8-R ,
: ( XFree86)
, , .

, LANG - . . , , ,
locale POSIX, , locale ru_*. ,
/etc/env.d/02locale, LANG, :
13. LC_NUMERIC
LC_NUMERIC="POSIX"

311

Gentoo Linux
, :
14. LC_MESSAGES
LC_MESSAGES="POSIX"

4.
4.1.
BIOS Setup (UTC),
/etc/localtime , . , :
15.
# ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime

/usr/share/zoneinfo/
Europe ( ) /usr/share/zoneinfo/Asia (
). , - :

16. -
# ln -sf /usr/share/zoneinfo/Asia/Kamchatka /etc/localtime

4.2.
,
/etc/rc.conf, : CLOCK="UTC" CLOCK="local".

5. X
5.1.
X ( XFree86) : ( xf86config, -

312

Gentoo Linux
)
/etc/X11/XF86Config.

5.2.
xf86config
xf86config
XFree86 . ( ) , -
, .
(Enter a number to choose the country), ,
, . 8 Belarusian
70 Ukrainian , : 53 Russian
54 Russian (cyrillic phonetic). qwerty, ywerti, .
.
53 Russian .
(Please enter a variant name for 'ru' layout).
, Enter, , DOS- (, ); , , winkeys, Windows- ( Windows, cp1251).
, y, XKB (Do you want to select additional XKB options (group switcher, group indicator, etc.)?):
/ ( XFree86 ).

. :
17. /
1
2
3
4
5
6
7
8
9
10
11
12
13

R-Alt switches group while pressed


Left Win-key switches group while pressed
Right Win-key switches group while pressed
Both Win-keys switch group while pressed
Right Alt key changes group
Caps Lock key changes group
Menu key changes group
Left Win-key changes group
Right Win-key changes group
Both Shift keys together change group
Control+Shift changes group
Alt+Control changes group
Alt+Shift changes group

, . , () . , CapsLock (
ru4). (
), , Shift+CapsLock

313

Gentoo Linux

- ..
Windows-, .
XFree86
console-tools-cyrillic.

,
Control, (, CapsLock ScrollLock) .
, Enter.
, XFree86 ( ) xf86config /etc/X11/XF8
6Config.

5.3.
xf86config ,
/etc/X11/XF86Config.
Section "Files"
.

/etc/X11/XF86Config .

:
18.
FontPath
FontPath
FontPath
FontPath
FontPath
FontPath
FontPath
FontPath

"/usr/X11R6/lib/X11/fonts/local/"
"/usr/X11R6/lib/X11/fonts/misc/"
"/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
"/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
"/usr/X11R6/lib/X11/fonts/Type1/"
"/usr/X11R6/lib/X11/fonts/Speedo/"
"/usr/X11R6/lib/X11/fonts/75dpi/"
"/usr/X11R6/lib/X11/fonts/100dpi/"

.
XFree86 Cronyx,
/usr/X11R6/lib/X11/fonts/cyrillic/.
19.
FontPath

"/usr/X11R6/lib/X11/fonts/cyrillic/"

, , .

314

Gentoo Linux

Cronyx . , . ( ) . (TTF ATM) ,


OpenOffice Altlinux.

5.4.

XFree86 xf86config . Gentoo Linux


(, ), /etc/X11/XF86Config.
Section "InputDevice". ,
( X , ,
) , .. (rules),
. :
20.
Option
Option
Option
Option
Option

"XkbRules"
"XkbModel"
"XkbLayout"
"XkbVariant"
"XkbOptions"

"xfree86"
"pc105"
"ru"
"winkeys"
"grp:caps_toggle,grp_led:caps"

, , , . Option "XkbOptions". , ,
CapsLock ( grp:caps_toggle) CapsLock ( grp_led:caps). , , . ( ) ! option /usr/
X11R6/lib/X11/xkb/rules/xfree86.lst.

.
http://www.tsu.ru/~pascal/other/xkb.

315

udev Gentoo

1. udev? ............................................................................................................................
1.1. /dev ......................................................................................................................
1.2. namedev ..............................................................................................................................
1.3. libsysfs ................................................................................................................................
1.4. udev ....................................................................................................................................
2. udev Gentoo ...................................................................................................
2.1. ........................................................................................................
2.2. ....................................................................................................................
3. ....................................................................................................................
3.1. ..................................................
3.2. udev nvidia ......................................................................................................................
3.3. LVM2 ..............................................................................................
3.4. DevFS udev ...........................................................................
3.5. ...............................................................................................................
4. ............................................................................................

316
316
317
318
318
318
318
319
320
320
320
321
321
322
322

: http://www.gentoo.org/doc/ru/udev-guide.xml
C : 1.0

1. udev?
1.1.

/dev

Linux , , Linux
- , ( /
dev/foo), . (, ), /dev/hda1
IDE .
?
, . , , ls -l, /dev. , IDE /dev/hda. ,
.

316

udev Gentoo
USB, IEEE1394, PCI ..
? ? , ? ? , - ,
, , ?
udev. udev , :



(API)
udev : namedev, libsysfs , , udev.

1.2. namedev
Namedev udev.
, . , udev.
, namedev , LANANA.
Linux,
Linux.
namedev
. , . :
1.

2.

3.

4.

5.

, . , USB USB, SCSI


UUID. namedev
, , .
, . ,
, (,
PCI ). , namedev
, ,
.
, , , ,
, . , , .

317

udev Gentoo
, . ,
, ( ) .
(, ) :
, . ,
Linux-.

1.3. libsysfs
udev sysfs. libsysfs , sysfs.
.

1.4. udev
, , /sbin/
hotplug. Hotplug, , , /etc/hotplug.d/default,
udev. Hotplug ,
, udev, /dev (
).

2. udev Gentoo
2.1.
udev 2.6 ( vanilla-sources
gentoo-sources, 2005.0). , ,
sys-apps/baselayout. , .
1. udev
# emerge udev

udev hotplug-base, . hotplug


, , . hotplug
.
2. hotplug
# emerge hotplug

, , ,
coldplug:
3. coldplug
# emerge coldplug

318

udev Gentoo
coldplug (boot):
4. coldplug
# rc-update add coldplug boot

, :
5.
General setup --->
[*] Support for hot-pluggable devices
File systems --->
Pseudo filesystems --->
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)

, /dev file system support


(OBSOLETE) , , Automatically mount at boot :
6. devfsd
File systems --->
Pseudo Filesystems --->
[*] /dev file system support (OBSOLETE)
[ ]
Automatically mount at boot

genkernel, --udev, . ,
genkernel, .

2.2.
udev, Gentoo ,
. Gentoo udev, /dev, . Gentoo
devfsd devfs .
udev , udev ( , ,
udev ), :)
, : RC_DEVICE_TARBALL /etc/conf.d/rc no:
7. /etc/conf.d/rc
RC_DEVICE_TARBALL="no"

devfs , : gentoo=nodevfs . devfs


udev, gentoo=noudev.

319

udev Gentoo

3.
3.1.

, /dev/null , ,
, , /dev udev.
, Gentoo .
sys-apps/baselayout-1.8.12 , ,
. ,
, ,
.
, ,
udev /dev:
8. ,
#
#
#
#

mkdir test
mount --bind / test
cd test/dev
ls

/dev/null /dev/console . , . test/dev/:


9.
# mknod -m 660 console c 5 1
# mknod -m 660 null c 1 3

, test/:
10. test/
# cd ../..
# umount test
# rmdir test

3.2. udev nvidia


nVidia X udev,
:

320

udev Gentoo
nvidia /etc/modules.autoload.d/kernel-2.6
nvidia-kernel media-video/nvidia-kernel-1.0.5336-r2
baselayout sys-apps/baselayout-1.8.12
xorg-x11 , , /dev/nvidia.
/sbin/NVmakedevices.sh, .

3.3. LVM2
udev Logical Volume Manager 2 (LVM ),
, . ,
, , , /dev/dm-#, # 0, 1, ... ..
, /etc/udev/rules.d/50-udev.rules
:
11. /etc/udev/rules.d/50-udev.rules
KERNEL="dm-[0-9]*",
SYMLINK="%c"

PROGRAM="/sbin/devmap_name %M %m", NAME="%k",

, sys-fs/multipath-tools, devmap_name.
12. multipath-tools
( , multipath-tools
Portage)
# echo "=sys-fs/multipath-tools-0.4.2 ~x86" >> /etc/portage/package.keywords
# emerge multipath-tools

3.4. DevFS udev



, .
HP Smart Array 5i ( - cciss).
udev, /dev/cciss/cXdYpZ, X, Y Z - . devfs, /dev/hostX/targetY/partZ /dev/ccisss/cXdY.
, /etc/fstab .
, /dev, /dev/mouse, udev . X Device,
.
devfs udev. devfs
tty, udev vc. -

321

udev Gentoo
root /etc/securetty.
root , tty1 vc/1 /etc/securetty.

3.5.
, /etc/modules.
autoload.d/kernel-2.6,
modprobe, sys-apps/baselayout-1.8.12 .
(/dev/fb/*) 2.6.6-rc2.
, 2.6.4, /dev/pts.
13. /dev/pts
File systems --->
Pseudo filesystems --->
[*] /dev/pts file system for Unix98 PTYs

4.
udev Linux 2003 (Linux Symposium, Ottawa, Ontario
Canada - 2003) - (Greg Kroah-Hartman) IBM,
udev.
Decibel's UDEV Primer - udev Gentoo.
udev Gentoo (Daniel Drake) - , udev.

322

1. devfs? ............................................................................................................................ 323


1.1. (?) ................................................................................................. 323
1.2. ........................................................................................................................... 324
1.3. ............................................................................................................................. 324
1.4. devfs ? .................................................................................... 324
2. ............................................................................................... 325
2.1. ........................................................................................................................ 325
2.2. o devfsd ..................................................................... 326
3. .......................................................................................... 326
3.1. devfsd ........................................................................................................... 326
3.2. compatibility symlinks .......................................................................................... 326
3.3. .................................................... 327
4. , ..................................................................................... 327
4.1. / PAM ....................................................... 327
4.2. / devfsd ..................................................... 328
4.3. devfsd .................................................................. 328
: http://www.gentoo.org/doc/ru/devfs-guide.xml
C : 1.0

1. devfs?
1.1. (?)
Linux , /dev. device nodes, , . , /dev/hda IDE . , ,
, API.
, character devices ( )
block devices ( ). , -

323


/. , , , /
. .
.
, -, :
1.
# ls -l /dev/hda
brw-rw---1 root

disk

3,

0 Jul

2000 /dev/hda

, /dev/hda . ,
3, 0. major-minor. ,
. major () ,
minor () . , ?
/dev/hda4 /dev/tty5.
IDE-. major-minor 3, 4. , minor ,
major . major-minor 4, 5.
, (
).

1.2.
/dev, , , , . ,
, .
. , ,
, .
,
. , ./
MAKEDEV /dev, , ?
, ,
, , . /dev
, mount , /dev .

1.3.
, kernel hackers . http://
www.atnf.csiro.au/people/rgooch/linux/docs/devfs.html#faq-why. ,
, :

1.4. devfs ?
devfs . , device nodes ( ), ,

324


read only ( ).
, ,
...
, devfs major/minor. (
), . Linux
, ( :)
devfs , , ,
obsolete (), udev, Gentoo.
, devfs , udev FAQ udev versus devfs document.

2.
2.1.
devfs
. ,
.
, , IDE, /dev/ide/,
SCSI /dev/scsi/. SCSI IDE , .
IDE SCSI ( ), host. . bus. IDs (). ID . ID
target. SCSI LUN (Logical Unit Numbers ), (hiend tapedrives). lun, lun0/.
, , /dev/hda4, /dev/ide/host0/bus0/
target0/lun0/part4. ... , ... ... ! :)

Unix , c0b0t0
u0p2. /dev/ide/hd, /dev/scsi/hd ...

, :
2. /dev
cdroms/
ide/
netlink/
scsi/
sr/

cpu/
input/
printers/
sg/
usb/

discs/
loop/
pts/
shm/
vc/

floppy/
misc/
pty/
sound/
vcc/

325

2.2. o devfsd
,
, . , , devfsd.
, (compatibility
symlinks).
3.
$ ls -l /dev/hda4
lr-xr-xr-x
1 root

root

33 Aug 25 12:08 /dev/hda4 -> ide/host0/bus0/target0/lun0/part4

devfsd, , ..
.

3.
3.1. devfsd
/etc/devfsd.conf, , . , , :
SIGHUP devfsd , (shared
objects) REGISTER .
SIGUSR1 , REGISTER.
, kill killall:
4. SIGHUP devfsd
# kill -s SIGHUP `pidof devfsd`

# killall -s SIGHUP devfsd

3.2. compatibility symlinks

Gentoo .

/dev ( Gentoo
), /etc/devfsd.conf :

326


5. /etc/devfsd.conf
#
REGISTER
.* MKOLDCOMPAT
UNREGISTER
.* RMOLDCOMPAT

, .

3.3.

, devfs . ,
, /etc/devfsd.conf:
6. /etc/devfsd.conf, autoload functionality
LOOKUP

.*

MODLOAD

4. ,

4.1. /
PAM
/etc/devfsd.conf, PAM
(Pluggable Authentification Modules). PAM ,
, /etc/devfsd.conf.
PAM /etc/security/console.perms . : , .
. sound-group:
7. Sound group /etc/security/console.perms
<sound>=/dev/dsp* /dev/audio* /dev/midi* \
/dev/mixer* /dev/sequencer* \
/dev/sound/* /dev/snd/* /dev/beep \
/dev/admm* \
/dev/adsp* /dev/aload* /dev/amidi* /dev/dmfm* \
/dev/dmmidi* /dev/sndstat

: , , .
, - , , , .

327


8. sound group /etc/security/console.perms
<console>

0600 <sound>

0600 root.audio

1.

. console-group. PAM . ,
console-group, PAM .

2.

, . ,
, PAM
. 0600 ( /, ).

3.

, . ,
( , ) .

4.

,
. , ,
, , PAM , .

5.

( ) , , , , PAM
, .

4.2. /
devfsd
, /etc/devfsd.conf, :
9. /etc/devfsd.conf
REGISTER

^cdroms/.*

PERMISSIONS root.cdrom 0660

, /dev. , ,
.
. PAM, (
console.perms, PAM ).
.

4.3.
devfsd
Gentoo: chown chmod ,
devfsd , . - ,
/etc/devfsd.conf :

328


10. /etc/devfsd.conf
REGISTER
^pt[sy]/.*
IGNORE
CHANGE
^pt[sy]/.*
IGNORE
CREATE
^pt[sy]/.*
IGNORE
DELETE
^pt[sy]
IGNORE
REGISTER
^log
IGNORE
CHANGE
^log
IGNORE
CREATE
^log
IGNORE
DELETE
^log
IGNORE
REGISTER
.*
COPY
/lib/dev-state/$devname $devpath
CHANGE
.*
COPY
$devpath /lib/dev-state/$devname
CREATE
.*
COPY
$devpath /lib/dev-state/$devname
DELETE
.*
CFUNCTION GLOBAL unlink
/lib/dev-state/$devname
RESTORE
/lib/dev-state

, /lib/dev-state, , /dev, .
- /lib/dev-state /dev . ,
, devfs ( , ), /dev/console . , - bootscripts ( )
, :
11. /lib/dev-state /dev
mount --bind /dev /lib/dev-state
mount -t devfs none /dev
devfsd /dev

329

HOWTO fbsplash

1. ......................................................................................................................................
1.1. gensplash? ..........................................................................................................
1.2. fbsplash (framebuffer splash)? ..............................................................................
1.3. frame buffer? ....................................................................................
2. fbsplash splashutils .....................................................................................................
2.1. ........................................................................................................
2.2. ............................................................................................................
2.3. () ..............................................................................................
2.4. / ( genkernel) .......................................
2.5. splashutils ...........................................................................................................
2.6. / ( ) .............................................................
3. initramfs ............................................................................................................
3.1. initramfs? ............................................................................................................
3.2. initramfs ........................................................
3.3. initramfs ...............................................................................
3.4. gensplash ...........................................................................
3.5. bootsplash gensplash ...........................................................................
3.6. gensplash ........................................................................
4. ..................................................................................................................
4.1. .................................................................................................................
4.2. Grub ...............................................................................................
4.3. Lilo ................................................................................................
5. .................................................................................................
6. Gensplash ...........................................................................................
6.1. .......................................................................................................
6.2. 3 ..................................................................................
7. .........................................................................................................................
7.1. /usr ..........................................................................................
7.2. .....................................................................................
8. ..........................................................................................................................................
: http://ru.gentoo-wiki.com/wiki/HOWTO_fbsplash
: 1.2

330

331
331
331
331
331
332
332
332
333
333
333
334
334
334
335
335
336
336
337
337
338
338
339
339
339
340
340
340
340
341

HOWTO fbsplash

1.
gentoo- Spock gensplash (fbsplash
and splashutils) vesafb-tng. how-to, Spock's Gensplashin-5-easy-steps How-to.

1.1. gensplash?
Gensplash - Spock`, ,
"" Gentoo ( , , , . .).

1.2. fbsplash (framebuffer splash)?


Fbsplash - gensplash . fbsplash, "framebuffer splash - (silent mode), //. fbsplash
/dev/fbsplash. fbsplash, framebuffer.

1.3. frame buffer?


frame buffer , ,
. . ,
. . , /
dev , /dev/fb*.
frame buffer .
1.

, :

2.

, :

, Fbsplash frame buffer (


8/15/16/24/32 directcolor/pseudocolor ).

2. fbsplash splashutils
vesafb-tng frame buffer .
Gentoo .

331

HOWTO fbsplash
1. Emerging splashutils & themes
# emerge -va splashutils splash-themes-gentoo splash-themes-livecd

2.1.
fbsplash vesafb-tng .
2.6.10 ( ) gentoo-sources.
Spock's homepage

2.2.
vesafb-tng frame buffer (
framebuffer vesa-tng, i810fb):
2. Linux: vesafb-tng
Device Drivers ---> Graphics support--->:
<*> Support for frame buffer devices
<*>
VESA VGA graphics support
VESA driver type (vesafb-tng)
(1280x1024@60) VESA default mode

fbsplash .
3. Linux: fbsplash
Device Drivers > Graphics support > Console display driver support:
<*> Framebuffer Console support
<*> Support for the framebuffer splash

initramfs ( "
initramfs " howto),
. , (
:)
4. Linux: initrd
Device Drivers > Block devices:
<*> RAM disk support
(4096) Default RAM disk size (kbytes) (NEW)
[*]
Initial RAM disk (initrd) support

Initial RAM disk (initrd) support ( 2.6.22) General setup.

2.3. ()
# cd /usr/src/linux

332

HOWTO fbsplash
# make mrproper

.
# make menuconfig

, (:
splashutils). "make" ('make bzImage') ('make modules').
# make

2.4. / (
genkernel)
genkernel :
# genkernel --gensplash=livecd-2006.0 --gensplash-res=1280x1024 --menuconfig all

:
--gensplash=livecd-2006.0

- livecd-2006.0 ( splash-themes-livecd),

--gensplash-res=1280x1024

- 1280x1024,

--menuconfig
all

- ncurses ,

- , initrd .

2.5. splashutils
splashutils. Splashutils ( jpg, png).
# emerge splashutils

, /usr/src/linux ..

2.6. / (
)
splash screen. .
/boot .
# mount /boot

.
# make modules_install

333

HOWTO fbsplash
# make install

3. initramfs
( howto, Configuring your bootloader)
, splash screen . ( vesafb-tng), initramfs.

3.1. initramfs?
( Spock'): ["Initramfs (initial ramfs) cpio
."]
initramfs . initramfs :
1.

, ;

2.

3.

(splash_helper).

gensplash.
initramfs image:
1.

initramfs image ;

2.

initramfs image ( 'initial ram disk'


- initrd).

, .

3.2. initramfs

initramfs:
# rm /usr/src/linux/usr/initramfs_data.cpio.gz

initramfs, , userspace
helper. splash_geninitramfs ( splashutils).
'splash' bootsplash.
# splash_geninitramfs -v -g /usr/src/linux/usr/initramfs_data.cpio.gz -r 1024x768 emergence

initramfs , ( initrd):

334

HOWTO fbsplash
#
#
#
#
#

cd /usr/src/linux
touch usr/initramfs_data.cpio.gz
make bzImage
mount /boot
make install

3.3. initramfs
initramfs . ,
( 'make'
/boot 'make install'), initramfs (initrd)
. ,
( initrd ). howto
splash_geninitramfs initrd ( ,
userspace helper):
# mount /boot
# cd /etc/splash
# splash_geninitramfs -v -g /boot/fbsplash-emergence-1024x768

-r 1024x768 emergence

( ) /boot.
, Spock'," initramfs initrd ".
, genkernel , . .
genkernel initrd .
solshark [solshark_at_rambler_dot_ru]: genkernel 3.3.6 :
# genkernel --gensplash=DangerGirl initrd

genkernel .
, initrd grub.conf :
root=/dev/ram0 real_root=/dev/$ROOT
initrd (hd0,0)/boot/initrd

:
root=/dev/$ROOT
initrd (hd0,0)/boot/fbsplash-emergence-1024x768

3.4. gensplash
'emergence' /etc/splash/emergence.
( 'newtheme'), :
1. /etc/splash:
# mkdir /etc/splash/newtheme

335

HOWTO fbsplash
2. 'images' /etc/splash/newtheme:
# mkdir /etc/splash/newtheme/images

( png/jpg) .
3. . *.cfg
(/etc/splash/newtheme).
('emergence'):
# ls -l /etc/splash/emergence/
images/
1024x768.cfg
1280x1024.cfg
800x600.cfg

'jpeg=' 'silentjpeg=' ( *.cfg )


( /etc/splash/newtheme/images).
jpeg , 'pic=' 'silentpic='.
fbsplash, splashutils:
# less /usr/doc/splashutils-version/theme_format.gz

3.5. bootsplash gensplash


Spock bootsplash2fbsplash (
splashutils) , bootsplash gensplash.
'gentoo-highquality' , /etc/bootsplash ,
( ):
# bootsplash2fbsplash gentoo-highquality

gensplash- /etc/splash (/etc/splash/gentoo-highquality)


.

3.6. gensplash
( 'newtheme',
1280x1024), splash_geninitramfs.
( ):
#
#
#
#
#
#

splash_geninitramfs -v -g /usr/src/linux/usr/initramfs_data.cpio.gz -r 1280x1024 newtheme


cd /usr/src/linux
touch usr/initramfs_data.cpio.gz
make bzImage
mount /boot
make install

initrd ( ):
# mount /boot

336

HOWTO fbsplash
# splash_geninitramfs -v -g /boot/fbsplash-newtheme-1280x1024 -r 1280x1024 newtheme

splash_geninitramfs:
-v splash_geninitramfs
-g splash_geninitramfs initramfs (/usr/src/linux/usr/initramfs_data.cpio.
gz /boot/fbsplash-newtheme-1280x1024)
-r splash_geninitramfs 1280x1024
newtheme splash_geninitramfs .cfg /etc/splash/newtheme
splash_geninitramfs' :
# splash_geninitramfs --help

how-to, splashutils':
[
.cfg , .]
.

4.
4.1.
, grub(lilo):
1. frame buffer.
vesafb-tng:
video=vesafb:ywrap,mtrr,1024x768-16@85

, 1024x768, 16
85Hz. vesafb-tng,
'vga=' ( '' vesafb frame
buffer ):
# 'vga=' vesafb-tng ( , ):
vga=791
vga=0x517

2. fbsplash' :
splash=verbose,theme:emergence

fbsplash ( 'verbose' ). fbsplash "fbsplash : verbose silent.

337

HOWTO fbsplash
. silent bootsplash.
, . , .
, .
, , , .
fbsplash ( 'emergence').
fbsplash : .
3. initrd ( - initramfs),
:
initrd /boot/fbsplash-emergence-1024x768
initrd = /boot/fbsplash-emergence-1024x768

# Grub
# Lilo

? fbsplash-emergence-1024x768 (
/boot).
grub lilo. 'newtheme',
1280x1024, 32 70Hz. fbsplash 'silent' initrd
.

4.2. Grub

title Gentoo
root (hd0,0)
kernel (hd0,0)/kernel-2.6.8-gentoo-r1 root=/dev/hda3 video=vesafb:ywrap,mtrr,1280x1024-32@70 splash=sil
initrd (hd0,0)/fbsplash-newtheme-1280x1024

(hd0,0) (, /boot , '/boot' initrd)


genkernel - ( ):

kernel (hd0,0)/kernel-2.6.8-gentoo-r1 init=/linuxrc root=/dev/hda3 video=vesafb:ywrap,mtrr,1280x1024-32

4.3. Lilo
image=/boot/kernel-2.6.8-gentoo-r1
label = "Gentoo"
root = /dev/hda3
append="video=vesa:ywrap,mtrr,1280x1024-32@70 splash=silent,theme:newtheme"
read-only
initrd = /boot/fbsplash-newtheme-1280x1024

lilo lilo.conf:
# mount /boot
# lilo -v

338

HOWTO fbsplash

5.
( 'verbose'), ,
/etc/conf.d/splash splash
:
# rc-update add splash default

bootsplash, :
# rc-update del bootsplash

6. Gensplash
(Jakub) :
: Gensplash .
1.

- ( ) - -
emerge. Gentoo.

2.

- . Gentoo .

3.

1.

- . gentoo-dev-sources ( )

2.

/ - - genkerel.

3.

splashutils - package.keywords, emerge. :). .


Gentoo .

4.

splash screen ( bootpslash) - . Gentoo ().

6.1.
. :
1.

bootsplash ()

2.

bootsplash ( )

339

HOWTO fbsplash

6.2. 3
Debian Spock' forums.gentoo.org.

7.
7.1. /usr
splashutils 0.9-pre08 /usr , gensplash
" " ( ). , splashutils ,
- , .
, splash_util' fbset
/usr/bin /usr/lib. ( RAID LVM2 ), ( ) ,
splash_utils .
? ( aslocum Gentoo)
Gensplash-How-to with progressbar!!!!! :
# cp /usr/bin/fbset /sbin
# cp /usr/lib/libjpeg.so.62 /lib
# cp /usr/lib/libpng.so.3 /lib

/sbin/splash ( nano, nano -w /sbin/splash)


31 :
res=`/sbin/fbset | grep "^mode" | sed -r 's/mode "([0-9]+x[0-9]+).*/\1/'`

/sbin/ fbset. ,
.

7.2.
, , initramfs . 640x480 -
.
. ( )
vesafb vesafb-tng. Spock' : [" initramfs
, , ,
. , , . .
, .
- . , vesafb .

340

HOWTO fbsplash
. vesafb , (
) . (vesafb-tng, rivafb, radeonfb)
fbdev".]

8.
1.

Spock'

2.

Spock's Gensplash-in-5-easy-steps

Gentoo:
1.

Gensplash-How-to !!!!!

:
1.

Fbsplash (/usr/src/linux/Documentation/fb/splash.txt).

2.

( /usr/src/linux/Documentation/fb/framebuffer.txt).

3.

splashutils (/usr/share/doc/splashutils-0.9_pre07/).

341

4. WIKI


HOWTO hal .......................................................................................................
1. hal-0.5.10 ..............................................................................................................................
2. portage ...............................................................................................................
3. xorg ..................................................................................................
4. ...........................................................................................................................
5. X- ..............................................................................................................
6. ..................................................................................................................................
7. Touchpad ...............................................................................................................................
HOWTO Ivman ..................................................................................................................................
1. ......................................................................................................................................
2. ..........................................................................................................
3. ......................................................................................................................
3.1. Ivman root ..................................................................................................
3.2. Ivman ....................................................................
3.3. ......................................................................................
4. .............................................................................................................................
4.1. fstab (ivman 0.6.x ) ....................................
4.2. fstab ( ivman 0.5.x!) ..............................................
4.3. (
ivman 0.5.x!) ......................................................................................................................
4.4.
...........................................................................................................................................
5. ...................................................................................................................................
6. ..................................................................................................................
......................................................................................................
1. ..................................................................................................................
1.1. .................................................................................................................
1.2. :) ..............................................................................................................
1.3. - ...........................................................................
CD/DVD .............................................................................................................................
1. ..........................................................................................................
2. ..........................................................................................
2.1. 2.4.x ........................................................................................................
2.2. 2.6.x .......................................................................................................
3. ISO .........................................................................................................
3.1. ISO .....................................................
4. ATAPI- .............................................................................................
5. ISO ...............................................................................................................
5.1. ..................................................................................
6. ............................................................................................................
7. .........................................................................................................
8. .................................................................................................................
DVD ..................................................................................................................................
1. ...............................................................................................................................
1.1. ........................................................................................................
1.2. ...........................................................................................
2. DVD .....................................................................................

343

349
349
349
349
350
351
352
352
353
353
353
354
354
355
355
356
356
356
356
357
357
358
359
359
361
363
368
370
370
370
370
371
371
372
372
373
373
373
374
374
375
375
375
375
376

WIKI
2.1. transcode MPEG2, DVD ............................................................ 376
2.2. tcmplex ................................ 379
2.3. kino ( transcode+tcmplex) ................................................ 379
2.4. replex ( DVB (Digital
Television)) ........................................................................................................................ 380
3. (authoring) dvdauthor ............................. 380
4. DVD ......................................................................................... 381
5. ................................................................................................................................... 381
5.1. ....................................................................... 381
5.2. ................................................................................................. 381
Portage ................................................................................................................................ 383
1. Portage NFS ................................................................................................................. 383
1.1. ................................................................................................................. 383
1.2. .................................................................................................................... 383
1.3. ............................................................................................... 383
1.4. ..................................................................................................................... 384
1.5. .................................................................................................. 384
1.6. ......................................................................................................... 386
1.7. ............................................................................................................. 386
Portage ............................................................................................................................. 388
1. Portage Setup Howto ............................................................................................................. 388
1.1. .................................................................................................... 388
1.2. howto? ........................................................................................... 388
1.3. Portage (Portage profiles) ............................................................................ 388
1.4. ................................................................................................ 389
Portage Overlay .................................................................................................................................. 392
1. ............................................................................................................................... 392
2. Portage Overlay ..................................................................................................... 392
3. ebuild .................................................................................................... 392
4. digest- ......................................................................................................... 393
4.1. ebuild ............................................................................................. 394
4.2. ........................................................................................................... 394
deltup ............................................................................................... 395
1. ? ....................................................................................................................... 395
2. .......................................................................................................... 395
2.1. emerge ....................................................................................................... 396
2.2. getdelta ................................................................................................ 396
2.3. ........................................................................................................... 396
.................................... 397
....................................... 399
............................................................................................................ 401
1. .............................................................................................................................................. 401
1.1. /var/lib/portage/world .............................................................. 401
2. .............................................................................................................................................. 402
2.1. USE- ................................................................................................................ 402
3. .............................................................................................................................................. 404
3.1. . ........................................................................................ 404
4. .............................................................................................................................................. 404
4.1. . ........................................................................... 404
5. .............................................................................................................................................. 405
5.1. . .............................................................................................. 405

344

WIKI
6. .............................................................................................................................................. 405
6.1. . ....................................... 405
.......................................................................................................... 406
.............................................................................................................................................. 408
1. MS Windows - ........................................................................................... 409
1.1. .................................................................................................................... 409
1.2. .......................................................................................................................... 409
1.3. ........................................................................................................... 409
1.4. ..................................................................................................... 411
2. Udev ...................................................................................................................................... 411
2.1. ................................................................................................... 411
2.2. ................................................................................................... 411
2.3. . .............................................................................. 412
2.4. Troubleshuting ............................................................................................................ 412
3. CFLAGS ......................................... 413
3.1. ? ............................................................................................... 413
3.2. .............................................................................................................. 413
4. nano ....................................................................................................................... 416
4.1. ................................................................................................................... 417
4.2. ........................................................................................................................ 417
5. Udev .................................................................................... 417
5.1. ................................................................................................................... 417
5.2. ................................................................................................................ 417
5.3. udev ..................................................................................................... 417
5.4. .......................................................................................................... 419
5.5. ............................................................................................................... 420
6. glibc ............................................................................................................... 420
6.1. ................................................................................................................... 420
6.2. Glibc ................................................................................ 421
6.3. .............................................................................................................. 421
6.4. ............................................................................................................. 424
7. USB-flash ........................................................................................................ 424
7.1. USB-flash ...................................................................... 424
7.2. kde ............................................................................................... 426
7.3. .................................................................................. 427
8. - NTFS ntfs-3g ...................................................... 427
8.1. .................................................................................................................... 427
8.2. ................................................................................................................... 428
8.3. ............................................................................................ 428
8.4. ...................................................................................................... 429
.............................................................................................................................. 430
1. Apache2 ................................................................................................................ 432
1.1. .................................................................................................................. 432
1.2. Apache ........................................................................................................... 432
1.3. ..................................................................................................................... 432
1.4. ........................................................................................................... 433
1.5. Common Problems ..................................................................................................... 434
1.6. See Also .................................................................................................................... 436
2. iptables ..................................................................................... 436
2.1. ................................................................................................................... 436
2.2. Linux ................................................................................... 436
2.3. iptables ..................................................................................................... 437

345

WIKI
2.4. ...........................................................................................................
2.5. iptables ...........................................................................................................
2.6. /etc/init.d/iptables ...............................................................................
2.7. .......................................................................................................
2.8. ...................................................................................................
2.9. .............................................................................................
2.10. ........................................................................................................
2.11. ....................................................................................................................
3. iptables ...............................................................................................
3.1. ....................................................................................................................
3.2. ....................................................................................................
3.3. ...............................................................................................
3.4. .......................................................................................
3.5. .....................................................................................................
3.6. Scripting ......................................................................................................................
3.7. ................................................................................
3.8. Firewall ........................................................................................................
3.9. .............................................................................
3.10. iptables ACCEPTS .....................................................................................................
3.11. iptables DROP & REJECT .........................................................................................
3.12. ...........................................................................................................
3.13. ............................................................................................
3.14. .................................................................
3.15. ..............................................
3.16. ................................................................................
3.17. Ports ..........................................................................................................................
3.18. Sysctl' .....................................................................................................................
3.19. NAT ......................................................................................
3.20. The full script ............................................................................................................
4. ................................................................................................
4.1. postfix ................................................................................................
5. vsftpd ...................................................................................................................
5.1. ...................................................................................................................
5.2. VSFTPD ...................................................................................................
5.3. .......................................................................
5.4. ..........................................................................................................
5.5. ...........................................................................
5.6. ................................................................................................
5.7. ....................................................................................................................
6. Jabber Server .........................................................................................................................
6.1. ....................................................................................................................
6.2. ......................................................................................................
6.3. ............................................................................................................
6.4. ............................................................................................................
7. Counter-Strike .......................................................................................
7.1. ....................................................................
7.2. ...............................................................................................
8. Samba Win2k .....................................................................................
8.1. ...............................................................................................................
8.2. .........................................................................................................
9. Samba PDC LDAP ............................
9.1. ..........................................................................................

346

437
437
437
437
438
439
439
440
441
441
441
442
442
443
444
445
445
446
447
448
449
449
450
450
451
452
454
455
457
465
466
473
473
473
474
474
474
475
475
476
476
476
476
477
477
477
477
478
478
478
482
482

WIKI
9.2. OpenLDAP .................................................................................................................. 482
9.3. OpenLDAP ......................................................................................... 484
9.4. SAMBA ...................................................................................................................... 484
9.5. LDAP ............................................................. 492
9.6. ....................................................................................... 494
10. .............................................................................................. 498
10.1. .................................................................................................................. 498
10.2. "" ................................................................................................. 499
10.3. ....................................................................... 499
10.4. ...................................................................................................... 500
10.5. ......................................................................... 503
10.6. ...................................................................................................... 504
10.7. Linux iptables ............................................................................................................ 504
10.8. FreeBSD ipfw ............................................................................................................ 505
10.9. ...................................................................................................... 507
10.10. "" ................................................................................. 508
10.11. .................................................................... 511
10.12. rrdtool ................................................................................................ 511
10.13. Net-Telnet .......................................................................................... 512
10.14. Apache ............................................................................................... 512
10.15. .................................................................... 513
10.16. ...................................................................... 514
10.17. .................................................................................... 516
10.18. ................................................................................... 519
10.19. ......................................................................................................... 519
X ..................................................................................................................................... 521
1. X .......................................................................................... 522
1.1. ................................................................................................................... 522
1.2. ............................................................................. 522
1.3. ft ............................................................................................................................. 522
1.4. .................................................................... 523
1.5. ................................................................................. 524
1.6. Qt Gtk ................................................................................................... 525
2. X .......................................................................................... 525
2.1. ................................................................................................................... 525
2.2. .......................................................................................................... 526
2.3. ......................................................................................... 526
2.4. ............................................................................................ 526
3. Xorg X11 ...................................................................................................... 527
3.1. .................................................................................................................... 527
3.2. X.org .......................................................................................................... 528
3.3. X Composite Extension ............................................................................... 528
3.4. KDE 3.4 ........................................................................................ 528
3.5. ................................................................................................................ 530
4. Xorg. ............................................................................................. 530
5. Xgl ....................................................................................................................... 531
5.1. .................................................................................................................... 531
5.2. ................................................................................................................ 531
5.3. nvidia .......................................................................... 532
6. XGL ...................................................................................................................................... 533
6.1. ................................................................................................................... 533
6.2. ............................................................................................... 533

347

WIKI
6.3. ................................................................... 533
6.4. ........................................................................................ 534
6.5. Portage ............................................................................................ 534
6.6. : ................................................... 535
6.7. ..................................................................... 535
6.8. Xgl ............................................................................................................ 537
6.9. Xgl ........................................................................................................ 538
6.10. Xgl ............................................................................................................... 539
7. ............................................................................. 554
8. Cedega 5.1 ............................................................................................................................. 555
8.1. .................................................................................................................... 555
8.2. ................................................................................................................... 555
............................................................................................................... 557
1. .............................................................................................................................................. 557
1.1. ......................................................................................................... 557
2. .............................................................................................................................................. 559
2.1. - ................................................................................................................. 559
3. .............................................................................................................................................. 560
3.1. .............................................................................................. 560
4. .............................................................................................................................................. 560
4.1. CD ............................................................................................................... 560
5. .............................................................................................................................................. 561
5.1. ...................................................................................................... 561
6. .............................................................................................................................................. 562
6.1. ....................................................................................................... 562
7. .............................................................................................................................................. 563
7.1. ...................................................................................... 563
8. .............................................................................................................................................. 563
8.1. .................................................................................................. 563
9. .............................................................................................................................................. 564
9.1. ........................................................................................................... 564
10. ............................................................................................................................................ 565
10.1. .............................................................................................................. 565
ccache emerge ...................................................................................................... 566
Keymap ............................................................................................................................................. 567

348

HOWTO hal

1.
2.
3.
4.
5.
6.
7.

hal-0.5.10 ......................................................................................................................................
portage .......................................................................................................................
xorg ..........................................................................................................
..................................................................................................................................
X- ......................................................................................................................
..........................................................................................................................................
Touchpad .......................................................................................................................................

349
349
349
350
351
352
352

: 28.01.2008

1. hal-0.5.10
hal-0.5.10 hal xorg : ,
, , .
xorg hal xorg.conf
~x86(~amd64) . keywords
.

2. portage
# emerge --sync
(# eix-sync -v)

3. xorg
# emerge -avDNt xorg-x11

hal. . xorg-server
, .
:

349

HOWTO hal
# emerge portage-utils; qlist -I -C x11-drivers/

4.
(rules) :
/usr/share/hal/fdi/policy/20thirdparty/

/etc/hal/fdi/policy
"" hal lshal ( ) "",
:
udi = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port_logicaldev_input'
info.addons.singleton = {'hald-addon-input'} (string list)
info.capabilities = {'input', 'input.keyboard', 'input.keypad', 'input.keys', 'button'} (string list)
info.category = 'input' (string)
info.parent = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port' (string)
info.product = 'AT Translated Set 2 keyboard' (string)
info.udi = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port_logicaldev_input' (string)
input.device = '/dev/input/event2' (string)
input.originating_device = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port' (string)
input.physical_device = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port' (string)
input.product = 'AT Translated Set 2 keyboard' (string)
input.x11_driver = 'evdev' (string)
input.xkb.layout = 'us' (string)
input.xkb.model = 'evdev' (string)
input.xkb.rules = 'base' (string)
input.xkb.variant =
(string)
linux.device_file = '/dev/input/event2' (string)
linux.hotplug_type = 2 (0x2) (int)
linux.subsystem = 'input' (string)
linux.sysfs_path = '/sys/devices/platform/i8042/serio0/input/input2/event2' (string)


input.xkb.layout = 'us'
input.xkb.rules = 'base'
input.xkb.variant =



# nano /usr/share/hal/fdi/policy/20thirdparty/10russian-layout.fdi

:
1. : /usr/share/hal/fdi/policy/20thirdparty/10russian-layout.fdi
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- -*- SGML -*- -->
<match key="input.product" contains="AT Translated Set 2 keyboard">
<merge key="input.xkb.layout" type="string">us,ru</merge>
<merge key="input.xkb.variant" type="string">,winkeys</merge>
<merge key="input.xkb.options" type="string">grp:alt_shift_toggle,grp_led:scroll</merge>
</match>

"",

350

HOWTO hal
<match key="input.product" contains="AT Translated Set 2 keyboard">


<match key="info.capabilities" contains="input.keyboard">

.
xorg.conf. , xorg.conf XML.

, ?

:
Option "XkbRules" "xorg"


<merge key="input.xkb.rules" type="string">xorg</merge>

- evdev( ) ,
:
Driver "kbd"

=
<merge key="input.x11_driver" type="string">kbd</merge>

.
# /etc/init.d/hald restart

, .
# lshal

:
...
input.x11_driver = 'evdev' (string)
input.xkb.layout = 'us,ru' (string)
input.xkb.model = 'evdev' (string)
input.xkb.options = 'grp:alt_shift_toggle,grp_led:scroll'
input.xkb.rules = 'base' (string)
input.xkb.variant = ',winkeys' (string)
...

(string)

, . -- .

5. X-
X- ( , xdm). . . , Xorg, .

351

HOWTO hal

6.
. Hal evdev,
()
# echo "SDL_VIDEO_X11_DGAMOUSE=0" >>/etc/env.d/02locale
# env-update
# source /etc/profile

7. Touchpad
.

352

HOWTO Ivman

1. ..............................................................................................................................................
2. ..................................................................................................................
3. ..............................................................................................................................
3.1. Ivman root ..........................................................................................................
3.2. Ivman ............................................................................
3.3. ..............................................................................................
4. .....................................................................................................................................
4.1. fstab (ivman 0.6.x ) ...........................................
4.2. fstab ( ivman 0.5.x!) ......................................................
4.3. ( ivman
0.5.x!) ........................................................................................................................................
4.4. .............
5. ...........................................................................................................................................
6. ..........................................................................................................................

353
353
354
354
355
355
356
356
356
356
357
357
358

1.
ivman .

: Ivman, Ivman
0.5.x. , Ivman.

2.
1.

UDEV

2.

HAL

353

HOWTO Ivman

3.

D-BUS

4.

pmount

5.

ivman

, :
# emerge -av ivman

, .
HAL , "u64" "BLKGETSIZE64" 2.6, linux-headers:
# emerge --oneshot linux-headers

linux-headers , glibc:
# emerge --oneshot glibc

3.
Ivman: root, .
, .

3.1. Ivman root


1.

Ivman : /etc/init.d/ivman start

2.

Ivman : rc-update add ivman default

3.

Ivman ivman
plugdev.

4.

, / plugdev ( , pmount).
, Ivman .

5.

.
sudo pumount sudo umount. 'media:/' ioslave KDE
.

6.

/usr/
share/hal/fdi/policy/10osvendor/10-storage-policy.fdi, user users <merge
key="storage.policy.default.mount_option.user" type="bool">true</merge>. , /usr/share/hal. (: ivman 0.5.x,
ivman.)

354

HOWTO Ivman

3.2. Ivman
1.

, HAL. root: /etc/init.d/hald start

2.

HAL : rc-update add hald default

3.

Ivman ivman .
Ivman , , :

4.

Ivman .

plugdev, ,
.

5.

/
.

6.

. pumount.
'media:/' ioslave KDE .

7.

(, , ), Ivman root . Ivman, Ivman , Ivman root. Ivman, .

Ivman . fstab ,
/ /media. , Ivman
. - :-)

3.3.
1. Code: ,
<ivm:Match name="ivm.mountable" value="true">
<ivm:Option name="mount" value="true" />
</ivm:Match>

2. Code: MP3- mc,


<ivm:Match name="hal.info.product" value="IAUDIO">
<ivm:Option name="exec" value="xterm -e mc /home/share/music /media/IAUDIO" />
</ivm:Match>

3. Code: mc,
<ivm:Match name="hal.info.vendor" value="FUJIFILM">
<ivm:Option name="exec" value="xterm -e mc /home/share/pics /media/usbdisk/DCIM/100_FUJI" />
<ivm:Option name="exec" value="xterm -e mc /home/share/pics /media/usbdisk/DCIM/100_FUJI" />

355

HOWTO Ivman
KDE
4. Code: , -

<ivm:Match name="hal.info.category" value="storage">


<ivm:Match name="hal.storage.bus" value="usb">
<ivm:Option name="exec"
value="kdialog --passivepopup 'USB storage device detected: $hal.info.vendor$ $hal.info.produc
/>
</ivm:Match>
</ivm:Match>

4.
4.1. fstab (ivman 0.6.x
)
Ivman 0.6.x pmount ,
fstab. , .
pmount ( Ivman, ) fstab. 0.6.0,
, IvmConfigMappings.xml. ,
fstab, /media.

4.2. fstab (
ivman 0.5.x!)
Ivman 0.5.x /etc/fstab. supermount, ivman. :
/dev/cdroms/cdrom0

/mnt/cdrom

iso9660

noauto,ro

0 0

devfs.

4.3.
( ivman 0.5.x!)
USB-, ivman, root ,
, root. , HAL
"users", .
whatever.fdi /usr/share/hal/fdi/95userpolicy/ :

356

HOWTO Ivman
5. : whatever.fdi
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<!-- Append users to default mount options -->
<device>
<merge key="storage.policy.default.mount_option.users" type="bool">true</merge>
</device>
</deviceinfo>

HAL Specifications.

4.4.

mount ,
6. Code:

# mount
/dev/sdb1 on /media/sdb1 type vfat (rw,noexec,nosuid,nodev,quiet,shortname=mixed,uid=104,gid=412,umask=
/dev/sdc1 on /media/sdc1 type vfat (rw,noexec,nosuid,nodev,quiet,shortname=mixed,uid=104,gid=412,umask=

ivman pumount /
dev/sdb1, /dev/sdb1 (udev )
/etc/ivman/IvmConfigBase.xml
7. : /etc/ivman/IvmConfigBase.xml
<!-- mount command. default is autodetected. Must be specified with umountcommand. -->
<ivm:Option name="mountcommand" value="/usr/bin/pmount -u 007 '$hal.block.device$'" />
<!-- umount command. default is autodetected. Must be specified with mountcommand. -->
<ivm:Option name="umountcommand" value="/usr/bin/sudo /bin/umount -l '$hal.block.device$'" />

/etc/sudoers
8. : /etc/sudoers
ivman

ALL = NOPASSWD: /bin/umount

sudo .

5.
HAL coldplug boot USB.
ivman USB flash, utf-8 .
.

357

HOWTO Ivman

6.
ivman , :
# /etc/init.d/ivman stop

:
# nano -w /etc/ivman/IvmConfigBase.xml

fork, . ivman . .
http://ru.gentoo-wiki.com/HOWTO_Ivman

358

1. ..........................................................................................................................
1.1. .........................................................................................................................
1.2. :) ......................................................................................................................
1.3. - ...................................................................................

359
361
363
368

1.
IDE , IDE-. CD-ROM. , :
1.

IDE

2.

ATA

3.

ATAPI

4.

Enhanced IDE (EIDE)

5.

Fast ATA Fast ATA-2

IDE PIO DMA. ,


, ,
.
PIO /, ,
( ,
, ,
, ).
PIO Mode 0 1 2 3 4. , . IDE ZIP100 Iomega
PIO mode 0. CD-ROM PIO mode 4, DMA.
1.

PIO Mode 0 = 3.3 Mb/s

2.

PIO Mode 1 = 5.2 Mb/s

359

3.

PIO Mode 2 = 8.3 Mb/s

4.

PIO Mode 4 = 11.1 Mb/s

5.

PIO Mode 5 = 16.7 Mb/s

DMA Direct Memory Access ,


, (bus
mastering), .
DMA : UDMA MDMA.
UDMA ultra DMA , . UDMA 0 1 2 3 4
5 6. :
1.

UDMA 2 = 33 mb/s

2.

UDMA 4 = 66 mb/s

3.

UDMA 5 = 100 mb/s

4.

UDMA 6 = 133 mb/s

Intel . SATA UDMA = 150 Mb/s.


UDMA 66 100 133 80- ,
, . 40-
.
MDMA multiword dma, , CD-ROM.
1.

MDMA0 = 4.2 mb/s

2.

MDMA1 = 13.3 mb/s

3.

MDMA2 = 16.7 mb/s

IDE
, . -
.


, , ,
.. :)
, 2.6.9-gentoo-r4
hdparm-5.7-r1, ACCEPT_KEYWORDS="~x86".

- , .

360

SATA libata (
sdX hdX). sata scsi pata, scsi sata. sata
hdparm , libata
.

, ,
100% . , , .

1.1.
, IDE DMA , .
:
# dmesg | less

.
ide . kern.log
( ):

Nov 14 17:45:54 tsoptimus kernel: ide: Assuming 33MHz system bus speed for PIO modes; override with ide
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
idebus=66,
DMA .
/usr/src/linux/Documentation/ide.txt
Nov 14 17:45:54 tsoptimus kernel: ICH2: IDE controller at PCI slot 0000:00:1f.1
Nov 14 17:45:54 tsoptimus kernel: ICH2: chipset revision 2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
Nov 14 17:45:54 tsoptimus kernel: ICH2: not 100%% native mode: will probe irqs later
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
. .
Nov 14 17:45:54 tsoptimus kernel:
ide0: BM-DMA at 0xf000-0xf007, BIOS settings: hda:DMA, hdb:pio
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
busmaster , dma
BIOS.
Nov 14 17:45:54 tsoptimus kernel:
ide1: BM-DMA at 0xf008-0xf00f, BIOS settings: hdc:pio, hdd:DMA
Nov 14 17:45:54 tsoptimus kernel: Probing IDE interface ide0...
Nov 14 17:45:54 tsoptimus kernel: hda: ST340016A, ATA DISK drive
Nov 14 17:45:54 tsoptimus kernel: ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Nov 14 17:45:54 tsoptimus kernel: Probing IDE interface ide1...
Nov 14 17:45:54 tsoptimus kernel: hdd: DV-516E, ATAPI CD/DVD-ROM drive
Nov 14 17:45:54 tsoptimus kernel: ide1 at 0x170-0x177,0x376 on irq 15
Nov 14 17:45:54 tsoptimus kernel: PDC20265: IDE controller at PCI slot 0000:02:0a.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
promise
Nov 14 17:45:54 tsoptimus kernel: ACPI: PCI interrupt 0000:02:0a.0[A] -> GSI 17 (level, low) -> IRQ 17
Nov 14 17:45:54 tsoptimus kernel: PDC20265: chipset revision 2
Nov 14 17:45:54 tsoptimus kernel: PDC20265: 100%% native mode on irq 17
Nov 14 17:45:54 tsoptimus kernel: PDC20265: (U)DMA Burst Bit ENABLED Primary MASTER Mode Secondary MAST
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BIOS DMA, :)
Nov 14 17:45:54 tsoptimus kernel:
ide2: BM-DMA at 0xac00-0xac07, BIOS settings: hde:pio, hdf:pio
^^^^^^^

361

Nov
Nov
Nov
Nov
Nov
Nov
Nov

14
14
14
14
14
14
14

17:45:54
17:45:54
17:45:54
17:45:54
17:45:54
17:45:54
17:45:54

tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus

kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:

Nov 14 17:45:54 tsoptimus kernel:

Nov
Nov
Nov
Nov
Nov
Nov
Nov

14
14
14
14
14
14
14

17:45:54
17:45:54
17:45:54
17:45:54
17:45:54
17:45:54
17:45:54

tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus
tsoptimus

kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:


ide3: BM-DMA at 0xac08-0xac0f, BIOS settings: hdg:pio, hdh:pio
Probing IDE interface ide2...
hde: FUJITSU MPG3204AT E, ATA DISK drive
ide2 at 0x9c00-0x9c07,0xa002 on irq 17
Probing IDE interface ide3...
hda: max request size: 128KiB
hda: 78165360 sectors (40020 MB) w/2048KiB Cache, CHS=65535/16/63, UD
^^

hda: cache flushes not supported
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:(
, panic oops .
supported, ...
/dev/ide/host0/bus0/target0/lun0: p1 p2 p3 p4
hde: max request size: 128KiB
hde: 40031712 sectors (20496 MB) w/512KiB Cache, CHS=39714/16/63, UDM
hde: cache flushes not supported
/dev/ide/host2/bus0/target0/lun0: p1 p2
hdd: ATAPI 48X DVD-ROM drive, 256kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.20

. IDE ( )
# ATA/ATAPI/MFM/RLL support
#
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y
#
# Please see Documentation/ide.txt for help/info on IDE drives
#
# CONFIG_BLK_DEV_IDE_SATA is not set
# CONFIG_BLK_DEV_HD_IDE is not set
CONFIG_BLK_DEV_IDEDISK=y
#CONFIG_IDEDISK_MULTI_MODE is not set
CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cdrom, ( )
CONFIG_IDE_TASK_IOCTL=y
CONFIG_IDE_TASKFILE_IO=y
^^^^^^^^^^^^^^^^^^^^^^^^
:)
#
# IDE chipset support/bugfixes
#
# CONFIG_IDE_GENERIC is not set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IDE . 99% . .
# CONFIG_BLK_DEV_CMD640 is not set
CONFIG_BLK_DEV_IDEPCI=y
CONFIG_IDEPCI_SHARE_IRQ=y
^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_BLK_DEV_GENERIC is not set

362


# CONFIG_BLK_DEV_OPTI621 is not set
# CONFIG_BLK_DEV_RZ1000 is not set
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!!!! DMA
blacklisted, .
CONFIG_IDEDMA_PCI_AUTO=y
^^^^^^^^^^^^^^^^^^^^^^^^^
:) , DMA.

# CONFIG_IDEDMA_ONLYDISK is not set


CDROM DMA PIO , DMA
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_BLK_DEV_ALI15X3 is not set
# CONFIG_BLK_DEV_AMD74XX is not set
# CONFIG_BLK_DEV_ATIIXP is not set
# CONFIG_BLK_DEV_CMD64X is not set
# CONFIG_BLK_DEV_TRIFLEX is not set
# CONFIG_BLK_DEV_CY82C693 is not set
# CONFIG_BLK_DEV_CS5520 is not set
# CONFIG_BLK_DEV_CS5530 is not set
# CONFIG_BLK_DEV_HPT34X is not set
# CONFIG_BLK_DEV_HPT366 is not set
# CONFIG_BLK_DEV_SC1200 is not set
CONFIG_BLK_DEV_PIIX=y
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# CONFIG_BLK_DEV_NS87415 is not set
CONFIG_BLK_DEV_PDC202XX_OLD=y
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

CONFIG_PDC202XX_BURST=y
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DMA promise, DMA . .
# CONFIG_BLK_DEV_PDC202XX_NEW is not set
# CONFIG_BLK_DEV_SVWKS is not set
# CONFIG_BLK_DEV_SIIMAGE is not set
# CONFIG_BLK_DEV_SIS5513 is not set
# CONFIG_BLK_DEV_SLC90E66 is not set
# CONFIG_BLK_DEV_TRM290 is not set
# CONFIG_BLK_DEV_VIA82CXXX is not set
# CONFIG_IDE_ARM is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_IVB is not set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UDMA4 5 6 .
40- , .
CONFIG_IDEDMA_AUTO=y
# CONFIG_BLK_DEV_HD is not set

1.2. :)
, ,
# emerge hdparm

363


:
# man hdparm

:)
:
# hdparm -tT /dev/hdX

X
.
.
:
/dev/hda:
Timing cached reads:
616 MB in 2.00 seconds = 307.74 MB/sec
Timing buffered disk reads:
74 MB in 3.04 seconds = 42.33 MB/sec

, :)
.
:) 35-55 mb/s ,
50 raid (... ...).

1.2.1.
BIOS .

!!! , , , !

, , .
IDE/A master slave. . cable select. cable select Y- , . , , master, slave.
, 80-, 40- :).
. , , . . (, ), .

364

IDE- ( SATA).
, .
- . , , - .
ATAPI- (, CDROM). , ATAPI , , ,
ATAPI- , .
.
CD-ROM .
.
, master CD-ROM slave
.
, CD-ROM .
!!!
:)
BIOS. UDMA , Bus master IDE, IDE Block mode.

1.2.2.
? ?
:
# hdparm -iIv /dev/hdX | less

. .
, .
/dev/hda:
multcount
IO_support
unmaskirq
using_dma
keepsettings
readonly
readahead
geometry

= 16 (on)
= 1 (32-bit)
= 1 (on)
= 1 (on)
= 0 (off)
= 0 (off)
= 256 (on)
= 65535/16/63, sectors = 40020664320, start = 0

365


, .
Model=ST340016A, FwRev=3.19, SerialNo=3HS9R2GG
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=16
CurCHS=4047/16/255, CurSects=16511760, LBA=yes, LBAsects=78165360
IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=enabled
Drive conforms to: device does not report version:
* signifies the current active mode

. .
ATA device, with non-removable media
Model Number:
ST340016A
Serial Number:
3HS9R2GG
Firmware Revision: 3.19
Standards:
Supported: 5 4 3 2
Likely used: 6
Configuration:
Logical
max
current
cylinders
16383
4047
heads
16
16
sectors/track
63
255
-CHS current addressable sectors:
16511760
LBA
user addressable sectors:
78165360
device size with M = 1024*1024:
38166 MBytes
device size with M = 1000*1000:
40020 MBytes (40 GB)
Capabilities:
LBA, IORDY(can be disabled)
bytes avail on r/w long: 4
Queue depth: 1
Standby timer values: spec'd by Standard
R/W multiple sector transfer: Max = 16 Current = 16
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
. 16 . .
Recommended acoustic management value: 128, current value: 254
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
. , .
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
. .
Cycle time: no flow control=240ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
*
READ BUFFER cmd
*
WRITE BUFFER cmd
*
Host Protected Area feature set
*
Look-ahead
*
Write cache
*
Power Management feature set
Security Mode feature set
*
SMART feature set

366

Device Configuration Overlay feature set


Automatic Acoustic Management feature set
SET MAX security extension
DOWNLOAD MICROCODE cmd

*
Security:
Master password revision code = 65534
supported
not
enabled
not
locked
not
frozen
not
expired: security count
not
supported: enhanced erase
HW reset results:
CBLID- above Vih
Device num = 1
Checksum: correct

, . ,
, :). man hdparm, . \

1.2.3.
, :
# hdparm - //

hdparm , , .
, dmesg .
1.2.3.1.
-a ,

. , . ,
. , mp3.
. .
, Look-ahead
Enabled Supported. 1 , 0 .
-A

-B , . ,

:), . 255
, .
. AdvancedPM= .

1 32 , 16 .
3 - . , 1.
, . 1 3 ,
.
-c

-d 1 , 0 . DMA.

dma , . ,
. !!! , !!!
, - !!!

367


-E

cdrom. ... . :)

-K .
. , , reset ,
, (aka suspend to disk). 1 . 0 .
-k

-m . .

, MaxMultSect=. .

. 254 . 0 .
128 254. :)
-M

. . ?
-P

. 1, -. .
. . .
-u

1 . . .
-W

-X . DMA.

hdparm , -X udma5. !!! , , (40-) !!!


DMA, ,
, !!! ?.
, hdparm -tT, dmesg.
. :)
, .

1.2.4.
/etc/conf.d/hdparm . :
hda_args="-u1c3M254Kk"
hde_args="-u1c3M254Kk"
#hdd cdrom
hdd_args="-u1c3Kk"

: rc-update add hdparm default


: /etc/init.d/hdparm start

1.3. -
2.6 -. . ,
anticipatory io cheduler. .

368


no-op . . .
.
anticipatory . - . ,
.
deadline anticipatory, "" .
.
CFQ - . - ,
. .

1.3.1. ?
GRUB elevator=[cfq|as|deadline|
noop], , . /
. " Linux".
general setup ->
Configure standart kernel features...

vm ...

369

CD/DVD

1. ..................................................................................................................
2. ..................................................................................................
2.1. 2.4.x ................................................................................................................
2.2. 2.6.x ...............................................................................................................
3. ISO .................................................................................................................
3.1. ISO .............................................................
4. ATAPI- .....................................................................................................
5. ISO .......................................................................................................................
5.1. ..........................................................................................
6. ....................................................................................................................
7. .................................................................................................................
8. .........................................................................................................................

370
370
370
371
371
372
372
373
373
373
374
374

1.
, cdrecord mkisofs,
cdrtools. :
# emerge cdrtools

2.
, .

2.1. 2.4.x
2.4.x SCSI :

370

CD/DVD
1. Linux: 2.4.x
ATA/IDE/MFM/RLL Support -->
IDE, ATA, and ATAPI Block Devices -->
<M> SCSI Emulation Support
SCSI Support -->
<M> SCSI Support
<M> SCSI CDROM Support
<M> SCSI Generic Support

, hdc=ide-scsi ( , CD hdc).
.. grub, :
2. : /boot/grub/grub.conf
title Gentoo Linux
root (hd#,#)
kernel (hd#,#)/YOUR_KERNEL_NAME_HERE root=/dev/hdx# hdc=ide-scsi ANY_OTHER_KERNEL_OPTIONS_NEEDED

.. grub, :
3. : /boot/grub/grub.conf
# Linux bootable partition config
image = /boot/YOUR_KERNEL_NAME_HERE
append = "hdc=ide-scsi"
root
= /dev/hdx#
label = Gentoo
read-only

2.2. 2.6.x
2.6.x SCSI (, , ). , ATAPI CDROM:
4. Linux: 2.6.x
Device Drivers -->
ATA/ATAPI/MFM/RLL support -->
<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
<*> Include IDE/ATAPI CDROM support

3. ISO
, :
# mkdir /tmp/iso

, , :
# cp *.doc /tmp/iso

371

CD/DVD
image.iso
# mkisofs -o /tmp/image.iso /tmp/iso

3.1. ISO

-r: () Rock Ridge, .. unix . , ( 255 , MS Windows), . -R, Rock Ridge, ,


.
-jcharset=koi8-r: 2 : 1) -J Joliet, MS Windows; 2) -input-charset: . ("koi8-r"
, )
-joliet-long: , Joliet 103 Unicode .
Joliet . .
-f: . /tmp/iso, , .
-C: , (. )

4. ATAPI-

# cdrecord --dev=ATAPI --scanbus

:
Cdrecord-Clone 2.01a25 (i686-pc-linux-gnu) Copyright (C) 1995-2004 J?rg Schilling
scsidev: 'ATAPI'
devname: 'ATAPI'
scsibus: -2 target: -2 lun: -2
Warning: Using ATA Packet interface.
Warning: The related libscg interface code is in pre alpha.
Warning: There may be fatal problems.
Using libscg version 'schily-0.8'.
scsibus0:
0,0,0
0) 'SONY
' 'CD-RW CRX175A1 ' '5YS2' Removable CD-ROM
0,1,0
1) *
0,2,0
2) *
0,3,0
3) *
0,4,0
4) *
0,5,0
5) *
0,6,0
6) *
0,7,0
7) *

372

CD/DVD
, 0,0,0 CD-RW .

cdrtools (2.01.01) 2.6.x


# cdrecord --dev=ATA --scanbus

5. ISO
# cdrecord --dev=ATA:0,0,0 /tmp/image.iso

( 0,0,0 )

dev=ATA:0,0,0 , , dev=/dev/cdrw

5.1.
--speed=#
# cdrecord --dev=ATAPI:0,0,0 --speed=4 /tmp/image.iso

--blank=fast CD-RW .
# cdrecord --dev=ATAPI:0,0,0 --blank=fast

BURN-free. cdrecord. , -driveropts=burnfree. , CD-ROM


# cdrecord dev=/dev/cdrw driveropts=help -checkdrive

/etc/default/cdrecord CDR_DEVICE=ATAPI:0,0,0 (
CDR_DEVICE=/dev/hdc), ( --dev=ATAPI:0,0,0) CD-RW :
# cdrecord --blank=fast

CD, cdrom.

6.
CD-ROM, - .
( dd, cat, cdrdao, readcd ..). readcd, ..
cdrtools, ( man readcd):

373

CD/DVD
# readcd dev=/dev/cdrw -clone f=/tmp/image.iso

cdrecord:
# cdrecord -v -eject dev=/dev/cdrw -raw96r -clone /tmp/image.iso

-raw96r -clone -
readcd -clone.

7.
, - , cdrecord -multi, mkisofs -r -R (.. Rock Ridge). :
# mkisofs -r -f -jcharset=koi8-r -o /tmp/image.iso /tmp/iso/
# cdrecord -v -multi driveropts=burnfree -eject dev=/dev/cdrw /tmp/image.iso

, .
# cdrecord -msinfo dev=/dev/cdrw

mkisofs -C. ,
, -M, -
CD-ROM (.. /dev/cdrw). cdrecord
. :

# mkisofs -r -f -jcharset=koi8-r -C $(cdrecord dev=/dev/cdrw -msinfo) -M /dev/cdrw -o /tmp/image.iso /t


# cdrecord -v -multi driveropts=burnfree -eject dev=/dev/cdrw /tmp/image.iso

8.
how-to : http://www.tldp.org/HOWTO/CD-WritingHOWTO.html
: http://www.opennet.ru/docs/HOWTO-RU/CD-Writing-HOWTO.html
( ): HOWTO Create an Audio CD

374

DVD

1. .......................................................................................................................................
1.1. ................................................................................................................
1.2. ...................................................................................................
2. DVD .............................................................................................
2.1. transcode
MPEG2, DVD ..............................................................................
2.2. tcmplex ........................................
2.3. kino ( transcode+tcmplex) .......................................................
2.4. replex ( DVB (Digital
Television)) ................................................................................................................................
3. (authoring) dvdauthor .....................................
4. DVD .................................................................................................
5. ...........................................................................................................................................
5.1. ...............................................................................
5.2. .........................................................................................................

375
375
375
376
376
379
379
380
380
381
381
381
381

1.
1.1.
DVD
Gentoo Linux.

1.2.
, :
transcode

375

DVD
emerge -n transcode
cdrecord mkisofs
emerge -n cdrtools
growisofs
emerge -n dvd+rw-tools
dvdauthor
emerge -n dvdauthor
: kino
emerge -n kino
cinelerra
emerge -n cinelerra-cvs
dvdrip
USE='cdr mplayer ogg subtitles xvid rar' emerge -n dvdrip
replex
emerge -n replex
cdrecord-prodvd
emerge -n cdrecord-prodvd

2. DVD
2.1. transcode

MPEG2, DVD
, ,
dvdrip, transcode .
Transcode, , . , , man
transcode, , . ,
man . ,
divx ( ).

376

DVD
letterbox 1.5:1. , . , 1.73 (16:9) 720x416. DVD
720x480, 704x480, 352x480 352x240 ( ). 720x480 ( 1.5), 32
.
transcode -i test-divx.avi -V -y mpeg -F d -Y -32,0,-32,0 -E 44100 -b 128 -o showgirls-dvd
-Y transcode , . , . 720x480
- "" , ,
-Y.
Here's what some of those command line arguments mean: , :
-V

YV12/I420 [ ]
, , RGB ,
.
, .

-y vmod[,amod]
[,] [ ].
, transcode .
transcode :
<>
mpeg () MPEG 1/2 | () MPEG 1 Layer II
nasm .
. .
bbmpeg ( transcode).
mpeg1, VCD, SVCD, MPEG2 DVD .
,
.
-F codec_string
[ ].
-F .
<>

377

DVD
-y mpeg:
: -F "<base-profile>[,<resizer-mode>[,user-profile]]"
<base-profile> :
'1' = MPEG 1 ( )
'b' = big MPEG 1 ()
'v' = VCD
's' = SVCD
'2' = MPEG2
'd' = DVD
<resizer-mode> :
0 = resizer ( )
1 = 352x288
2 = 480x480
3 = 480x576
4 = 352x240
<user-profile> .

( transcode).
-Y top[,left[,bottom[,right]]]
( ) .
[ ].
-E r[,b[,c]]
[],
[ ]. "-J resample"
.
-B n[,m[,M]]
-n*M
[,-m*M] [ ,32].

378

DVD
M 8, 16 32. M
. fast -Z
n m .
-b b[,v,[q,[m]]]
/ [,vbr[,quality[,mode]]] [128,0,5,0]
mode lame
. mode:
0

Joint Stereo ( )

Full stereo

Mono

-o file
, [/dev/null].
, , 728x424,
:
transcode -i showgirls-divx.avi -V -y mpeg -F d -B 1,1,8 -E 44100 -b 128 -o showgirls-dvd
-X , .

2.2. tcmplex

Transcode *.m2v (mpeg-2 ) *.mpa () .
:
tcmplex -o showgirls-dvd.vob -i showgirls-dvd.m2v -p showgirls-dvd.mpa -m d

2.3. kino ( transcode


+tcmplex)
Kino dv . ( , , ).
( dvgrab ). qt4linux mov .
cinelerra, , Linux. , ( ) . .mov kino (dvgrab)

379

DVD
cinelerra ( , ). cinelerra, mov.
.mov , , kino
export. video vcd, svcd dvd. DVD
( ).

2.4. replex ( DVB


(Digital
Television))
" DVB-C, "
: , , ,
. , ;)
Digital television streams are transmitted as MPEG2-TS in which the TS stands for Transport Stream. This means
that extra information, such as multiple audio streams, could be transferred along with the actual video. Quite
fortunately, the video stream is already suitable for DVD without re-encoding which is both time consuming
and stupid as it lowers the quality. Enter replex. First use czap for tuning into some channel:
czap -r -n 3
This tunes the DVB card to channel number 3. Now, record some data by typing:
cat /dev/dvb/adapter0/dvr0 > stream.ts
This simply writes raw data from the first tuner card into a file. After awhile press CTRL-C to stop recording.
Now, you should have a blob of data which could be played with e.g. mplayer. Next, you should use replex to
transform TS format suitable for DVD. Enter following command:
replex -k -i TS -t DVD -o stream.dvd stream.ts
This command ignores possible errors in original stream (-k), assumes that input file is in TS format (-i TS),
outputs format suitable for DVD (-t DVD), writes to a file called stream.dvd (-o stream.dvd) and reads its input
from the file entered as a last parameter (stream.ts).
After a moment a file called stream.dvd should appear in the same directory where above command was entered.
Now just follow the instructions from the next chapter onwards to burn this baby on a DVD.

3.
(authoring) dvdauthor
! MPEG2 , dvdauthor ( (, dvdstyler)), DVD (VIDEO_TS AUDIO_TS).

380

DVD
dvdauthor -o . showgirls-dvd.vob && dvdauthor -o . -T

4. DVD
AUDIO_TS VIDEO_TS bar, , :
mkisofs -dvd-video -o ./bar.img ./bar/
bar.img ,
.
AUDIO_TS VIDEO_TS bar/ :
growisofs -Z /dev/dvd -dvd-video -V _ .
/dev/dvd DVD-writer.

5.
Linux DVD. cdrecord
growisofs.

5.1.
ISO X-CDroast ( cdrecord-ProDVD, , ).
k3b, growisofs. , , .

5.2.
:
cdrecord-ProDVD -dao -speed=4 -dev=/dev/dvd ./bar.img
cdrecord -scanbus , . ATAPI -dev=/dev/dvd -dev=/dev/hdd (
), SCSI -dev=0,0,0 -dev=0,0,1 ( ).
cdrecord-ProDVD growisofs.
growisofs -dvd-compat -Z /dev/dvd=./bar.img

381

DVD
: growisofs (
.iso):
growisofs -dvd-compat -Z /dev/dvd -dvd-video ./bar
, http://james.nontrivial.org/
projdvd.htm

382

Portage

1. Portage NFS .........................................................................................................................


1.1. .........................................................................................................................
1.2. ............................................................................................................................
1.3. .......................................................................................................
1.4. .............................................................................................................................
1.5. ..........................................................................................................
1.6. .................................................................................................................
1.7. .....................................................................................................................

383
383
383
383
384
384
386
386

1. Portage NFS
1.1.
'emerge --sync' LAN.
gentoo, .

1.2.
NFS portage. cron, /usr/portage NFS.

1.3.
1.

nfs . ,
modules.autoload

2.

, nfs

3.

emerge nfs-utils

4.

NFS/fstab portage.

383

Portage
5.

PORTAGE_TMPDIR .

1.4.
portage ( cron').
rsync .
/usr/portage/distfiles ,
, portage .
, NFS ;)

NFS . ,
, . !

1.5.
1.5.1.
NFS , (
):
1. Linux:
File systems --->
Network File Systems --->
<*> NFS file system support
[*]
Provide NFSv3 client support
[ ]
Provide NFSv4 client support (EXPERIMENTAL)
[ ]
Allow direct I/O on NFS files (EXPERIMENTAL)
<*> NFS server support
[*]
Provide NFSv3 server support
[ ]
Provide NFSv4 server support (EXPERIMENTAL)
[ ]
Provide NFS server over TCP support (EXPERIMENTAL)

:
2. Linux:
File systems --->
Network File Systems --->
<M> NFS file system support
[*]
Provide NFSv3 client support
[ ]
Provide NFSv4 client support (EXPERIMENTAL)
[ ]
Allow direct I/O on NFS files (EXPERIMENTAL)
<M> NFS server support
[*]
Provide NFSv3 server support
[ ]
Provide NFSv4 server support (EXPERIMENTAL)
[ ]
Provide NFS server over TCP support (EXPERIMENTAL)

384

Portage
NFS server support, portage. NFS .
.
3.
gentoo #
gentoo #

gentoo #

gentoo #

mount /boot //
cd /usr/src/linux
2.4:
make dep && make bzImage modules modules_install install
2.6:
make && make modules_install

1.5.2.
, NFS , , ,
: modprobe nfs

1.5.3.
nfs-utils:
# emerge nfs-utils

portage
# rc-update add portmap default
# rc-update add nfs default

crontab ( , cron ). vixie-cron


dcron : crontab -e
:
0 0 * * * emerge --sync > /dev/null 2>&1 || true --nospinner && emerge world -vup

/etc/exports , :
/usr/portage

ip_range/subnet(sync,no_root_squash,rw)

/etc/fstab , :
SERVER_IP:/usr/portage

/usr/portage

nfs

bg,hard 0 0

/etc/modules.autoload.d/kernel-version, :
nfs

nfs.
emerge , crontab .
10 . .
10 0 * * * emerge --metadata

385

Portage

1.5.4. PORTAGE_TMPDIR
PORTAGE_TMPDIR

( ).

PORTAGE_TMPDIR /etc/make.conf /
var/tmp, , , , ,
, : emerge info ( ),
/usr/portage (,
)

1.6.
crontab'
0 0 * * * emerge --sync > /dev/null 2>&1 || true --nospinner && emerge world -vup

, ,
emerge world -vup root' ,
).
/etc/exports:

"/usr/portage"
"ip_range/subnet"
"(sync,no_root_squash,rw)" ,
/etc/fstab:

"SERVER_IP:/usr/portage"
"/usr/portage"
"nfs"
"bg,hard 0 0" ,
/etc/modules.autoload.d/kernel-version:

"nfs" kernel-version

1.7.
? ? ? .
"Error starting NFS daemon"
# mount -t nfsd nfsd /proc/fs/nfsd

386

Portage
.

387

Portage

1. Portage Setup Howto .....................................................................................................................


1.1. ............................................................................................................
1.2. howto? ...................................................................................................
1.3. Portage (Portage profiles) ....................................................................................
1.4. ........................................................................................................

388
388
388
388
389

1. Portage Setup Howto


1.1.
, Portage.

1.2. howto?
Portage Gentoo Linux. , USE-;
; ; ; , . . , , , ,
Gentoo Linux .
.

1.3. Portage (Portage profiles)


Gentoo ,
. .
, (, hardened selinux). -

388

Portage
, , Gentoo , ,
;). .
, , Gentoo-, .
/usr/portage/profiles. , . , 'default-x86-2004.2' x86 2004.2. deprecated, ,
.
/etc/make.profile
. , ln -s /usr/portage/profiles/default-x86-2004.2 /etc/make.profile
Gentoo, , .
/etc/make.profile , .
: Cascading
Profiles. :
default-linux/x86/2004.2/
, .
, , ;).
: - cascading profiles , , "Portage profiles"

1.4.
:
1.

use- ;

2.

, , emerge system;

3.

4.

. (CFLAGS, CHOST );

5.

. (, xorg xfree)

,
rsync-. portage
.
/etc/portage /etc/make.conf
, ,
/etc/portage. , . , Portage :
/etc/portage/package.mask
: DEPEND ATOM, >, <, >=, <=, =, , . .

389

Portage
: >=net-www/mozilla-1.7
:
net-www/mozilla-1.7 ( )
>=mozilla-1.7 ( )
: . , Portage
. , apache-1.3 apache-2.0
/etc/portage/package.unmask
: , package.mask
: , .
. , - .
/etc/portage/profile/package.provided
: , category/name-version
: dev-lang/ghc-6.2.1-r1
: 'emerge --inject'. package.provided Portage ,
.
: /etc/make.profile/
package.provided ( emerge sync)
/etc/portage/mirrors
: /usr/portage/profiles/thirdpartymirrors. : ,
. sourceforge gnu, .
: sourceforge http://keihanna.dl.sourceforge.net/sourceforge
'local'. , ebuild'
RESTRICT="NOMIRROR". :
local ftp://gentoo.linux.kiev.ua/pub/Linux/Gentoo/distfiles/
/etc/portage/package.use
: DEPEND ATOM USE-
: x11-libs/gtk+ doc
: USE-
/etc/portage/package.keywords
: DEPEND ATOM KEYWORD KEYWORD , , . 4 KEYWORDS:

390

Portage
arch arch
~arch arch,
-arch arch.
-*
: >=app-editors/emacs-cvs-21.3 ~x86
: KEYWORDS .
, :)
/etc/portage/categories
: . : Portage.
: app-vasia
ebuild app-vasia. emacs ${PORTDIR_OVERLAY}/appvasia/pupkin/pupkin-0.0.1.ebuild
/etc/make.conf
/etc/make.conf .
, /etc/make.conf.example.
$PORTDIR_OVERLAY
: , ebuild' , - . ebuild', , Portage . ebuild /usr/portage,
rsync-. , third-party ebuild' , (, /usr/local/portage)
$PORTDIR_OVERLAY /etc/make.conf. ebuild'
, .

391

Portage Overlay

1.
2.
3.
4.

.......................................................................................................................................
Portage Overlay .............................................................................................................
ebuild ............................................................................................................
digest- .................................................................................................................
4.1. ebuild .....................................................................................................
4.2. ...................................................................................................................

392
392
392
393
394
394

1.
ebuild .

2. Portage Overlay
PORTAGE_OVERLAY , /etc/make.conf
: /etc/make.conf
PORTDIR_OVERLAY="/usr/local/portage"
ebuild' .

3. ebuild
/usr/local/portage, install -d /usr/local/portage

392

Portage Overlay
ebuild /usr/local/portage, /usr/
portage (category/program/program.ebuild)

4. digest-
digest- , md5 , .
, Portage ,
md5- ( ). , Portage
, digest-. Digest- ebuild /
usr/local/portage/category/program/program.ebuild digest . ebuild-.
ebuild- ,
ebuild /usr/local/portage/category/program/program.ebuild digest :
!!! /usr/local/portage does not seem to have a valid PORTDIR structure.
ebuild , .
:
ebuild:
/usr/portage/media-sound/ncmpc/ncmpc-0.11.1-r1.ebuild
:
/usr/portage/distfiles/ncmpc-0.11.1.tar.gz ebuild-.
ebuild .
ebuld , '-rN', N
. :
cp
/usr/portage/media-sound/ncmpc/ncmpc-0.11.1-r1.ebuild
ncmpc-0.11.1-r2.ebuild

/usr/local/portage/media-sound/ncmpc/

,
ebuild /usr/portage/distfiles/ncmpc-0.11.1.tar.gz
/usr/portage/distfiles/ncmpc-0.11.1-r2.tar.gz
, ebuild:
vi /usr/local/portage/media-sound/ncmpc/ncmpc-0.11.1-r2.ebuild
:
SRC_URI="http://mercury.chem.pitt.edu/~shank/${P}.tar.gz mirror://sourceforge/musicpd/${P}.tar.gz"
:

393

Portage Overlay
SRC_URI="http://mercury.chem.pitt.edu/~shank/${P}-r2.tar.gz mirror://sourceforge/musicpd/${P}-r2.tar.gz"
.. '-r2', , . ,
.

ebuild /usr/local/portage/media-sound/ncmpc/ncmpc-0.11.1-r2.ebuild digest,
emerge .

4.1. ebuild
ebuild, masked,
/etc/portage/package.keywords
/etc/portage/, , :
echo "<category>/<package> ~x86" >>/etc/portage/package.keywords
:
emerge -p package
emerge package

4.2.
Unofficial ebuilds , ebuild', ,
Bugzill' Gentoo. ebuild'

394


deltup

1. ? ..............................................................................................................................
2. ..................................................................................................................
2.1. emerge ...............................................................................................................
2.2. getdelta ........................................................................................................
2.3. ...................................................................................................................

395
395
396
396
396

1. ?
, Gentoo Linux . . ,
, , gcc openoffice .
,
. , , deltup.
wget emerge getdelta.
, , .
, .

2.
deltup
deltup:
emerge deltup getdelta: emerge getdelta
: emerge deltup "!!!All ebuilds that could satisfy "deltup"
have been masked." ACCEPT_KEYWORDS="~x86"

395

deltup

2.1. emerge
emerge getdelta wget.
/etc/make.conf FETCHCOMMAND: : File /etc/make.conf
FETCHCOMMAND="/usr/bin/getdelta.sh \${URI}"

2.2. getdelta
getdelta :/etc/deltup/getdelta.rc. :
DELTUP_SERVER deltup . , deltup-
linux01.gwdg.de.
QUEUERETRY , getdelta, dtu-.
MAXIMUM_ACCEPTABLE_QUEUEPOS .
deltup- .
REMOVE_OLD . , .
DO_NOT_REMOVE , , REMOVE_OLD

2.3.
. ,
emerge FETCHCOMMAND, RESUMECOMMAND. RESUMECOMMAND getdelta, getdelta .

396




Gentoo . portage-xxxxxxxx.tar.bz2. portage-xxxxxxxx.tar.bz2.md5sum 40
( , )
:
/var/tmp/emerge-webrsync/ :
# mkdir /var/tmp/emerge-webrsync/
portage-xxxxxxxx.tar.bz2 portage-xxxxxxxx.tar.bz2.md5, , CD-ROM (/mnt/cdrom/portage-xxxxxxxx.tar.bz2 /mnt/cdrom/portagexxxxxxxx.tar.bz2.md5sum), :
# cp /mnt/cdrom/portage-xxxxxxxx.tar.bz2 /var/tmp/emerge-webrsync/
#cp /mnt/cdrom/portage-xxxxxxxx.tar.bz2.md5sum /var/tmp/emerge-webrsync/

emerge -webrsync: # emerge-webrsync
xxxxxxxx.
portage-xxxxxxxx.tar.bz2 40 :
/usr/portage /usr/portage2:
# mv /usr/portage /usr/portage2
/usr/portage:
# mkdir /usr/portage
/usr/portage2/distfiles ( :) ) /usr/portage/distfiles:
# cp /usr/portage2/distfiles /usr/portage/distfiles
portage-xxxxxxxx.tar.bz2, , , CD-ROM (/mnt/cdrom/portage-xxxxxxxx.tar.bz2), :
# tar -xvjpf /mnt/cdrom/portage-xxxxxxxx.tar.bz2 -C /usr/portage

397


:
# emerge metadata
xxxxxxxx, /usr/portage2 .
:
HOWTO .

398




( ) :
(, :) ), .
. / glibc baselayout texinfo gettext zlib binutils gcc ncurses. ,
.
:
( '2' '>') Code:
# emerge -fp glibc baselayout gettext zlib binutils gcc ncurses 2> stage1.list
# mount -t vfat /dev/fd0 /mnt/floppy
# cp /mnt/gentoo/stage1.list /mnt/floppy
# umount /mnt/floppy
. ( .)
stage1.list, ,
. , , . :
:
emerge, ! # cut -f 1 -d ' ' stage1.list > stage1.download
wget :
# wget -N -i stage1.download
, /mnt/gentoo/usr/portage/distfiles.

# emerge -pv glibc baselayout gettext zlib binutils gcc ncurses


Total Download: 0 .
:
# emerge glibc baselayout gettext zlib binutils gcc ncurses

399


. stage1.download . , distfiles. stage1.download
distfiles . .
Gentoo.org: http://www.gentoo.org/doc/ru/altinstall.xml

400

1. ......................................................................................................................................................
1.1. /var/lib/portage/world ......................................................................
2. ......................................................................................................................................................
2.1. USE- ........................................................................................................................
3. ......................................................................................................................................................
3.1. . ................................................................................................
4. ......................................................................................................................................................
4.1. . ...................................................................................
5. ......................................................................................................................................................
5.1. . ......................................................................................................
6. ......................................................................................................................................................
6.1. . ...............................................

401
401
402
402
404
404
404
404
405
405
405
405

1.
1.1. /var/lib/portage/
world
world , ,
"system" (.. ).
world , .., ,
- ( / ,
- ) , "system", world.
world , /etc/portage/package.mask.
regenworld world /var/log/emerge.log
world ( world!).
dep -p -w world( -
world system).

401


/etc/portage/*, .. .
profile
Gentoo release profile (, 2004.1 profile).
profile , ( ,
deprecated emerge ).
profile :
http://www.gentoo.org/doc/en/gentoo-upgrading.xml
/etc/make.profile

2.
2.1. USE-
emerge -uDpv --newuse world USE- ,
USE- /etc/make.conf /etc/portage/package.use
( toolchain)

emerge -uDav --newuse world


toolchain (linux-headers, glibc, binutils gcc),
.
:
emerge -uDav --newuse world
emerge -U -u
1: SLOT
, , , gimp-2 gimp-1.2.
, gimp-1.2 stable SLOT 1, gimp-2 unstable SLOT
2. ACCEPT_KEYWORDS=~x86 emerge gimp gimp-2.
, , - "emerge
-U world", gimp-1.2, , gimp world-, "-U"
SLOT .
2: , ebuild- Portage-.
, Portage 2 foo, foo-1.4 ( stable) foo-1.6 ( unstable). unstable emerge, gimp. -

402


world ,
foo-1.6 foo-1.6.1. .
foo-1.6 Portage. foo-1.4, ""
"-U"
, foo-1.6 Portage - : foo-1.6 (,
) , stable
- foo-1.6.
toolchain
- linux-headers, glibc, binutils gcc,
, system, world.
: toolchain toolchain . system/world , (
toolchain . ).
system/world toolchain. system world - , .. world system.
gcc, gcc-config gcc
" ", .
system toolchain
toolchain system. world system system world. ,
[1], `emerge -k` ( ).
, :
# , `emerge -k`
#
# (., /tmp/portage-packages)
pkgdir=$(portageq pkgdir)
mv $pkgdir /tmp/portage-packages1
install -d -o portage -g portage $pkgdir
# toolchain
emerge linux-headers glibc binutils gcc-config gcc
# gcc
gcc-config ____gcc
# . `gcc-config -l`

403


source /etc/profile
# toolchain
emerge -b glibc binutils gcc portage
# glibc, binutils gcc
emerge -bke system
# ( system)
emerge -bke world
: binutils-config, - gcc-config.

3.
3.1. .
: `emerge -uDav --newuse world`
!
glsa-check -l | grep '\[N\]'
emerge ... #

4.
4.1. .
, . , .. `emerge -uDav --newuse world`.
emerge -a depclean # !!!
, :
: glsa-check, revdep-rebuild gentoolkit
rm /root/.revdep-rebuild*.?_*
revdep-rebuild -p

404


revdep-rebuild

5.
5.1. .
dispatch-conf
runit-init baselayout, /sbin/init:
ls -l /sbin/*init*
if (/sbin/init , ) {
mv /sbin/init /sbin/init-sysv
ln -s runit-init /sbin/init
}

6.
6.1.
.
emerge world ,
, .
log- emerge world.
enotice, portlog-info.

405


, ,
.
,
, , Gentoo ,
CD .
Gentoo x86 (, Pentium Pro 200MHz RAM) x86_64- Gentoo. , 64- 32- , .
chroot- Gentoo-handbook, 64bit-Gentoo
"" CD:
# mkdir /your/new/gentoo
# tar xjvpf stage3-x86-*.tar.bz2 -C /your/new/gentoo
CHOST CFLAGS, ( CHOST, 2 3 ).
:
# CHOST="i686-pc-linux-gnu"
# CFLAGS="-march=pentiumpro -Os -momit-frame-pointer -pipe"
# CXXFLAGS="$CFLAGS"
chroot- , Gentoo .
i386 x86_64- ARCH=i386
.
# make menuconfig ARCH=i386
# make clean dep modules modules_install bzImage ARCH=i386
# cp arch/i386/boot/bzImage /boot/vmlinuz
""
CD Linux.
:
# cd /your/new/gentoo

406


# echo "/sys/*" >> tar_exclusions
# echo "/var/run/*" >> tar_exclusions
# echo "/tmp/*" >> tar_exclusions
# echo "/proc/*" >> tar_exclusions
#
# tar -C /your/new/gentoo -X tar_exclusions --preserve -cf ../gentoo.tar .
## -v -j / -z
# scp [-P ssh_port] ../gentoo.tar user@dest_pc:
:
# tar -C /your/new/system --preserve -xf ~user/gentoo.tar
chroot-. .
, , Gentoo.
, . ,
C-, gcc ( configure , /lib/cpp fails sanity check).
, /usr/include chroot-
.
!
http://gentoo-wiki.com/HOWTO_Compile_on_another_computer
Poor Fred

407

1. MS Windows - ...................................................................................................
1.1. ............................................................................................................................
1.2. ..................................................................................................................................
1.3. ...................................................................................................................
1.4. .............................................................................................................
2. Udev ..............................................................................................................................................
2.1. ...........................................................................................................
2.2. ...........................................................................................................
2.3. . ......................................................................................
2.4. Troubleshuting ....................................................................................................................
3. CFLAGS .................................................
3.1. ? .......................................................................................................
3.2. ......................................................................................................................
4. nano ...............................................................................................................................
4.1. ...........................................................................................................................
4.2. ................................................................................................................................
5. Udev ............................................................................................
5.1. ...........................................................................................................................
5.2. ........................................................................................................................
5.3. udev .............................................................................................................
5.4. ..................................................................................................................
5.5. .......................................................................................................................
6. glibc .......................................................................................................................
6.1. ...........................................................................................................................
6.2. Glibc ........................................................................................
6.3. ......................................................................................................................
6.4. .....................................................................................................................
7. USB-flash ................................................................................................................
7.1. USB-flash ..............................................................................
7.2. kde .......................................................................................................
7.3. .........................................................................................
8. - NTFS ntfs-3g ..............................................................
8.1. ............................................................................................................................
8.2. ...........................................................................................................................
8.3. ....................................................................................................
8.4. ..............................................................................................................

408

409
409
409
409
411
411
411
411
412
412
413
413
413
416
417
417
417
417
417
417
419
420
420
420
421
421
424
424
424
426
427
427
427
428
428
429

1. MS Windows -
1.1.
M$ Windows.

1.2.
, FAT NTFS,
.
Linux Kernel Configuration: Filesystems
File systems ->
DOS/FAT/NT Filesystems ->
(M) DOS FAT fs support
(M) MSDOS fs support
(M) VFAT (Windows-95) fs support
(M) NTFS file system support
:
Linux Kernel Configuration: Native Language Support
File systems ->
Native Language Support ->
<M> Windows CP1251 (Bulgarian, Belarusian)
<M> Codepage 866 (Cyrillic/Russian)

1.3.
windows- mount. mount -t file_system /dev/
device /mnt/dir file_system vfat ntfs,
windows.
FAT
FAT :
mount -t vfat -o codepage=866,iocharset=koi8-r,quiet,umask=000 /dev/hdd2 /mnt/win1

409


:
mount -t vfat -o codepage=866,iocharset=koi8-u,quiet,umask=000 /dev/hdd2 /mnt/win1
iocharset, codepage, quiet umask.
:
1.

codepage . ,
codepage=866. .

2.

iocharset /. . locale. ( /
. , ..
.)

3.

quiet FAT ,
.., FAT (
). ""

4.

umask
- . FAT , ( Linux )
umask. umask umask(2)

codepage iocharset . :
Linux Kernel Configuration: FAT
File systems ->
DOS/FAT/NT Filesystems ->
(utf8) Default iocharset for FAT
(866) Default codepage for FAT

mount -t vfat -o codepage=866,iocharset=utf8,quiet,umask=000 /dev/hdd2 /mnt/win1
mount -t vfat -o quiet,umask=000 /dev/hdd2 /mnt/win1
NTFS
NTFS mount . :
mount -t ntfs -o nls=koi8-r,umask=0,ro /dev/hdd2 /mnt/win1
:
mount -t ntfs -o nls=koi8-u,umask=0,ro /dev/hdd2 /mnt/win1
:
nls . codepage iocharset ,
NTFS .

410


umask .
ro. , NTFS .
utf-8, mount : mount -t ntfs -o utf8,umask=0,ro /dev/hdd2 /mnt/win1
utf8 UTF-8 .

1.4.
Windows ,
. /etc/fstab. : /etc/fstab
...
/dev/hda9 /mnt/win1 vfat auto,codepage=866,iocharset=koi8-r,quiet,umask=000 0 0
#/dev/hda9 /mnt/win1 vfat auto,codepage=866,iocharset=koi8-u,quiet,umask=000 0 0
/dev/hda3 /mnt/win2 ntfs auto,nls=koi8-r,umask=0,user 0 0
showexec, , FAT32

2. Udev
2.1.

emerge udev hotplug coldplug

2.2.
udev 2.6. 2.6.12-mm1.
General setup --->
[*] Support for hot-pluggable devices
File systems --->
Pseudo filesystems --->
[ ] /dev file system support (OBSOLETE)
[ ] Automatically mount at boot (NEW)

411


[*] Virtual memory file system support (former shm fs)
: devfs , .
, 2.6.13 ... .
: , 2.6.14

2.3. .

udev , udev.
/etc/conf.d/rc:
...
RC_DEVICE_TARBALL="no"
...
RC_DEVFSD_STARTUP="yes"
...
: "no", udev
rc-update add coldplug boot rc-update add hotplug default

GrUB
kernel :
kernel /boot/kernel-2.6.9-r4 root=/dev/hda3 gentoo=noudev
kernel :
kernel /boot/kernel-2.6.10-r6 root=/dev/hda3 gentoo=nodevfs

2.4. Troubleshuting

, . :
WARNING: Unable to open an initial console
, (
LiveCD) , /dev ( ) : Code:

412


# mknod -m 660 console c 5 1
# mknod -m 660 null c 1 3
POMAH007: ? udev guide
www.gentoo.org (http://www.gentoo.org/doc/en/udev-guide.xml), /dev : Code: Code Listing 3.1: Listing device nodes available at boot
# mkdir test
# mount --bind / test
# cd test/dev
# ls

, ... Xorg
:
Option "Device" "/dev/input/mice"
PS
. . , , /etc/conf.d/rc "no" udev.
PPS
,

3. CFLAGS

3.1. ?
, ;-). Gentoo' ;)
.
: , .

3.2.
CFLAGS

413


GCC,
CFLAGS. /etc/make.conf, :
/etc/make.conf;
(emerge ,
export ):
export CFLAGS=' '

gcc 3.x 5 : -O0 ( ), -O1, -O2
-O3 (O3 ), -Os.
: -O ,
.
-O0
. , register, .
-O(-O1)
. . . -O : -fthread-jumps,
-fdefer-pop.
, , -fdelayed-branch.
, ,
-fomit-frame-pointer.
.
-O2
. GCC , . , -O2. -O, , .
-O2 -O. :
-fforce-mem -foptimize-sibling-calls
-fstrength-reduce -fcse-follow-jumps -fcse-skip-blocks
-frerun-cse-after-loop -frerun-loop-opt -fgcse -fgcse-lm
-fgcse-sm -fgcse-las -fdelete-null-pointer-checks -fexpensive-optimizations
-fregmove -fschedule-insns -fschedule-insns2 -fsched-interblock
-fsched-spec -fcaller-saves -fpeephole2 -freorder-blocks
-fre-order-functions -fstrict-aliasing -funit-at-a-time -falign-functions

414


-falign-jumps -falign-loops -falign-labels -fcrossjumping
-O3
. -O2 -finline-functions
-fweb.
-Os
. -Os -O2, ,
. .
-Os : -falign-functions, -falign-jumps, -falign-loop, -falign-labels, freorder-blocks, -fprefetch-loop-arrays.
: -Ox, -fflag man gcc

, .
-mtune -march. , -mtune ,
, -march .
:
i386
i486
i586
i686
pentium
pentium-mmx
pentiumpro
pentium2
pentium3
pentium4
pentium-m
prescott
nocona
k6
k8
k6-2 ( , - , i686)
k6-3

415


athlon
athlon-tbird
athlon-4
athlon-xp
athlon-mp
athlon64
opteron
winchip-c6
winchip2
c3.
! pentium-m pentium3. Mobile Intel Pentium
4 M, pentium4 pentium4m ( )
(JohnBat26) ( 1.5): 4.2.0 ,
, ( : -march
-mtune):
1.

generic: , , x86;

2.

native: . cpuid ! .


. emerge acovea
pentium 3/4, gcc 3.3/3.4, .
-ftracer -mfpmath=sse. .
runacovea -config gcc33_pentium3.acovea -bench evobench.c .
, /usr/share/acovea/benchmarks, /usr/share/acovea/config, .

4. nano
nano Nano's ANOther editor
Nano , pico

416

4.1.
emerge nano

: /etc/nanorc

4.2.

nano -w somefile
-w .

5. Udev
5.1.
, udev usb-. , . - ?
.

5.2.
udev:
sys-fs/udev-069
, .. firmware
. - -, .

5.3. udev
flash-
udev, , , /etc/udev/rules.d/*. ,
, 2:

417


# ls /etc/udev/rules.d
05-udev-early.rules
50-udev.rules
. , udev
. , udev 2
:
Udev /etc/udev/rules.d .
, udev .
, ,
(50-udev.rules). 10-udev-my.rules. :
: /etc/udev/rules.d/10-udev-my.rules
# First rule
SUBSYSTEM=="block", KERNEL=="sd*", ACTION=="add", NAME="%k", GROUP="disk", RUN+="/etc/
udev/scripts/udev-flash-mount add %k"
#Second rule
SUBSYSTEM=="block", KERNEL=="sd*", ACTION=="remove", RUN+="/etc/udev/scripts/udev-flashmount remove %k"
, .
( )
SUBSYSTEM=="block" . block , . , udevmonitor
--env .. , SUBSYSTEM
block .
KERNEL=="sd*" , ,
. : sda, sda1, sdb, sdb1 ..
ACTION=="add" . , usb
.
NAME="%k" , , , . , .
, , . %k . man udev.
GROUP="disk" .
RUN+="/etc/udev/scripts/udev-flash-mount add %k" . ("+=") , . ( ) /etc/udev/scripts/udev-flash-mount 2 .
, , .

418


( )
ACTION=="remove" .
RUN+="/etc/udev/scripts/udev-flash-mount remove %k" ,
, .
, .
, .. , .

5.4.
, .
/usr/bin/. , root:
# su
:
# touch /etc/udev/scripts/udev-flash-mount
:
# chmod u+x /etc/udev/scripts/udev-flash-mount
: : /etc/udev/scripts/udev-flash-mount
#!/bin/bash
LOG="/var/log/udev"

sleep 3

DEV=`echo $2 | sed -n '/^sd[a-z][1-9]\?/p'`


if [ "$1" = "add" ]; then
if [ "$DEV" != "" ]; then
echo "--- `date` ---" >> $LOG
echo "Mounting /dev/$DEV" >> $LOG
mkdir /mnt/$DEV >> $LOG 2>&1
chmod a+rwx /mnt/$DEV >> $LOG 2>&1
mount /dev/$DEV /mnt/$DEV -o sync,umask=0000,iocharset=cp1251 >> $LOG 2>&1
fi
elif [ "$1" = "remove" ]; then

419


if [ "$DEV" != "" ]; then
echo "--- `date` ---" >> $LOG
echo "Unmounting /dev/$DEV" >> $LOG
umount /dev/$DEV >> $LOG 2>&1
rm -rf /mnt/$DEV >> $LOG 2>&1
fi
fi
3 , . , .
add, ,
. , , . ,
remove, . : sync mount , ..
. , ,
. , , . fat c linux 2.6.13
sync ..
usb2.0 200 usb1.0 10 20 .
, sync mount 6 . .
http://bugs.debian.org/309625
: ! - ,
, .
, .

5.5.
. , ,
, udev , , . - . ,

6. glibc
6.1.
Glibc ,
GNU/Linux. C ,
Linux, glibc
. Glibc -

420


. , , .
USE, emerge. USE. .

6.2. Glibc
CFLAGS
Glibc GCC glibc. Glibc
GCC CFLAGS. . CFLAGS , glibc.

-fomit-frame-pointer, glibc-omitfp USE. glibc. Code: Remerging glibc
emerge --newuse -v world
Glibc . glibc -enableomitfp, , , glibc --fomit-frame-pointer. .
glibc '' ''. ,
,
'' . glibc
--fomit-frame-pointer, .. (debug) ,
. , , .

glibc 2 linuxthreads nptl. ,
nptlonly, nptl linuxthreads. ,
, nptl.
, nptlonly, glibc (
linuxthreads ).

6.3.
Gentoo 8 2004 ,
(en:TIP Specifying only needed locales). , (
, ..) .
, , , aa_DJ (
) en_GB ( ) zu_ZA.utf8 ( ). 90% ,
Glibc , , , , .
( , ),
.

421


USE userlocales , /etc/locales.build.
/etc/make.conf userlocales - ""
USE="".
/etc/portage/package.use : Code: Activating the
userlocales USE flag for glibc
echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
, :
: nano -w /etc/locales.build
# !
en_US/ISO-8859-1
en_US.UTF-8/UTF-8
#en_GB/ISO-8859-1
#en_GB.UTF-8/UTF-8
de_DE/ISO-8859-1
de_DE@euro/ISO-8859-15
ru_RU.UTF-8/UTF-8
glibc-2.3.6-r4 glibc-2.4-r2, userlocales. /etc/locale.gen
/etc/locales.build.
: Code: Convert locales.build to locale.gen
cd /etc
grep '^[^#].*' locales.build | sed 's:/: :' > locale.gen
rm locales.build
nano -w locale.gen
: nano -w /etc/locale.gen
# !
en_US.UTF-8 UTF-8
en_US ISO-8859-1
ru_RU.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
/usr/share/i18n/SUPPORTED.

422


! , !
, . <locale>/<charmap>. <locale>
/usr/share/i18n/locales, <charmap> /usr/share/
i18n/charmaps/. : , , ,
@euro, . , UTF-8 .UTF-8 (, , , ).
,
. - , de
facto, ISO, ASCII .
,
Gentoo.
: : nano -w /etc/locales.build
# !
en_US.UTF-8/UTF-8
ru_RU.UTF-8/UTF-8
, US UTF-8. ,
.
Gentoo
.
Gentoo Handbook.
.
Gentoo
glibc , glibc:
Code: glibc
emerge glibc
world, ,
. .
, localepurge, man info- . man localepurge, , /etc/
locale.nopurge.
:
Gentoo Linux Localization Guide.
Gentoo Linux.
( , ,
!).

423

6.4.
? , , , . , ,
, , .
Glibc
( , , ...) USE hardened.
.

erandom , .

7. USB-flash
7.1. USB-flash

Linux ,
USB , .. :), ,
. .
, - USB,
USB . : USB , ..
.
,

USB Linux scsi , usb Linux
, .. /dev/sda1(2,3) ., .
, , scsi
Linux Kernel Configuration: SCSI
Device Drivers --->
SCSI device support
<*>legacy /proc/scsi/ support

424


--- SCSI support type (disk, tape, CD-ROM)
<*> SCSI disk support
<*> SCSI generic support
--- Some SCSI devices (e.g. CD jukebox) support multiple LUNs
<*> Probe all LUNs on each SCSI device
USB (
USB, )
Linux Kernel Configuration: USB
Device Drivers --->
USB support
<*> Support for Host-side USB
<*> USB device filesystem
<*> EHCI HCD (USB 2.0) support
< > OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
<*> USB Mass Storage support
: USB Mass Storage support ,
. , (
) .
, MTD
Linux Kernel Configuration: MTD
Device Drivers --->
Memory Technology Devices (MTD) --->
, . : , USB
MTD .

, Alt+F12 -
, USB , , /dev/uba ..
,
dmesg | grep usb
, USB BIOS :)
, , , ,
15 :)

425


dmesg | grep usb , , .
, .
/etc/fstab
: /etc/fstab
/dev/uba1 /mnt/usbdir auto user,noauto,rw 0 0
! , , ..
Native Languages .
!
, submount
:
: /etc/fstab
/dev/uba1 /mnt/usb subfs fs=vfat,auto,umask=0,quiet,sync 0 0
sync .
. !
- , ,
:)
, - tradakad
submount (dernik)

7.2. kde
: hal, dbus, and hotplug
hal /etc/make.conf
emerge -avt kdebase-kioslaves
, hal :
emerge -DNu world
rc-update add dbus default
/etc/init.d/dbus start
rc-update add hald default
/etc/init.d/hald start
/etc/fstab

426


emerge -av pmount
plugdev
gpasswd -a USER plugdev
"Storage media" (" " ) systray ( ).
:)

7.3.
, ,
, managed /etc/fstab ,
: /etc/fstab
/dev/cdrw
/dev/sda

/mnt/cdrom
/mnt/flash

iso9660

vfat

user,noauto,ro,managed

exec,user,noauto,sync,managed

00
00

, , .
ps. . gpasswd :
http://gentoo-wiki.com/HOWTO_D-BUS,_HAL,_KDE_media:/

8. - NTFS
ntfs-3g
8.1.
" ntfs-3g , GPL, NTFS Linux, Linux-NTFS. NTFS (-), . .
ntfsmount. , ." (Szakacsits Szabolcs, ntfs-3g)
, , NTFS
Linux, , Linux
EXT3 .
: [1]
: BETA, , / . , x86 amd64.

427


!!! !!!

8.2.
ebuild sys-fs/fuse (portage ).
-, :
# echo "sys-fs/ntfs3g ~x86" >> /etc/portage/package.keywords
:
# emerge sys-fs/ntfs3g
fuse
# modules-update
# modprobe fuse

:
# ntfs-3g /dev/hda1 /mnt/windows
, ,
( ru_RU.utf8, ):
# ntfs-3g /dev/hda1 /mnt/windows -o silent,umask=0,locale=ru_RU.utf8

# fusermount -u /mnt/windows
ntfs-3g .
$ man ntfs-3g
:
fuse :
# echo "fuse" >> /etc/modules.autoload.d/kernel-2.6
/etc/fstab:
# echo "/dev/hda1 /mnt/windows ntfs-3g silent,umask=0,locale=ru_RU.utf8 0 0" >> /etc/fstab

8.3.
, :

428


# emerge sys-fs/fuse
# modules-update
# modprobe fuse

8.4.
, . .

429

1. Apache2 ........................................................................................................................
1.1. ..........................................................................................................................
1.2. Apache ...................................................................................................................
1.3. .............................................................................................................................
1.4. ...................................................................................................................
1.5. Common Problems .............................................................................................................
1.6. See Also ............................................................................................................................
2. iptables .............................................................................................
2.1. ...........................................................................................................................
2.2. Linux ...........................................................................................
2.3. iptables .............................................................................................................
2.4. ...................................................................................................................
2.5. iptables ...................................................................................................................
2.6. /etc/init.d/iptables .......................................................................................
2.7. ...............................................................................................................
2.8. ...........................................................................................................
2.9. .....................................................................................................
2.10. ................................................................................................................
2.11. ............................................................................................................................
3. iptables .......................................................................................................
3.1. ............................................................................................................................
3.2. ............................................................................................................
3.3. .......................................................................................................
3.4. ...............................................................................................
3.5. .............................................................................................................
3.6. Scripting ..............................................................................................................................
3.7. ........................................................................................
3.8. Firewall ................................................................................................................
3.9. .....................................................................................
3.10. iptables ACCEPTS .............................................................................................................
3.11. iptables DROP & REJECT .................................................................................................
3.12. ...................................................................................................................
3.13. ....................................................................................................
3.14. .........................................................................
3.15. ......................................................
3.16. ........................................................................................
3.17. Ports ..................................................................................................................................
3.18. Sysctl' .............................................................................................................................
3.19. NAT ..............................................................................................

430

432
432
432
432
433
434
436
436
436
436
437
437
437
437
437
438
439
439
440
441
441
441
442
442
443
444
445
445
446
447
448
449
449
450
450
451
452
454
455


3.20. The full script ....................................................................................................................
4. ........................................................................................................
4.1. postfix ........................................................................................................
5. vsftpd ...........................................................................................................................
5.1. ...........................................................................................................................
5.2. VSFTPD ...........................................................................................................
5.3. ...............................................................................
5.4. ..................................................................................................................
5.5. ...................................................................................
5.6. .......................................................................................................
5.7. ............................................................................................................................
6. Jabber Server .................................................................................................................................
6.1. ............................................................................................................................
6.2. ..............................................................................................................
6.3. ....................................................................................................................
6.4. ....................................................................................................................
7. Counter-Strike ...............................................................................................
7.1. ............................................................................
7.2. .......................................................................................................
8. Samba Win2k .............................................................................................
8.1. .......................................................................................................................
8.2. .................................................................................................................
9. Samba PDC LDAP ...................................
9.1. ..................................................................................................
9.2. OpenLDAP ..........................................................................................................................
9.3. OpenLDAP .................................................................................................
9.4. SAMBA ..............................................................................................................................
9.5. LDAP .....................................................................
9.6. ...............................................................................................
10. ......................................................................................................
10.1. ..........................................................................................................................
10.2. "" ........................................................................................................
10.3. ...............................................................................
10.4. ..............................................................................................................
10.5. .................................................................................
10.6. ..............................................................................................................
10.7. Linux iptables ....................................................................................................................
10.8. FreeBSD ipfw ....................................................................................................................
10.9. .............................................................................................................
10.10. "" .........................................................................................
10.11. ............................................................................
10.12. rrdtool ........................................................................................................
10.13. Net-Telnet ..................................................................................................
10.14. Apache .......................................................................................................
10.15. ...........................................................................
10.16. .............................................................................
10.17. ...........................................................................................
10.18. ...........................................................................................
10.19. .................................................................................................................

431

457
465
466
473
473
473
474
474
474
475
475
476
476
476
476
477
477
477
477
478
478
478
482
482
482
484
484
492
494
498
498
499
499
500
503
504
504
505
507
508
511
511
512
512
513
514
516
519
519

1. Apache2
1.1.
Apache2 ,
Common Problems .
apache2: "apache2" USE /etc/make.conf :
emerge apache

1.2. Apache
Apache2:
/etc/init.d/apache2 start
apache2 :
rc-update add apache2 default
init scripts section .
Apache2. http://
localhost/ .
/var/www/localhost/htdocs/index.html HTML http://localhost/. Apache htdocs/index.html
htdocs/ . HTTP. Apache
. (index) . Apache index .
'index' ; .

1.3.
Apache . HTTP FTP.
, PHP . Apache . . . , , ().
Apache mod_something. . . :
1.

emerge module ;

432


2.

/etc/conf.d/apache2 -D MOD ;

3.

/etc/apache2/modules.d/xy_module ;

4.

httpd.conf .htaccess ;
emerge mod_perl
nano /etc/conf.d/apache2
# change APACHE_OPTS="" to APACHE_OPTS="-D PERL"

Apache Index in this wiki.


the documentation Apache.

1.4.
httpd.conf, (/etc/apache2/httpd.conf,) Gentoo Apache. However, it probably does both more and less than you need it to. Apache configuration files
have a consistent syntax.
#
# Apache
#
.
. .
<Section>
# Will only apply when the section matches
AnotherDirective
</Section>
. httpd.conf:
# If mod_alias is loaded
<IfModule mod_alias.c>
# Alias is a directive and it only applies if mod_alias is loaded
Alias /icons/ "/usr/share/httpd/icons/"
# If the file is in the directory
<Directory "/usr/share/httpd/icons">
# Options will only apply if:
# mod_alias is loaded AND

433


# the file is in the directory
Options Indexes MultiViews
</Directory>
</IfModule>
configuration files sections Apache.

1.5. Common Problems


SSI Not Working
When configuring for SSI (Server Side Includes), an error may occur:
mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
The problem is that setting Options +Includes in either .htaccess or httpd.conf is overwritten by the additional
configuration file as defined at the end of httpd.conf.
Include /etc/apache2/vhosts.d/*.conf
You need to edit this additional configuration file such that
AllowOverride None
Is replaced by
AllowOverride Options
Could Not Open Error Log
While starting Apache, it prints:
Error while starting apache: (2)No such file or directory: apache2: could not open error log file /usr/lib/apache2/
logs/error_log.
/usr/lib/apache2/logs should be a symlink pointing to /var/log/apache2 . Check it using:
ls -la /usr/lib/apache2/logs
(note the lack of a slash on the end). If /var/log/apache2 is missing, create it and make sure you give apache
ownership:
mkdir /var/log/apache2
chown apache:apache /var/log/apache2
If the symlink /usr/lib/apache2/logs is missing, you can create it:
ln -s /var/log/apache2 /usr/lib/apache2/logs
You don't need to set permissions on the symlink.
Check the Logs

434


See /var/log/apache2/error_log for errors, especially towards the end of the file. You may find tail useful because
it displays only the last few lines of a file:
tail /var/log/apache2/error_log
If you wish to keep an eye one the log the -f option for tail may be useful:
tail -f /var/log/apache2/error_log
Here's one error you might see:
Error: [alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of ""
With the base installation "mod_unique_id" is turned on, this can cause problems, notably the server not starting.
Simply comment out this module in /etc/apache2/httpd.conf and the problem will be solved.
(Your config file might be /etc/apache2/conf/apache2.conf)
Forbidden User Directories
If the server is returning "403 Forbidden" while accessing http://server/~username/ Make sure Apache (usually
user apache and group apache) has read access to username's home directory and public_html (or equivalent).
You can grant everyone read access using:
chmod 755 ~username/ ~username/public_html/
Not Enough Entropy
If Apache2
accepts connections
does not respond to clients
creates exactly one process
is not stopped by
/etc/init.d/apache2 stop
Check to see how much entropy is available using:
cat /proc/sys/kernel/random/entropy_avail
If little entropy (less than 100) is available, Apache2 is probably waiting for more so it can generate the secret
for digest authentication (mod_auth_digest). To generate more entropy, just do something else for a little while.
Grepping the kernel or emerging a package usually works well.
The video-entropyd and audio-entropyd supply /dev/random with entropy gathered from your video and audio
devices, respectively. If you have a hardware random number generator (RNG), you can emerge rng-tools and
run rngd.
If there's still a shortage of entropy, you can enable the urandom USE flag and re-emerge APR and Apache2.
This makes APR use /dev/urandom, which falls back to a pseudorandom number generator when there isn't
enough entropy. The program gets a number immediately, but it is cryptographically weaker. This is okay for
some things (e.g. solitaire), but completely unacceptable for others (like PGP key generation).

435


Confusing config files
If you start the Apache2 server with the startup script /etc/init.d/apache2 check to see if the line
local myconf="/etc/apache2/httpd.conf"
from /etc/init.d/apache2 points to your configuration script. If it points to apache.conf and you use httpd.conf,
make the necessary adjustments.

1.6. See Also


Configure LAMP (Linux, Apache, MySQL, and Python/PHP/Perl) A popular web server combination
Apache Installation & Configuration
How to install mod_security for Apache

2. iptables
2.1.
iptables .
. ,
.
, ...
1.

. , , . , iptables. ,
, , ,
.

2.

Linux
Gentoo Linux .
ifconfig, rc-update, /etc/conf.d/net, . , ,
Gentoo Linux Help's Networking Basics 101

2.2. Linux
iptables.
Networking --->
Networking Options---->
Network Packet Filtering (replace Ipchains)--->

436


Netfilter Configuration
( ,
, ).

2.3. iptables
iptables: emerge iptables

2.4.
, 2 : eth0 ppp0 .
ping:
Code: ping
ping www.google.com
ping 192.168.1.78
ping 192.168.2.77

2.5. iptables
iptables: /etc/init.d/iptables start
Linux. iptables : rc-update add iptables default

2.6. /etc/init.d/iptables
/etc/init.d/iptables (/etc/init.d/iptables <>), :
1.

start iptables. ( /var/lib/iptables/rules-save);

2.

stop ;

3.

save .

2.7.
: iptables -A _ -j

437

filter, . filter 3 : INPUT, OUTPUT FORWARD. "" :


1.

INPUT . .

2.

FORWARD , .

3.

OUTPUT , , .

: iptables <> <>


:
1.

-A . .

2.

-I , . :

iptables -I INPUT 2 bla-bla-bla .


1.

-D . :

iptables -D INPUT 5
1.

-F . , , .

2.

-N . , . : iptables -N .
, , .

3.

-X .

: INPUT, OUTPUT FORWARD .


1.

-P . :

iptables -P

2.8.
? .

-s.
192.168.133.133: iptables -A INPUT -s 192.168.133.133 -j DROP
. : iptables -A INPUT -s test.host.jp
-j DROP
: iptables -A INPUT -s 192.168.133.0/24 -j DROP
( !).
192.168.133.156 : iptables -A INPUT -s ! 192.168.133.156 -j DROP

438



-d.
192.168.156.156: iptables -A OUTPUT -d 192.168.156.156 -j DROP
.
.

-p . all, icmp, tcp, udp.



. : iptables -A INPUT -p tcp --sport 80 -j
ACCEPT
(tcp udp). .

. : iptables -A INPUT -p tcp --dport 80 -j ACCEPT
. .

2.9.
, . , .
-j. :
1.

ACCEPT .

2.

DROP .

3.

REJECT ICMP , .

4.

LOG (syslog).

.
, : iptables -A INPUT -s
192.168.200.0/24 -j LOCAL_NET

2.10.
:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -i lo -j ACCEPT
iptables -P INPUT DROP
. , .
.

439

2.11.
, iptables . iptables . -m.
: iptables -A INPUT -m bla-bla
-m owner
( OUTPUT):
1.

--uid-owner UID UID .

2.

--gid-owner GID GID .

2.6.14:
1.

--pid-owner PID PID .

2.

--sid-owner SID SID ( ) SID , SID


"".

3.

--cmd-owner NAME .

-m multiport
, :
1.

--source-ports 1,2 , ;

2.

--sports 1,2 --source-ports;

3.

--destination-ports 1,2 ;

4.

--dports 1,2 --destination-ports;

5.

--ports 1,2 .

-m state
--state. :
1.

NEW .

2.

ESTABLISHED .

3.

RELATED .

-m mac
MAC- --mac-source, :
iptables -A INPUT -s 192.168.0.1 -m mac --mac-source 00:65:3F:ED:12:98 -j DROP
http://ru.gentoo-wiki.com/_iptables__

440

3. iptables
3.1.
iptables .
, , , .
.
, pppoe 2.6.x .
ppp0 eth0 (
)
, ...
1.

1. . , ,
. ,
iptables. , , , ,
.

2.

2. . , , , man iptables
,
.

3.

3. Linux
Gentoo Linux .
ifconfig, rc-update, /etc/conf.d/net, . , ,
The Gentoo Handbook Linux Help's Networking Basics 101

3.2.
iptables.
Linux Kernel Configuration: IPTables
Device Drivers--->
Networking Support--->
Networking Options---->
Network Packet Filtering (replace Ipchains)--->
Netfilter Configuration

( , ) ip_tables modules.autoload. .

441


ip_conntrack "statefull" , .
:
# modprobe ip_tables

3.3.
iptables:
# emerge iptables

3.4.

HTTP, SMTP, SSH, SNMP, FTP, NNTP, NTP, LDAP, ...

TLS, SSL, RPC, WSP...

TCP, UDP, SCTP, ICMP, OSPF, RSVP, VRRP, RTP, DCCP


...

IPv4, IPv6, ARP, RARP, MPLS, IPX ...

Ethernet, 802.11, xDSL, Fibre Channel, FDDI, ATM, ISDN


...

3 . WAN pppoe. . , iptables (NAT'),


. , 2 ( ). IP-: 192.168.1.1
192.168.2.1.
, , . pppoe , , IP-. /etc/
conf.d/net . , pppoe
, . . conf.d/
:

: /etc/conf.d/net
# pppoe [[eth0]],
# net.ppp0 rc-pppoe default .
iface_eth0="192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0"
iface_eth1="192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0"

442

, .
1
: /etc/conf.d/net
iface_eth0="192.168.1.77 broadcast 192.168.1.255 netmask 255.255.255.0"
gateway="eth0/192.168.1.1"

2
: /etc/conf.d/net
iface_eth0="192.168.2.77 broadcast 192.168.2.255 netmask 255.255.255.0"
gateway="eth0/192.168.2.1"

IP , .
default :
# rc-update add net.eth1 default && rc-update add net.eth2 default && rc-update add net.ppp0 default

# /etc/init.d/net.eth1 start && /etc/init.d/net.eth2 start && /etc/init.d/net.ppp0 start


1.

# /etc/init.d/net.eth0 restart

3.5.
, ,
. :
Code: ping
ping www.google.com;
ping 192.168.1.78
ping 192.168.2.78
ping 192.168.1.77
ping 192.168.2.77

DNS- /etc/resolv.conf

443

3.6. Scripting
... iptables NAT( ). , .
: , , ...
. , .

: /var/lib/iptables/rules-save
#!/bin/bash
IPTABLES='/sbin/iptables'
#
EXTIF='ppp0'
INTIF1='eth1'
INTIF2='eth2'
# ip .
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward
#
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X
#
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
# $INTIF1 $EXTIF
$IPTABLES -A FORWARD -i $INTIF1 -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT
# $INTIF2 $EXTIF
$IPTABLES -A FORWARD -i $INTIF2 -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT
#echo -e "

SSH "

$IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT


#echo -e "

HTTP "

444


$IPTABLES -A INPUT --protocol tcp --dport 80 -j ACCEPT
# $EXTIF
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW,INVALID -j DROP
$IPTABLES -A FORWARD -i $EXTIF -m state --state NEW,INVALID -j DROP

3.7.
: - ... , ... , ,
. (, ).

ssh.
, .
... , IP- ... ...
, , :
# /etc/init.d/iptables save
" ":
# cp /var/lib/iptables/rules-save /var/lib/iptables/rules.working
iptables start-up iptables default runlevel:
Code:
1.

/etc/init.d/iptables start

2.

/etc/init.d/iptables stop

3.

/etc/init.d/iptables start

-- , iptables... . , ,
. . ,
iptables default runlevel:
rc-update add iptables default
/etc/sysctl.conf:
net.ipv4.ip_forward = 1

3.8. Firewall
, , .. . ,

445


, . :) ,
, , , - , .
SOHO, .. .
. , *nix, . , .. , ,
, DoS ,
.
, . - , . , ( )
.
( ) Firewall.
SSH, ,
. ,
. ,
, ymmv.

3.9.
:
Code: '
#!/bin/sh
#
#
EXTIF="ppp0"
#
INTIF="eth1"
# Loop device/localhost
LPDIF="lo"
LPDIP="127.0.0.1"
LPDMSK="255.0.0.0"
LPDNET="$LPDIP/$LPDMSK"
#
IPT="/sbin/iptables"
IFC="/sbin/ifconfig"
G="/bin/grep"
SED="/bin/sed"

446


AWK="/usr/bin/awk"
ECHO="/bin/echo"
# .
#
EXTIP="`$IFC $EXTIF | $AWK /$EXTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"
EXTBC="255.255.255.255"
#EXTMSK="`$IFC $EXTIF | $G Mask:|$SED 's/.*Mask:\([^ ]*\)/\1/'`"
EXTMSK="`$IFC $EXTIF | $AWK /$EXTIF/'{next}//{split($0,a,":");split(a[4],a," ");print a[1];exit}'`"
EXTNET="$EXTIP/$EXTMSK"
$ECHO "EXTIP=$EXTIP EXTBC=$EXTBC EXTMSK=$EXTMSK EXTNET=$EXTNET"
# Due to absence of EXTBC I manually set it to 255.255.255.255
# this (hopefully) will serve the same purpose
#
INTIP="`$IFC $INTIF | $AWK /$INTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"
INTBC="`$IFC $INTIF | $AWK /$INTIF/'{next}//{split($0,a,":");split(a[3],a," ");print a[1];exit}'`"
INTMSK="`$IFC $INTIF | $AWK /$INTIF/'{next}//{split($0,a,":");split(a[4],a," ");print a[1];exit}'`"
INTNET="$INTIP/$INTMSK"
$ECHO "INTIP=$INTIP INTBC=$INTBC INTMSK=$INTMSK INTNET=$INTNET"

3.10. iptables ACCEPTS


ACCEPT, , . . . , , .
ACCEPT . ,
.
Code: '
$IPT -t nat -A PREROUTING -j ACCEPT
# $IPT -t nat -A POSTROUTING -o $EXTIF -s $INTNET -j SNAT --to $EXTIP
# ( "MASQUERADE")
# (NAT)
$IPT -t nat -A POSTROUTING -o $EXTIF -s $INTNET1 -j MASQUERADE
$IPT -t nat -A POSTROUTING -o $EXTIF -s $INTNET2 -j MASQUERADE

447


$IPT -t nat -A POSTROUTING
$IPT -t nat -A OUTPUT

-j ACCEPT
-j ACCEPT

$IPT -A INPUT -p tcp --dport auth --syn -m state --state NEW -j ACCEPT
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

3.11. iptables DROP & REJECT


(chains) DROP REJECT. .
syslog, ( /var/log/messages).
( ) sed/grep
cron.
, . ,
. , . .
Code: '
# ********** **********
#
#
# .
# . DROP, REJECT.
# , ( ???)
$IPT -N DROPl 2> /dev/null
$IPT -A DROPl -m limit --limit 3/minute --limit-burst 10 -j LOG --log-prefix 'FIREWALL DROP BLOCKED:'
$IPT -A DROPl -j DROP
$IPT -N REJECTl 2> /dev/null
$IPT -A REJECTl -m limit --limit 3/minute --limit-burst 10 -j LOG --log-prefix 'FIREWALL REJECT BLOCKED:'
$IPT -A REJECTl -j REJECT
$IPT -N DROP2 2> /dev/null
$IPT -A DROP2 -m limit --limit 3/second --limit-burst 10 -j LOG --log-prefix 'FIREWALL DROP UNKNOWN:'
$IPT -A DROP2 -j DROP
$IPT -N REJECT2 2> /dev/null

448


$IPT -A REJECT2 -m limit --limit 3/second --limit-burst 10 -j LOG --log-prefix 'FIREWALL REJECT UNKNOWN:'
$IPT -A REJECT2 -j REJECT
# ACCEPT
$IPT -N ACCEPTl 2> /dev/null
$IPT -A ACCEPTl -m limit --limit 10/second --limit-burst 50 -j LOG --log-prefix 'FIREWALL ACCEPT:'
$IPT -A ACCEPTl -j ACCEPT

3.12.
, , , .
. , : ECHO='/bin/echo'
Code: '
# .
CHAINS=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $CHAINS
do
$IPT -t $i -F
done
for i in $CHAINS
do
$IPT -t $i -X
done

3.13.
, .
loopback , .
Code: '
$IPT -A INPUT -i $LPDIF -s $LPDIP -j ACCEPT
$IPT -A INPUT -i $LPDIF -s $EXTIP -j ACCEPT
$IPT -A INPUT -i $LPDIF -s $INTIP1 -j ACCEPT

449


$IPT -A INPUT -i $LPDIF -s $INTIP2 -j ACCEPT

3.14.
. DoS , DoS
. , DoS .
Code:
$IPT -A INPUT -i $EXTIF -d $EXTBC -j DROPl
$IPT -A INPUT -i $INTIF1 -d $INTBC1 -j DROPl
$IPT -A INPUT -i $INTIF2 -d $INTBC2 -j DROPl
$IPT -A OUTPUT -o $EXTIF -d $EXTBC -j DROPl
$IPT -A OUTPUT -o $INTIF1 -d $INTBC1 -j DROPl
$IPT -A OUTPUT -o $INTIF2 -d $INTBC2 -j DROPl
$IPT -A FORWARD -o $EXTIF -d $EXTBC -j DROPl
$IPT -A FORWARD -o $INTIF1 -d $INTBC1 -j DROPl
$IPT -A FORWARD -o $INTIF2 -d $INTBC2 -j DROPl

, , .
, DROP1 (chains). , (log file).

3.15.

, IP .
Code: '
#
#
# .
#
#

450


# " , ,
# , ,
# ."
$IPT -A INPUT -i $EXTIF -d ! $EXTIP -j DROPl

3.16.
.
.
Code: '
#
# .
# , ,
# , .
#
#
$IPT -A INPUT -i $INTIF1 -s ! $INTNET1 -j DROPl
$IPT -A OUTPUT -o $INTIF1 -d ! $INTNET1 -j DROPl
$IPT -A FORWARD -i $INTIF1 -s ! $INTNET1 -j DROPl
$IPT -A FORWARD -o $INTIF1 -d ! $INTNET1 -j DROPl
#
$IPT -A INPUT -i $INTIF2 -s ! $INTNET2 -j DROPl
$IPT -A OUTPUT -o $INTIF2 -d ! $INTNET2 -j DROPl
$IPT -A FORWARD -i $INTIF2 -s ! $INTNET2 -j DROPl
$IPT -A FORWARD -o $INTIF2 -d ! $INTNET2 -j DROPl

icmp ping.
Code: '
#
$IPT -A OUTPUT -o $EXTIF -s ! $EXTNET -j DROPl
# ICMP ( PING)

451


$IPT -A OUTPUT -o $EXTIF -p icmp --icmp-type ! 8 -j DROPl
$IPT -A FORWARD -o $EXTIF -p icmp --icmp-type ! 8 -j DROPl

. .

3.17. Ports
, :
# COMmon ports:
# 0 is tcpmux; SGI had vulnerability, 1 is common attack
# 13 is daytime
# 98 is Linuxconf
# 111 is sunrpc (portmap)
# 137:139, 445 is Microsoft
# SNMP: 161,2
# Squid flotilla: 3128, 8000, 8008, 8080
# 1214 is Morpheus or KaZaA
# 2049 is NFS
# 3049 is very virulent Linux Trojan, mistakable for NFS
# Common attacks: 1999, 4329, 6346
# Common Trojans 12345 65535
COMBLOCK="0:1 13 98 111 137:139 161:162 445 1214 1999 2049 3049 4329 6346 3128 8000 8008 8080
12345 65535"
# TCP ports:
# 98 is Linuxconf
# 512-5!5 is rexec, rlogin, rsh, printer(lpd)
# [very serious vulnerabilities; attacks continue daily]
# 1080 is Socks proxy server
# 6000 is X (NOTE X over SSH is secure and runs on TCP 22)
# Block 6112 (Sun's/HP's CDE)
TCPBLOCK="$COMBLOCK 98 512:515 1080 6000:6009 6112"

452


# UDP ports:
# 161:162 is SNMP
# 520=RIP, 9000 is Sangoma
# 517:518 are talk and ntalk (more annoying than anything)
UDPBLOCK="$COMBLOCK 161:162 520 123 517:518 1427 9000 9 6346 3128 8000 8008 8080 12345
65535"
:
echo -n "FW: Blocking attacks to TCP port"
for i in $TCPBLOCK;
do
echo -n "$i "
$IPT -A INPUT -p tcp --dport $i -j DROPl
$IPT -A OUTPUT -p tcp --dport $i -j DROPl
$IPT -A FORWARD -p tcp --dport $i -j DROPl
done
echo ""
echo -n "FW: Blocking attacks to UDP port "
for i in $UDPBLOCK;
do
echo -n "$i "
$IPT -A INPUT -p udp --dport $i -j DROPl
$IPT -A OUTPUT -p udp --dport $i -j DROPl
$IPT -A FORWARD -p udp --dport $i -j DROPl
done
echo ""
, , , ... .
... sed grep, EXTIP EXTBC
, . ,
. ,
.
DROP, . , -
ssh , , INPUT

453


ssh. .
, :
# , : ,
#
$IPT

-P INPUT

DROP

$IPT

-P OUTPUT

$IPT

-P FORWARD

DROP
DROP

#
CHAINS=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $CHAINS;
do
$IPT -t $i -F
done
for i in $CHAINS;
do
$IPT -t $i -X
done
$IPT -A INPUT -i $INTIF1 -p tcp --dport 22 --syn -m state --state NEW -j ACCEPT

3.18. Sysctl'
sysctl' tcp_syncookies, icmp_echo_ignore_broadcasts, rp_filter
accept_source_rout. , "", . , . :
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#
for f in /proc/sys/net/ipv4/conf/*/rp_filter;
do
echo 1 > $f
done

454


# IP ICMP-
for f in /proc/sys/net/ipv4/conf/*/accept_source_route;
do
echo 0 > $f
done
for f in /proc/sys/net/ipv4/conf/*/accept_redirects;
do
echo 0 > $f
done
echo 1 > /proc/sys/net/ipv4/ip_forward
ftp-,
PASV :
# ftp-
MODULES="ip_nat_ftp ip_conntrack_ftp"
for i in $MODULES;
do
echo " $i"
modprobe $i
done

3.19. NAT
, , . : IRC, MSN, ICQ, and NFS, FTP,
domain,time . ,
. ftp :
IRC='ircd'
MSN=1863
ICQ=5190
NFS='sunrpc'
# sync!!
PORTAGE='rsync'

455


OpenPGP_HTTP_Keyserver=11371
# /etc/services
TCPSERV="domain ssh http https ftp ftp-data mail pop3 pop3s imap3 imaps imap2 time $PORTAGE $IRC
$MSN $ICQ $OpenPGP_HTTP_Keyserver"
UDPSERV="domain time"
echo -n "FW: Allowing inside systems to use service:"
for i in $TCPSERV;
do
echo -n "$i "
$IPT -A OUTPUT -o $EXTIF -p tcp -s $EXTIP --dport $i --syn -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p tcp -s $INTNET1 --dport $i --syn -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p tcp -s $INTNET2 --dport $i --syn -m state --state NEW -j ACCEPT
done
echo ""
echo -n "FW: Allowing inside systems to use service:"
for i in $UDPSERV;
do
echo -n "$i "
$IPT -A OUTPUT -o $EXTIF -p udp -s $EXTIP --dport $i -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p udp -s $INTNET1 --dport $i -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p udp -s $INTNET2 --dport $i -m state --state NEW -j ACCEPT
done
echo ""
, . icmp- :
#
$IPT -A OUTPUT -o $EXTIF -p icmp -s $EXTIP --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p icmp -s $INTNET1 --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p icmp -s $INTNET2 --icmp-type 8 -m state --state NEW -j ACCEPT

456


# :
$IPT -A OUTPUT -o $INTIF1 -p icmp -s $INTNET1 --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A OUTPUT -o $INTIF2 -p icmp -s $INTNET2 --icmp-type 8 -m state --state NEW -j ACCEPT
,
. .
, :
# , :
$IPT -A INPUT
$IPT -A OUTPUT

-j DROPl
-j REJECTl

$IPT -A FORWARD

-j DROPl

, . nmap nessus IRC, MSN, ICQ, emerge sync.

3.20. The full script


, ( ssh ):
#
EXTIF=ppp0
#
INTIF1=eth1
INTIF2=eth2
# Loop-/localhost
LPDIF=lo
LPDIP=127.0.0.1
LPDMSK=255.0.0.0
LPDNET="$LPDIP/$LPDMSK"
#
IPT='/sbin/iptables'
IFC='/sbin/ifconfig'
G='/bin/grep'
SED='/bin/sed'

457


# ( )
JAMES=192.168.1.77
TERESA=192.168.2.77
# Deny accept: ""
# ,
$IPT

-P INPUT

DROP

$IPT

-P OUTPUT

$IPT

-P FORWARD

DROP
DROP

#
CHAINS=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $CHAINS
do
$IPT -t $i -F
$IPT -t $i -X
done
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#
for f in /proc/sys/net/ipv4/conf/*/rp_filter;
do
echo 1 > $f
done
# IP ICMP
for f in /proc/sys/net/ipv4/conf/*/accept_source_route;
do
echo 0 > $f
done
for f in /proc/sys/net/ipv4/conf/*/accept_redirects;
do

458


echo 0 > $f
done
echo 1 > /proc/sys/net/ipv4/ip_forward
#
EXTIP="`$IFC $EXTIF|$G addr:|$SED 's/.*addr:\([^ ]*\) .*/\1/'`"
#EXTBC="`$IFC $EXTIF|$G Bcast:|$SED 's/.*Bcast:\([^ ]*\) .*/\1/'`"
EXTBC="255.255.255.255"
EXTMSK="`$IFC $EXTIF|$G Mask:|$SED 's/.*Mask:\([^ ]*\)/\1/'`"
EXTNET="$EXTIP/$EXTMSK"
#echo "EXTIP=$EXTIP EXTBC=$EXTBC EXTMSK=$EXTMSK EXTNET=$EXTNET"
echo "EXTIP=$EXTIP EXTBC=$EXTBC EXTMSK=$EXTMSK EXTNET=$EXTNET"
# EXTBC , it to 255.255.255.255
# ()
#
INTIP1="`$IFC $INTIF1|$G addr:|$SED 's/.*addr:\([^ ]*\) .*/\1/'`"
INTBC1="`$IFC $INTIF1|$G Bcast:|$SED 's/.*Bcast:\([^ ]*\) .*/\1/'`"
INTMSK1="`$IFC $INTIF1|$G Mask:|$SED 's/.*Mask:\([^ ]*\)/\1/'`"
INTNET1="$INTIP1/$INTMSK1"
echo "INTIP1=$INTIP1 INTBC1=$INTBC1 INTMSK1=$INTMSK1 INTNET1=$INTNET1"
#
INTIP2="`$IFC $INTIF2|$G addr:|$SED 's/.*addr:\([^ ]*\) .*/\1/'`"
INTBC2="`$IFC $INTIF2|$G Bcast:|$SED 's/.*Bcast:\([^ ]*\) .*/\1/'`"
INTMSK2="`$IFC $INTIF2|$G Mask:|$SED 's/.*Mask:\([^ ]*\)/\1/'`"
INTNET2="$INTIP2/$INTMSK2"
echo "INTIP2=$INTIP2 INTBC2=$INTBC2 INTMSK2=$INTMSK2 INTNET2=$INTNET2"
# ,
# .
# log , .
# ,

459


# .
# , ( )
$IPT -N DROPl 2> /dev/null
$IPT -A DROPl -j LOG --log-prefix 'DROPl:'
$IPT -A DROPl -j DROP
$IPT -N REJECTl 2> /dev/null
$IPT -A REJECTl -j LOG --log-prefix 'REJECTl:'
$IPT -A REJECTl -j REJECT
# loopback
# IP .
$IPT -A INPUT -i $LPDIF -s $LPDIP -j ACCEPT
$IPT -A INPUT -i $LPDIF -s $EXTIP -j ACCEPT
$IPT -A INPUT -i $LPDIF -s $INTIP1 -j ACCEPT
$IPT -A INPUT -i $LPDIF -s $INTIP2 -j ACCEPT
#
$IPT -A INPUT -i $EXTIF -d $EXTBC -j DROPl
$IPT -A INPUT -i $INTIF1 -d $INTBC1 -j DROPl
$IPT -A INPUT -i $INTIF2 -d $INTBC2 -j DROPl
$IPT -A OUTPUT -o $EXTIF -d $EXTBC -j DROPl
$IPT -A OUTPUT -o $INTIF1 -d $INTBC1 -j DROPl
$IPT -A OUTPUT -o $INTIF2 -d $INTBC2 -j DROPl
$IPT -A FORWARD -o $EXTIF -d $EXTBC -j DROPl
$IPT -A FORWARD -o $INTIF1 -d $INTBC1 -j DROPl
$IPT -A FORWARD -o $INTIF2 -d $INTBC2 -j DROPl
# WAN
#
#
# iptables:
# "

460


# nefarious , "
$IPT -A INPUT -i $EXTIF -d ! $EXTIP -j DROPl
# , ,
# ..... ,
# pc , ,
# IP- .
# /
$IPT -A INPUT -i $INTIF1 -s ! $INTNET1 -j DROPl
$IPT -A OUTPUT -o $INTIF1 -d ! $INTNET1 -j DROPl
$IPT -A FORWARD -i $INTIF1 -s ! $INTNET1 -j DROPl
$IPT -A FORWARD -o $INTIF1 -d ! $INTNET1 -j DROPl
# /
$IPT -A INPUT -i $INTIF2 -s ! $INTNET2 -j DROPl
$IPT -A OUTPUT -o $INTIF2 -d ! $INTNET2 -j DROPl
$IPT -A FORWARD -i $INTIF2 -s ! $INTNET2 -j DROPl
$IPT -A FORWARD -o $INTIF2 -d ! $INTNET2 -j DROPl
# Egress-
$IPT -A OUTPUT -o $EXTIF -s ! $EXTNET -j DROPl
# ICMP ( PING)
$IPT -A OUTPUT -o $EXTIF -p icmp --icmp-type ! 8 -j DROPl
$IPT -A FORWARD -o $EXTIF -p icmp --icmp-type ! 8 -j DROPl
# :
# 0 tcpmux; SGI ,
# 13 daytime
# 98 Linuxconf
# 111 sunrpc (portmap)
# 137:139, 445 Microsoft
# SNMP: 161,2
# Squid: 3128, 8000, 8008, 8080

461


# 1214 Morpheus KaZaA
# 2049 NFS
# 3049 Linux, NFS
# : 1999, 4329, 6346
# 12345 65535
COMBLOCK="0:1 13 98 111 137:139 161:162 445 1214 1999 2049 3049 4329 6346 3128 8000 8008 8080
12345 65535"
# TCP:
# 98 Linuxconf
# 512-5!5 rexec, rlogin, rsh, printer(lpd)
# [ ; ]
# 1080 - Socks
# 6000 X (. X SSH , TCP 22)
# 6112 (CDE Sun HP)
TCPBLOCK="$COMBLOCK 98 512:515 1080 6000:6009 6112"
# UDP:
# 161:162 SNMP
# 520=RIP, 9000 Sangoma
# 517:518 talk ntalk ( )
UDPBLOCK="$COMBLOCK 161:162 520 123 517:518 1427 9000"
echo -n "FW: Blocking attacks to TCP port"
for i in $TCPBLOCK;
do
echo -n "$i "
$IPT -A INPUT -p tcp --dport $i -j DROPl
$IPT -A OUTPUT -p tcp --dport $i -j DROPl
$IPT -A FORWARD -p tcp --dport $i -j DROPl
done
echo ""
echo -n "FW: Blocking attacks to UDP port "

462


for i in $UDPBLOCK;
do
echo -n "$i "
$IPT -A INPUT -p udp --dport $i -j DROPl
$IPT -A OUTPUT -p udp --dport $i -j DROPl
$IPT -A FORWARD -p udp --dport $i -j DROPl
done
echo ""
# ftp
MODULES="ip_nat_ftp ip_conntrack_ftp"
for i in $MODULES;
do
echo "Inserting module $i"
modprobe $i
done
# .
# .
IRC='ircd'
MSN=1863
ICQ=5190
NFS='sunrpc'
# !!
PORTAGE='rsync'
OpenPGP_HTTP_Keyserver=11371
# /etc/services
TCPSERV="domain ssh http https ftp ftp-data mail pop3 pop3s imap3 imaps imap2 time $PORTAGE $IRC
$MSN $ICQ $OpenPGP_HTTP_Keyserver" UDPSERV="domain time"
echo -n "FW: Allowing inside systems to use service:"
for i in $TCPSERV;
do

463


echo -n "$i "
$IPT -A OUTPUT -o $EXTIF -p tcp -s $EXTIP --dport $i --syn -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p tcp -s $INTNET1 --dport $i --syn -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p tcp -s $INTNET2 --dport $i --syn -m state --state NEW -j ACCEPT
done
echo ""
echo -n "FW: Allowing inside systems to use service:"
for i in $UDPSERV;
do
echo -n "$i "
$IPT -A OUTPUT -o $EXTIF -p udp -s $EXTIP --dport $i -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p udp -s $INTNET1 --dport $i -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p udp -s $INTNET2 --dport $i -m state --state NEW -j ACCEPT
done
echo ""
# ping
$IPT -A OUTPUT -o $EXTIF -p icmp -s $EXTIP --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF1 -p icmp -s $INTNET1 --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A FORWARD -i $INTIF2 -p icmp -s $INTNET2 --icmp-type 8 -m state --state NEW -j ACCEPT
# ping
$IPT -A OUTPUT -o $INTIF1 -p icmp -s $INTNET1 --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A OUTPUT -o $INTIF2 -p icmp -s $INTNET2 --icmp-type 8 -m state --state NEW -j ACCEPT
$IPT -A INPUT -i $INTIF1 -p tcp --dport 22 --syn -m state --state NEW -j ACCEPT
$IPT -t nat -A PREROUTING -j ACCEPT
$IPT -t nat -A POSTROUTING -o $EXTIF -s $INTNET1 -j MASQUERADE
$IPT -t nat -A POSTROUTING -o $EXTIF -s $INTNET2 -j MASQUERADE
$IPT -t nat -A POSTROUTING -j ACCEPT
$IPT -t nat -A OUTPUT -j ACCEPT
$IPT -A INPUT -p tcp --dport auth --syn -m state --state NEW -j ACCEPT

464


$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# , .
$IPT -A INPUT -j DROPl
$IPT -A OUTPUT -j REJECTl
$IPT -A FORWARD -j DROPl

4.
Gentoo linux
postfix + cyrus-imap, cyrus-sasl - ( -
mysql postgress ). sasldb, .
,
. ,
.
/var reiserfs, .
emerge -pv cyrus-sasl
[ebuild N ] dev-libs/cyrus-sasl-2.1.20 -authdaemond +berkdb -debug +gdbm +java -kerberos -ldap +mysql
+pam -postgres +ssl -static 0 kB

emerge cyrus-sasl
,
emerge -pv postfix
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild N ] mail-mta/postfix-2.1.5-r1 +ipv6 -ldap -mailwrapper -mbox +mysql +pam -postgres -sasl*(selinux) +ssl -vda 0 kB
sasl, smtp, cyrus-sasl smtp

USE="sasl" emerge postfix

465



emerge -pv cyrus-imapd
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild N ] net-mail/cyrus-imapd-2.2.10 -afs -drac -idled -kerberos +pam -snmp +ssl +tcpd 0 kB
openssl imap-
emerge cyrus-imapd

emerge cyrus-imap-admin
,
cyrus-sasl
passwd cyrus
pwconv
chown -R cyrus:mail /etc/sasl2 cyrus /etc/sasl2/sasldb2
saslpasswd2 cyrus sasldb2
sasldblistusers2

4.1. postfix
C /etc/postfix/main.cf, ( relayhost), MX-
. , main.cf, .
postfix.
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
mail_owner = postfix
myhostname = mail.domain.tld
mydomain = mail.domain.tld
myorigin = $mydomain
inet_interfaces = all

466


mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
local_recipient_maps =
unknown_local_recipient_reject_code = 550
mynetworks_style = subnet
mynetworks = 192.168.1.0/24, 127.0.0.0/8
relay_domains = $mydestination
!!!
mailbox_transport = lmtp:unix:/var/imap/socket/lmtp
procmail
mailbox_transport = procmail
, main.cf, /etc/postfix/master.cf

# Also specify in main.cf: cyrus_destination_recipient_limit=1
cyrus

unix -

pipe

user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}


# Also specify in main.cf: cyrus_destination_recipient_limit=1
cyrus

unix -

pipe

user=cyrus argv=/cyrus/deliver -e -r ${sender} -m ${extension} ${user}


procmail,
procmail unix -

pipe

flags=R user=cyrus argv=/usr/bin/procmail -p /etc/procmailrc USER=${user}


/etc/procmailrc :
DELIVERMAIL=/usr/lib/cyrus/deliver
LOGFILE=/var/log/procmaillog
IMAP="$DELIVERMAIL -e -a $USER -m user.$USER"
( spamassassin)
:0fw : spamassassin.lock

467


* < 90000
| /usr/bin/spamassassin

:0
| $IMAP
:0w
{
EXITCODE=$?
HOST
}
, , cyrus-imapd
/etc/cyrus.conf
# $Header: /var/cvsroot/gentoo-x86/net-mail/cyrus-imapd/files/cyrus.conf,v
dragonheart Exp $
# Standard standalone server configuration.
START {
# Do not delete this entry!
recover

cmd="ctl_cyrusdb -r"

# This is only necessary if using idled for IMAP IDLE.


#idled

cmd="idled"

}
# UNIX sockets start with a slash and are put into /var/imap/socket.
SERVICES {
# Add or remove based on preferences.
imap

cmd="imapd" listen="imap2" prefork=0

pop3

cmd="pop3d" listen="pop-3" prefork=0

# Don't forget to generate the needed keys for SSL or TLS


# (see doc/html/install-configure.html).
imaps

cmd="imapd -s" listen="imaps" prefork=0

pop3s

cmd="pop3d -s" listen="pop3s" prefork=0

468

1.4

2004/07/18

04:02:23


sieve

cmd="timsieved" listen="sieve" prefork=0

# at least one LMTP is required for delivery


#lmtp

cmd="lmtpd" listen="lmtp" prefork=0

##
lmtpunix

cmd="lmtpd" listen="/var/imap/socket/lmtp" prefork=0

# this is only necessary if using notifications


#notify

cmd="notifyd" listen="/var/imap/socket/notify" proto="udp" prefork=1

}
EVENTS {
# This is required.
checkpoint

cmd="ctl_cyrusdb -c" period=30

# This is only necessary if using duplicate delivery suppression.


delprune

cmd="ctl_deliver -E 3" period=1440

# This is only necessary if caching TLS sessions.


tlsprune

cmd="tls_prune" period=1440

}

openssl req -new -nodes -out req.pem -keyout key.pem
openssl rsa -in key.pem -out new.key.pem
openssl x509 -in req.pem -out ca-cert -req \
-signkey new.key.pem -days 999
cp new.key.pem /etc/ssl/cyrus/server.pem
rm new.key.pem
cat ca-cert >> /etc/ssl/cyrus/server.pem
chown cyrus:mail /etc/ssl/cyrus/server.pem
chmod 600 /etc/ssl/cyrus/server.pem # Your key should be protected
-
/var/imap
cd /var

469


mkdir imap
chown cyrus:mail imap
chmod 750 imap
/var/spool/imap
cd /var/spool
mkdir imap
chown cyrus:mail imap
chmod 750 imap
/usr/sieve
cd /usr
mkdir sieve
chown cyrus:mail sieve
chmod 750 sieve
/etc/imapd.conf
configdirectory:

/var/imap

partition-default:
auto_transition:
tls_ca_path:

/var/spool/imap
yes
/etc/ssl/cyrus

tls_cert_file:

/etc/ssl/cyrus/server.pem

tls_key_file:

/etc/ssl/cyrus/server.pem

admins:

cyrus

hashimapspool:

yes

allowanonymouslogin:
allowplaintext:

yes

sasl_pwcheck_method:
sasl_auxprop_plugin:
sasldb_path:
sasl_mech_list:

no

auxprop
sasldb

/etc/sasl2/sasldb2
LOGIN PLAIN

sasldb, LOGIN,PLAIN
, ( ) /etc/imapd.conf

470


allowanonymouslogin: yes
cyrus
, cyradm
/etc/init.d/cyrus start
cyradm -user cyrus -server localhost
localhost> cm user.testuser
localhost> help
localhost> exit
sasldb2 :
saslpasswd2 testuser

/etc/init.d/postfix start
/etc/init.d/cyrus start
( thunderbird 1.0 KMail 1.7.1, Outlook Express
).
, - ,
/var/imap/socket/lmtp postfix cyrus,
. /etc/sasl2/sasldb2 cyrus,
mail.
clamav clamav + clamsmtp
amavisd-new. http://
www.nixp.ru/articles/clamav_postfix, , Gentoo
emerge clamav
ACCEPT_KEYWORDS="~x86" emerge clamsmtp ( )
/etc/conf.d/clamd START_CLAMD = yes ( 0.85
clamd.conf clamsmtpd.conf)
/etc/clamd.conf /etc/clamsmtpd.conf LocalSocket: /var/run/clamav/clamd.sock /etc/
clamav.conf ClamAddress: /var/run/clamav/clamd.sock /etc/clamsmtpd.conf

main.cf :
content_filter = scan:127.0.0.1:10025
receive_override_options = no_address_mappings

471


postfix' , () 'scan'
10025- , , , clamsmtpd. , postfix
, content_filter. ,
, ,
..
master.cf :
# AV scan filter (used by content_filter)
scan

unix -

16

smtp

-o smtp_send_xforward_command=yes
# For injecting mail back into postfix from the filter
127.0.0.1:10026 inet n

16

smtpd

-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks_style=host
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
: '=' . 127.0.0.1:10026 10026-
clamsmtpd.
rc-update add clamd default
rc-update add clamsmtpd default
/etc/init.d/postfix reload

P.S. .
( ) . ! .
. ,
,
.
PS.
aliases sendmail,

472


- cyradm -user cyrus -auth login -server localhost cm
etc/postfix/main.cf
alias_maps = hash:/usr/local/etc/postfix/aliases
alias_database = hash:/usr/local/etc/postfix/aliases

5. vsftpd
5.1.
en:HOWTO vsftpd. - ,
,
en:HOWTO Plan, setup and run a high school Gentoo Club .
VSFTP . FTP (File Transfer Protocol) , ,
.

5.2. VSFTPD
root : Code:
emerge vsftpd

. /etc/vsftpd/vsftpd.conf
:

: /etc/vsftpd/vsftpd.conf
dirmessage_enable=YES
# banner_file=/etc/vsftpd/vsftpd.banner # edit banner first
chown_uploads=NO
xferlog_enable=YES
idle_session_timeout=600
data_connection_timeout=120
ascii_upload_enable=NO

473


ascii_download_enable=NO
chroot_list_enable=YES
background=YES
listen=YES
ls_recurse_enable=NO
(Anonymous),
: /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
anon_upload_enable=NO
anon_mkdir_write_enable=NO

5.3.
ftp ( sftp/ssh), . : /etc/vsftpd/vsftpd.conf
local_enable=NO
write_enable=NO

5.4.
Gentoo , init scripts . /etc/init.d/ ,
. . VSFTPD Code: vsftpd
/etc/init.d/vsftpd start
"/etc/init.d/
vsftpd" ("start" , "stop" "restart") )

5.5.
/etc/init.d/vsftpd start ? Gentoo
.
VSFTPD , : Code: vsftpd
rc-update add vsftpd default
rc-update "man rc-update".

474


chkconfig: Code: vsftpd
chkconfig vsftpd on

5.6.
ftp ( ). /home/ftp. /var/ftp,
: /var/ftp Code:
rmdir /home/ftp
mkdir /var/ftp
chown ftp:ftp /var/ftp
ln -s /var/ftp /home/
- . ,
disfiles packages, : Code: '
mv /usr/portage/disfiles /var/ftp/
ln -s /var/ftp/disfiles /usr/portage/
mv /usr/portage/packages /var/ftp/
ln -s /var/ftp/packages /usr/portage/
: VSFTPD chroot ,
. /usr/portage/disfiles usr/portage/packages
.
.../ftp fstab.
: /var/ftp/distfiles /var/ftp/packages Code: '
mkdir /var/ftp/distfiles
mkdir /var/ftp/packages
/etc/fstab : Code: '
/usr/portage/distfiles /var/ftp/distfiles none ro,bind 0 0
/usr/portage/packages /var/ftp/packages none ro,bind 0 0

5.7.
c , ftp . :
ftp
lftp

475


mozilla-firefox
nautilus
gftp

6. Jabber Server
6.1.
Jabber , XML, . , jabber ICQ, IRQ, MSN, RSS,
Yahoo .

6.2.
jabber jabberd. IM- ICQ, MSN, Yahoo, SSL-
IPv6.
, USE- jabber: Code:
# emerge -pv jabberd
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild N ] net-im/jabberd-1.4.3-r5 -icq -ipv6 -ldap -msn -oscar -ssl -yahoo 0 kB
Total size of downloads: 0 kB
(, USE
make.conf) : USE="icq ssl" emerge jabberd jit Jabber
ICQ Transport, ICQ.

6.3.
, jabber, jabber:
gpasswd -a _ jabber
, jabber, XML /etc/jabber.
.

476

6.4.
:
rc-update add jabber default
: /etc/init.d/jabber start
:)

7. Counter-Strike
. Counter-Strike.CS:Source. ,
. CS 1.6.
.

7.1.
CS- :halflife-steam Code: emerge -pv
halflife-steam
Calculating dependencies ...done!
[ebuild N ] games-server/halflife-steam-2.0 3,431 kB
Total size of downloads: 3,431 kB
Steam Valve, steam-network.

7.2.
steam
emerge halflife-steam.
hl
Steam /opt/halflife
: 2006 .
, unix . , steam . cs xxx.WAD ( wad, ) Code:
cd /opt/halflife

477


chmod +x stream
Code:
./steam -command update -game cstrike -dir ./
. error . Code: output
HLDS installation up to date
: LAN ( ) steam .

8. Samba Win2k
:


:
Red Hat 9.0
Samba 3.0.13
DC win 2003 server

8.1.
,
,
.

8.2.
. 3.0.13.
RPM . ,
.
, ,
.
[global]
realm = bryusov.iasnet.ru
# Workgroup = NT- ( ):

478


workgroup = DOMAIN
# NetBIOS-, .
netbios name = NAU
# , " " Windows.
server string = Samba Server
# . Hosts allow
# IP- Samba-.
hosts allow = 172.18. 172.17. 127.
# %m Samba-
# log-.
log file = /var/log/samba/log.smbd
#
max log size = 500
# , ( DC)
security = domain
# Password server security = domain
password server = <IP >
#
allow trusted domains = yes
# .
encrypt passwords = yes
# .
# %m NetBIOS- .
# .
# include = /usr/local/samba/lib/smb.conf.%m
#
# , Unix
smb passwd file = /etc/samba/smbpasswd
unix password sync = Yes

479


passwd program = /usr/bin/passwd %u
passwd chat = *New*UNIX*password* %n\n
*passwd:*all*authentication*tokens*updated*successfully*

*ReType*new*UNIX*password*

%n\n

# ,
# Samba-.
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
# ,
interfaces = <ip >
# p NT-p:
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind enum groups = yes
winbind enum users = yes
# ,
# 3 ( KOI8-R )
# dos charset = CP866
# unix charset = KOI8-R
# display charset = KOI8-R
#
[FILES]
comment = share
path = /share/FILES
public = no
writable = yes
valid users = DOMAIN\users
create mask = 0744
#
, /etc/krb5.conf
[logging]
default = FILE:/var/log/krb5libs.log

480


kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
ticket_lifetime = 24000
default_realm = PDC.DOMAIN.NAME.RU
dns_lookup_realm = false
dns_lookup_kdc = false
[realms]
DOMAIN.NAME.RU = {
kdc = pdc.domain.name.ru:88
admin_server = kerberos.domain.name.ru:749
default_domain = domain.name.ru
}
[domain_realm]
.domain.name.ru = DOMAIN.NAME.RU
domain.name.ru = DOMAIN.NAME.RU
[kdc]
profile = /var/kerberos/krb5kdc/kdc.conf
[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}
.
,
, getent group .
.

481


,
.

9. Samba
PDC LDAP
9.1.
:
# USE="ldap acl ldapsam pam gdbm samba ssl tcpd winbind" emerge samba openldap acl nss_ldap pam_ldap
: nss_ldap 250-r1 (>=sys-auth/nss_ldap-250-r1)

9.2. OpenLDAP
OpenLDAP
amber.global.com
global.com, Win2003 Server.
:
amber global.com
: /etc/openldap/slapd.conf
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/samba.schema
pidfile
argsfile

/var/run/openldap/slapd.pid
/var/run/openldap/slapd.args

access to dn.base=""
by self write
by * auth

482


access to attr=userPassword
by self write
by * auth
access to attr=shadowLastChange
by self write
by * read
access to *
by * read
by anonymous auth
#loglevel 1
database

ldbm

suffix

"dc=amber,dc=global,dc=com"

rootdn

"cn=Manager,dc=amber,dc=global,dc=com"

# rootpw .
# slappasswd
# : slappasswd -h {MD5}
# rootpw = secret
rootpw
directory

{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==
/var/lib/openldap-ldbm

index objectClass

eq

index cn

eq,subinitial

index sn

eq,subinitial

index uid

eq,subinitial

index displayName

eq,subinitial

index uidNumber

eq

index gidNumber

eq

index memberUID
index sambaSID

eq
eq

index sambaPrimaryGroupSID eq

483


index sambaDomainName

eq

: /etc/openldap/ldap.conf
HOST 127.0.0.1
BASE dc=sanaa,dc=global,dc=com
/var/lib/openldap-*
ls -la /var/lib/
:
drwx------ 2 ldap

ldap

104 8 18:31 openldap-data

drwx------ 2 ldap

ldap

72 8 18:31 openldap-ldbm

drwx------ 2 ldap

ldap

72 8 18:31 openldap-slurp

9.3. OpenLDAP
, LDAP SAMBA ,
LDAP 389 localhost.
: /etc/conf.d/sldap
# conf.d file for the openldap-2.1 series
#
# To enable both the standard unciphered server and the ssl encrypted
# one uncomment this line or set any other server starting options
# you may desire.
#
# OPTS="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
OPTS="-h 'ldap://127.0.0.1'"
OpenLDAP
/etc/init.d/slapd start

9.4. SAMBA
OpenLDAP
2 :
. BDC, , -

484


PDC, PDC. , PDC
smbldap-tools.
emerge smbldap-tools
/etc/init.d/samba start
Code: configure.pl
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=smbldap-tools script configuration
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Before starting, check
. if your samba controller is up and running.
. if the domain SID is defined (you can get it with the 'net getlocalsid')
. you can leave the configuration using the Crtl-c key combination
. empty value can be set with the "." character
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Looking for configuration files...
Samba Configuration File Path [/etc/samba/smb.conf] >
The default directory in which the smbldap configuration files are stored is shown.
If you need to change this, enter the full directory path, then press enter to continue.
Smbldap-tools Configuration Directory Path [/etc/smbldap-tools/] >
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Let's start configuring the smbldap-tools scripts ...
. workgroup name: name of the domain Samba act as a PDC
workgroup name [amber] >
. netbios name: netbios name of the samba controler
netbios name [neptun] >
. logon drive: local path to which the home directory will be connected
(for NT Workstations). Ex: 'H:'
logon drive [U:] >
. logon home: home directory location (for Win95/98 or NT Workstation).

485


(use %U as username) Ex:'\\neptun\%U'
logon home (press the "." character if you don't want homeDirectory) [\\%L\users\%U] >
. logon path: directory where roaming profiles are stored. Ex:'\\neptun\profiles\%U'
logon path (press the "." character if you don't
want roaming profile) [\\%L\Profiles\%a\%U] >
. home directory prefix (use %U as username) [/home/%U] >
. default users' homeDirectory mode [700] >
. default user netlogon script (use %U as username) [] >
default password validation time (time in days) [45] > 900
. ldap suffix [dc=amber,dc=global,dc=com] >
. ldap group suffix [ou=Groups] >
. ldap user suffix [ou=Users] >
. ldap machine suffix [ou=Users] >
. Idmap suffix [ou=Idmap] >
. sambaUnixIdPooldn: object where you want to store the next uidNumber
and gidNumber available for new users and groups
sambaUnixIdPooldn object (relative to ${suffix}) [sambaDomainName=amber] >
. ldap master server: IP adress or DNS name of the master (writable) ldap server
ldap master server [127.0.0.1] >
. ldap master port [389] >
. ldap master bind dn [cn=Manager,dc=amber,dc=global,dc=com] >
. ldap master bind password [] >
. ldap slave server: IP adress or DNS name of the slave ldap server: can also
be the master one
ldap slave server [127.0.0.1] >
. ldap slave port [389] >
. ldap slave bind dn [cn=Manager,dc=amber,dc=global,dc=com] >
. ldap slave bind password [] >
. ldap tls support (1/0) [0] >

486


. SID for domain amber: SID of the domain (can be obtained with 'net getlocalsid neptun')
SID for domain amber [S-1-5-21-1918777035-593721947-2697221154] >
. unix password encryption: encryption used for unix passwords
unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA) [SSHA] > MD5
. default user gidNumber [513] >
. default computer gidNumber [515] >
. default login shell [/bin/bash] >
. default skeleton directory [/etc/skel] >
. default domain name to append to mail adress [] >
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
backup old configuration files:
/etc/smbldap-tools/smbldap.conf->/etc/smbldap-tools/smbldap.conf.old
/etc/smbldap-tools/smbldap_bind.conf->/etc/smbldap-tools/smbldap_bind.conf.old
writing new configuration file:
/etc/smbldap-tools/smbldap.conf done.
/etc/smbldap-tools/smbldap_bind.conf done.
, , /etc/smbldaptools/smbldap.conf : : /etc/smbldap-tools/smbldap.conf
...
userProfile=""
...

LDAP:
smbldap-populate -a Administrator -k 0 -m 0
SAMBA
: /etc/samba/smb.conf
[global]
workgroup = amber
netbios name = neptun
realm = amber.global.com

487


nt acl support = yes
acl compatibility = win2k
map acl inherit = yes
server string = Samba Server %v
interfaces = eth0
bind interfaces only = yes
hosts allow = 192.168.7. 127.
log file = /var/log/samba/log.%m
debug level = 9
max log size = 500
socket options = TCP_NODELAY SO_SNDBUF=8192 SO_RCVBUF=8192
security = user
os level = 250
passdb backend = ldapsam:"ldap://127.0.0.1/"
enable privileges = yes

passwd program = /usr/sbin/smbldap-passwd "%u"


passwd chat = *new*password* %n\n *new*password* %n\n *successfully*
passdb expand explicit = no
unix password sync = no
ldap passwd sync = no

ldap suffix = dc=amber,dc=global,dc=com


ldap admin dn = cn=Manager,dc=amber,dc=global,dc=com
ldap user suffix = ou=Users
ldap group suffix = ou=Groups
# .. ,
# ,
#

488


#
#
#

ldap machine suffix = ou=Computers

#
# :
ldap machine suffix = ou=Users
ldap idmap suffix = ou=Idmap
idmap backend = ldapsam:ldap://127.0.0.1/
idmap uid = 10000-20000
idmap gid = 10000-20000

ldap delete dn = Yes


ldap ssl = no

add user script = /usr/sbin/smbldap-useradd -n -a "%u"


delete user script = /usr/sbin/smbldap-userdel "%u"

add group script = /usr/sbin/smbldap-groupadd -p "%g"


delete group script = /usr/sbin/smbldap-userdel "%g"

add user to group script = /usr/sbin/smbldap-groupmod -m "%u" "%g"


delete user from group script = /usr/sbin/smbldap-groupmod -x "%u" "%g"
set primary group script = /usr/sbin/smbldap-usermod -g "%g" "%u"

add machine script = /usr/sbin/smbldap-useradd -w "%u"

#PDC

489


domain master = yes
preferred master = yes
#BDC
#

domain master = no

preferred master = no
domain logons = Yes

logon script =
# ,
# ( )
# :
#
#

logon path = \\%L\Profiles\%a\%U

#
# , ,
# ( ,
# ), :
logon path =
logon drive = U:
logon home = \\%L\users\%U

#============================ Share Definitions ==============================


[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
browseable = yes
guest ok = yes
writable = no

490


share modes = no
[Profiles]
admin users = admin
create mode = 600
directory mode = 700
path = /var/lib/samba/profiles
browseable = yes
guest ok = yes
writable = yes
[homes]
comment = Home Directories
browseable = no
read only = no
[public]
path = /pub
guest ok = yes
read only = no
[users]
path = /home/users
writable = yes
printable = no

winbind ( ): : /etc/conf.d/samba
...
daemon_list="smbd nmbd winbind"
...

:
smbpasswd -w secret

491


,
net rpc join -S neptun -U Administrator

9.5. LDAP
--ladserg 14:05, 28 2006 (UTC) samba LDAP LDAP, .
/etc/ldap.conf, :
: /etc/ldap.conf
host 127.0.0.1
base dc=amber,dc=global,dc=com
ldap_version 3
rootbinddn cn=Manager,dc=amber,dc=global,dc=com
bind_timelimit 10
bind_policy soft
pam_filter objectClass=posixAccount
pam_password exop
nss_base_passwd

ou=Users,dc=tty,dc=perm,dc=ru?one

nss_base_shadow

ou=Users,dc=tty,dc=perm,dc=ru?one

nss_base_group

ou=Groups,dc=tty,dc=perm,dc=ru?one

nss_base_hosts

ou=Hosts,dc=tty,dc=perm,dc=ru?one

nss_base_services

ou=Services,dc=tty,dc=perm,dc=ru?one

nss_base_networks

ou=Networks,dc=tty,dc=perm,dc=ru?one

nss_base_protocols

ou=Protocols,dc=tty,dc=perm,dc=ru?one

nss_base_rpc
nss_base_ethers

ou=Rpc,dc=tty,dc=perm,dc=ru?one
ou=Ethers,dc=tty,dc=perm,dc=ru?one

nss_base_netmasks

ou=Networks,dc=tty,dc=perm,dc=ru?one

nss_base_bootparams
nss_base_aliases
nss_base_netgroup

ou=Ethers,dc=tty,dc=perm,dc=ru?one

ou=Aliases,dc=tty,dc=perm,dc=ru?one
ou=Netgroup,dc=tty,dc=perm,dc=ru?one

492


ssl off
nss_reconnect_tries 4
nss_reconnect_sleeptime 1
nss_reconnect_maxsleeptime 16
nss_reconnect_maxconntries 2

nss_ldap .
/etc/ldap.secret plain/text
, rootbinddn, secret:
: /etc/ldap.secret
secret
:
Code: /etc/ldap.secret
#chmod 600 /etc/ldap.secret
#chown root:root /etc/ldap.secret
/etc/pam.d/system-auth :
: /etc/pam.d/system-auth
auth

required

pam_env.so

auth

sufficient pam_unix.so likeauth nullok

auth

sufficient pam_ldap.so use_first_pass

auth

required

pam_deny.so

account

sufficient pam_ldap.so

account

required

password required

pam_unix.so
pam_cracklib.so difok=2 minlen=8 dcredit=2 ocredit=2 retry=3

password sufficient pam_unix.so nullok md5 shadow use_authtok


password sufficient pam_ldap.so use_authtok
password required

pam_deny.so

session

required

pam_limits.so

session

required

pam_unix.so

session

required

pam_mkhomedir.so skel=/etc/skel/ umask=077

493


session

optional

pam_ldap.so

:
session required pam_mkhomedir.so skel=/etc/skel/ umask=077
,
/etc/skel/ 0x700
/etc/nsswitch.conf, :
: /etc/nsswitch.conf
passwd:

files ldap

shadow:

files ldap

group:

files ldap

hosts:

files dns

networks:
services:

files dns
db files

protocols: db files
rpc:

ldap [NOTFOUND=return] db files

ethers:

ldap [NOTFOUND=return] db files

netmasks:

files

netgroup:

ldap [NOTFOUND=return] files

bootparams: files
automount: files
aliases:

files

: ldap : hosts, networks,


protocols, services. .
, , LDAP.
, . udev, /etc/nsswitch.conf, ldap .

9.6.
smbldap-tools,
.

494



smbldap-useradd [-o] [-a] [-b] [-w] [-i] [-u uid] [-g gid ] [-G groups,,,]
[-n] [-d home] [-s shell] [-c gecos] [-m [-k]] [-t] [-P] [-A 0|1] [-B 0|1]
[-C sambaHomePath] [-D sambaHomeDrive] [-E sambaLogonScript] [-F sambaProfilePath]
[-H sambaAcctFlags] [-N surname] [-S family name] [-M local mailAddress,,,]
[-T mailToAddress] [-?] user
:
user
-o add the user in the organizational unit (relative to the user suffix)
-a is a Windows User (otherwise, Posix stuff only)
-b is a AIX User
-w is a Windows Workstation (otherwise, Posix stuff only)
-i is a trust account (Windows Workstation)
-u uid
-g gid
-G , .
-n do not create a group
-d ( /home/_)
-s ( /bin/false)
-c Windows
-m /etc/skel
-k ,
( -m)
-t time. Wait 'time' seconds before exiting (when adding Windows Workstation)
-P ends by invoking smbldap-passwd
-A , 0 , 1
-B , 0 , 1
-C samba ( '\\PDC-SRV\homes')
-D samba ( 'H:')

495


-E ,
-F ( '\\PDC-SRV\profiles\foo')
-H sambaAcctFlags (samba account control bits like '[NDHTUMWSLKI]')
-N ( )
-S
-M local mailAddress (comma seperated)
-T mailToAddress (forward address) (comma seperated)
-?
ladserg:
smbldap-useradd -a -c 'Serg Alex Lad' -N 'Serg Alex' -S 'Lad' -s /bin/bash ladserg
smbldap-tools ,
UTF-8.
, ladserg, Lad, Serg Alex, /bin/bash, /home/ladserg. -a ,
.

smbldap-passwd [-s] [-u] [-h] username
:
username

-h, -?, --help


-s

samba

-u

UNIX

:
smbldap-passwd ladserg
.
.

smbldap-usermod [-a] [-c comment] [-d home_dir] [-e expiration_date]
[-g initial_group] [-r new_login_name] [-p passwd] [-s shell] [-u uid [ -o]] [-x]
[-A canchange] [-B mustchange] [-C smbhome] [-D homedrive] [-E scriptpath]
[-F profilepath] [-G group[,...]] [-H acctflags] [-N canonical_name]

496


[-S surname] [-P] login
:
-c

-d

-r

- (cn, sn dn )

-u

- uid

-o

- uid

-g

- gid

-G

- , .

-s

-N

- ( )

-S

-P

- ends by invoking smbldap-passwd

For samba users:


-a

- add sambaSAMAccount objectclass

-e

- expire date ("YYYY-MM-DD HH:MM:SS")

-A

- , 0 , 1

-B

- , 0 , 1

-C

- samba ( '\\PDC-SRV\homes')

-D

- samba ( 'H:')

-E

- ,

-F

- ( '\\PDC-SRV\profiles\foo')

-H

- sambaAcctFlags (samba account control bits like '[NDHTUMWSLKI]')

-I

- disable an user. Can't be used with -H or -J

-J

- enable an user. Can't be used with -H or -I

-M

- mailAddresses (comma seperated)

-T

- mailToAddress (forward address) (comma seperated)

-?|-h
:

497


smbldap-usermod -A 1 ladserg
ladserg . :
smbldap-usermod -a slad-adm
slad-adm sambaSAMAccount, samba.

smbldap-userdel [-r|-R|-?] username
:
-r

-R

-?

:
smbldap-userdel -r slad-adm
slad-adm, .

Windows, ,
:
ftp://ftp.microsoft.com/Softlib/MSLFILES/SRVTOOLS.EXE

10.
10.1.
,
, GNU/Linux UNIX.

(
) , .
: http://monitoring.sourceforge.net/example.html
: (, , , ), (

498


, 100), , .
df, sar iptables ipfw.
: ,
, . I2C lm_sensors.
- Net-Telnet. rrdtool, apache / .
,
.
- . , , ,
.
, , ,
html , apache
.
, :
http://monitoring.sourceforge.net/
monitoring-*.tar.bz2 , ftp: /var/ftp/pub/
linux.

10.2. ""
monitoring-*.tar.bz2.
Gentoo , monitoring .
monitoring-*.ebuild.tar.bz2 /usr/local. :
# emerge -pv monitoring
[ebuild N ] net-analyzer/monitoring-0.11 USE="-admin -apache2 -lm_sensors -server"
USE="server",
USE="lm_sensors"
# export "USE=lm_sensors server"
# emerge monitoring
lm_sensors, sysstat, iptables, coreutils, xinetd Gentoo , , .

10.3.
: , ( ) , : http://secure.netroedge.com/~lm78/supported.html http://www.lmsensors.nu/~lm78/newdrivers.html , .

499


, , .
, 2.4.9,
! : i2c. 2.4.*, !
i2c-*.*.*.tar.gz, . 2.6.* i2c.

10.4.
" 2.6,
. 2.0"
, GNU/Linux :
ACPI:
Power management options (ACPI, APM) ---> ACPI (Advanced Configuration and Power Interface) Support
--->
IPMI .
Device Drivers ---> Character devices ---> IPMI --->

Device Drivers ---> I2C support --->
,
Device Drivers ---> I2C support ---> I2C Algorithms --->
(, , , . ):
Device Drivers ---> I2C support ---> I2C Hardware Bus support --->
Device Drivers ---> I2C support ---> Miscellaneous I2C Chip support --->
(, , ,
):
Device Drivers ---> Hardware Monitoring support --->
,
( sensors-detect). netfilter
(iptables) ...
, lm_sensors
: lm_sensors, lm_sensors-*.*.*.tar.gz. lm_sensors*.*.*.tar.gz , :
# make user

500


# make user_install
# depmod -a
, /usr/local/lib /etc/ld.so.conf, , :
# ldconfig
lm_sensors

# prog/mkdev/mkdev.sh
, , :
# prog/detect/sensors-detect
, , !
, modules.conf /etc/modules.conf
prog/init/lm_sensors.init /etc/rc.d/init.d/lm_sensors ( ).
, prog/detect/sensors-detect modprobe sensors -s , /etc/conf.d/local.start
:
Gentoo :
# rc-update -a lm_sensors default
RedHat :
# chkconfig --add lm_sensors
prog/init/lm_sensors.sysconfig /etc/sysconfig/lm_sensors
etc/sensors.conf.eg /etc/sensors.conf
prog/sensors/sensors /usr/bin/sensors ( )
modprobe , sensors-detect
, :
# sensors -s
/etc/sensors.conf , ,
, : "Volt", "Fan", "Temp". ,
, , "_",
., / +! !!!
/etc/sensors.conf server/etc/senso