Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas


Linux From Scratch-BOOK-7.1, Manuais, Projetos, Pesquisas de Cultura

Manual de Instalacao do Linux Livre

Tipologia: Manuais, Projetos, Pesquisas

2012

Compartilhado em 14/03/2012

lamech-de-seth-4
lamech-de-seth-4 🇧🇷

1 documento

1 / 345

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
Linux From Scratch
Version 7.1
Created by Gerard Beekmans
Edited by Matthew Burgess and Bruce Dubbs
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Pré-visualização parcial do texto

Baixe Linux From Scratch-BOOK-7.1 e outras Manuais, Projetos, Pesquisas em PDF para Cultura, somente na Docsity!

Linux From Scratch

Version 7.

Created by Gerard Beekmans Edited by Matthew Burgess and Bruce Dubbs

Linux From Scratch: Version 7.

by Created by Gerard Beekmans and Edited by Matthew Burgess and Bruce Dubbs Copyright © 1999-2012 Gerard Beekmans Copyright © 1999-2012, Gerard Beekmans All rights reserved. This book is licensed under a Creative Commons License. Computer instructions may be extracted from the book under the MIT License. Linux® is a registered trademark of Linus Torvalds.

iv

- 5.10. GCC-4.6.2 - Pass - 5.11. Tcl-8.5.11 - 5.12. Expect-5.45 - 5.13. DejaGNU-1.5 - 5.14. Check-0.9.8 - 5.15. Ncurses-5.9 - 5.16. Bash-4.2 - 5.17. Bzip2-1.0.6 - 5.18. Coreutils-8.15 - 5.19. Diffutils-3.2 - 5.20. File-5.10 - 5.21. Findutils-4.4.2 - 5.22. Gawk-4.0.0 - 5.23. Gettext-0.18.1.1 - 5.24. Grep-2.10 - 5.25. Gzip-1.4 - 5.26. M4-1.4.16 - 5.27. Make-3.82 - 5.28. Patch-2.6.1 - 5.29. Perl-5.14.2 - 5.30. Sed-4.2.1 - 5.31. Tar-1.26 - 5.32. Texinfo-4.13a - 5.33. Xz-5.0.3 - 5.34. Stripping - 5.35. Changing Ownership
  • III. Building the LFS System
      1. Installing Basic System Software
      • 6.1. Introduction
      • 6.2. Preparing Virtual Kernel File Systems
      • 6.3. Package Management
      • 6.4. Entering the Chroot Environment
      • 6.5. Creating Directories
      • 6.6. Creating Essential Files and Symlinks
      • 6.7. Linux-3.2.6 API Headers
      • 6.8. Man-pages-3.35
      • 6.9. Glibc-2.14.1
      • 6.10. Re-adjusting the Toolchain
      • 6.11. Zlib-1.2.6
      • 6.12. File-5.10
      • 6.13. Binutils-2.22
      • 6.14. GMP-5.0.4
      • 6.15. MPFR-3.1.0
      • 6.16. MPC-0.9
      • 6.17. GCC-4.6.2
      • 6.18. Sed-4.2.1
      • 6.19. Bzip2-1.0.6
    • 6.20. Ncurses-5.9 v
    • 6.21. Util-linux-2.20.1
    • 6.22. Psmisc-22.15
    • 6.23. E2fsprogs-1.42
    • 6.24. Coreutils-8.15
    • 6.25. Iana-Etc-2.30
    • 6.26. M4-1.4.16
    • 6.27. Bison-2.5
    • 6.28. Procps-3.2.8
    • 6.29. Grep-2.10
    • 6.30. Readline-6.2
    • 6.31. Bash-4.2
    • 6.32. Libtool-2.4.2
    • 6.33. GDBM-1.10
    • 6.34. Inetutils-1.9.1
    • 6.35. Perl-5.14.2
    • 6.36. Autoconf-2.68
    • 6.37. Automake-1.11.3
    • 6.38. Diffutils-3.2
    • 6.39. Gawk-4.0.0
    • 6.40. Findutils-4.4.2
    • 6.41. Flex-2.5.35
    • 6.42. Gettext-0.18.1.1
    • 6.43. Groff-1.21
    • 6.44. Xz-5.0.3
    • 6.45. GRUB-1.99
    • 6.46. Gzip-1.4
    • 6.47. IPRoute2-3.2.0
    • 6.48. Kbd-1.15.2
    • 6.49. Kmod-5
    • 6.50. Less-444
    • 6.51. Libpipeline-1.2.0
    • 6.52. Make-3.82
    • 6.53. Man-DB-2.6.1
    • 6.54. Patch-2.6.1
    • 6.55. Shadow-4.1.5
    • 6.56. Sysklogd-1.5
    • 6.57. Sysvinit-2.88dsf
    • 6.58. Tar-1.26
    • 6.59. Texinfo-4.13a
    • 6.60. Udev-181
    • 6.61. Vim-7.3
    • 6.62. About Debugging Symbols
    • 6.63. Stripping Again
    • 6.64. Cleaning Up
    1. Setting Up System Bootscripts
    • 7.1. Introduction
      • 7.2. General Network Configuration vi
      • 7.3. Customizing the /etc/hosts File
      • 7.4. Device and Module Handling on an LFS System
      • 7.5. Creating Custom Symlinks to Devices
      • 7.6. LFS-Bootscripts-20120229
      • 7.7. How Do These Bootscripts Work?
      • 7.8. Configuring the system hostname
      • 7.9. Configuring the setclock Script
      • 7.10. Configuring the Linux Console
      • 7.11. Configuring the sysklogd Script
      • 7.12. The rc.site File
      • 7.13. The Bash Shell Startup Files
      • 7.14. Creating the /etc/inputrc File
      1. Making the LFS System Bootable
      • 8.1. Introduction
      • 8.2. Creating the /etc/fstab File
      • 8.3. Linux-3.2.6
      • 8.4. Using GRUB to Set Up the Boot Process
      1. The End
      • 9.1. The End
      • 9.2. Get Counted
      • 9.3. Rebooting the System
      • 9.4. What Now?
  • IV. Appendices
    • A. Acronyms and Terms
    • B. Acknowledgments
    • C. Dependencies
    • D. Boot and sysconfig scripts version-20120229
      • D.1. /etc/rc.d/init.d/rc
      • D.2. /lib/lsb/init-functions
      • D.3. /etc/rc.d/init.d/functions
      • D.4. /etc/rc.d/init.d/mountvirtfs
      • D.5. /etc/rc.d/init.d/modules
      • D.6. /etc/rc.d/init.d/udev
      • D.7. /etc/rc.d/init.d/swap
      • D.8. /etc/rc.d/init.d/setclock
      • D.9. /etc/rc.d/init.d/checkfs
      • D.10. /etc/rc.d/init.d/mountfs
      • D.11. /etc/rc.d/init.d/udev_retry
      • D.12. /etc/rc.d/init.d/cleanfs
      • D.13. /etc/rc.d/init.d/console
      • D.14. /etc/rc.d/init.d/localnet
      • D.15. /etc/rc.d/init.d/sysctl
      • D.16. /etc/rc.d/init.d/sysklogd
      • D.17. /etc/rc.d/init.d/network
      • D.18. /etc/rc.d/init.d/sendsignals
      • D.19. /etc/rc.d/init.d/reboot
      • D.20. /etc/rc.d/init.d/halt vii
      • D.21. /etc/rc.d/init.d/template
      • D.22. /etc/sysconfig/rc
      • D.23. /etc/sysconfig/modules
      • D.24. /etc/sysconfig/createfiles
      • D.25. /etc/sysconfig/udev-retry
      • D.26. /sbin/ifup
      • D.27. /sbin/ifdown
      • D.28. /lib/services/ipv4-static
      • D.29. /lib/services/ipv4-static-route
    • E. Udev configuration rules
      • E.1. 55-lfs.rules
    • F. LFS Licenses
      • F.1. Creative Commons License
      • F.2. The MIT License
  • Index

viii

Preface

Foreword

My journey to learn and better understand Linux began over a decade ago, back in 1998. I had just installed my first Linux distribution and had quickly become intrigued with the whole concept and philosophy behind Linux. There are always many ways to accomplish a single task. The same can be said about Linux distributions. A great many have existed over the years. Some still exist, some have morphed into something else, yet others have been relegated to our memories. They all do things differently to suit the needs of their target audience. Because so many different ways to accomplish the same end goal exist, I began to realize I no longer had to be limited by any one implementation. Prior to discovering Linux, we simply put up with issues in other Operating Systems as you had no choice. It was what it was, whether you liked it or not. With Linux, the concept of choice began to emerge. If you didn't like something, you were free, even encouraged, to change it. I tried a number of distributions and could not decide on any one. They were great systems in their own right. It wasn't a matter of right and wrong anymore. It had become a matter of personal taste. With all that choice available, it became apparent that there would not be a single system that would be perfect for me. So I set out to create my own Linux system that would fully conform to my personal preferences. To truly make it my own system, I resolved to compile everything from source code instead of using pre-compiled binary packages. This “perfect” Linux system would have the strengths of various systems without their perceived weaknesses. At first, the idea was rather daunting. I remained committed to the idea that such a system could be built. After sorting through issues such as circular dependencies and compile-time errors, I finally built a custom-built Linux system. It was fully operational and perfectly usable like any of the other Linux systems out there at the time. But it was my own creation. It was very satisfying to have put together such a system myself. The only thing better would have been to create each piece of software myself. This was the next best thing. As I shared my goals and experiences with other members of the Linux community, it became apparent that there was a sustained interest in these ideas. It quickly became plain that such custom-built Linux systems serve not only to meet user specific requirements, but also serve as an ideal learning opportunity for programmers and system administrators to enhance their (existing) Linux skills. Out of this broadened interest, the Linux From Scratch Project was born. This Linux From Scratch book is the central core around that project. It provides the background and instructions necessary for you to design and build your own system. While this book provides a template that will result in a correctly working system, you are free to alter the instructions to suit yourself, which is, in part, an important part of this project. You remain in control; we just lend a helping hand to get you started on your own journey. I sincerely hope you will have a great time working on your own Linux From Scratch system and enjoy the numerous benefits of having a system that is truly your own.

-- Gerard Beekmans [email protected]

Audience

There are many reasons why you would want to read this book. One of the questions many people raise is, “why go through all the hassle of manually building a Linux system from scratch when you can just download and install an existing one?”

x

The default 64-bit build that results from LFS is considered a "pure" 64-bit system. That is, it supports 64-bit executables only. Building a "multi-lib" system requires compiling many applications twice, once for a 32-bit system and once for a 64-bit system. This is not directly supported in LFS because it would interfere with the educational objective of providing the instructions needed for a straightforward base Linux system. You can refer to the Cross Linux From Scratch project for this advanced topic. There is one last comment about 64-bit systems. There are some packages that cannot currently be built in a "pure" 64- bit system or require specialized build instructions. Generally, these packages have some embedded 32-bit specific assembly language instructions that fail when building on a 64-bit system. This includes some Xorg drivers from Beyond Linux From Scratch (BLFS). Many of these problems can be worked around, but may require some specialized procedures or patches.

LFS and Standards

The structure of LFS follows Linux standards as closely as possible. The primary standards are:

  • POSIX.1-.
  • Filesystem Hierarchy Standard (FHS)
  • Linux Standard Base (LSB) Core Specification 4. The LSB has five separate standards: Core, C++, Desktop, Runtime Languages, and Printing. In addition to generic requirements there are also architecture specific requirements. LFS attempts to conform to the architectures discussed in the previous section.

Note

Many people do not agree with the requirements of the LSB. The main purpose of defining it is to ensure that proprietary software will be able to be installed and run properly on a compliant system. Since LFS is source based, the user has complete control over what packages are desired and many choose not to install some packages that are specified by the LSB.

Creating a complete LFS system capable of passing the LSB certifications tests is possible, but not without many additional packages that are beyond the scope of LFS. Most of these additional packages have installation instructions in BLFS.

Packages supplied by LFS needed to satisfy the LSB Requirements

LSB Core: Bash, Binutils, Coreutils, Diffutils, File, Findutils, Gawk, Grep, Gzip, M4, Man- DB, Ncurses, Procps, Psmisc, Sed, Shadow, Tar, Util-linux, Zlib LSB C++: Gcc LSB Desktop: None LSB Runtime Languages: Perl LSB Printing: None LSB Multimeda: None

Packages supplied by BLFS needed to satisfy the LSB Requirements

LSB Core: Bc, Cpio, Ed, Fcrontab, Initd-tools, PAM, Sendmail (or Postfix or Exim) LSB C++: None

xi

LSB Desktop: ATK, Cairo, Desktop-file-utils, Freetype, Fontconfig, Glib2, GTK+2, Icon- naming-utils, Libjpeg, Libpng, Libxml2, MesaLib, Pango, Qt3, Qt4, Xorg LSB Runtime Languages: Python LSB Printing: CUPS LSB Multimeda: Alsa Libraries, NSPR, NSS, OpenSSL, Java

Packages not supplied by LFS or BLFS needed to satisfy the LSB Requirements

LSB Core: At, Batch, Lsb_release LSB C++: None LSB Desktop: None LSB Runtime Languages: None LSB Printing: None LSB Multimeda: Xdg-utils

Rationale for Packages in the Book

As stated earlier, the goal of LFS is to build a complete and usable foundation-level system. This includes all packages needed to replicate itself while providing a relatively minimal base from which to customize a more complete system based on the choices of the user. This does not mean that LFS is the smallest system possible. Several important packages are included that are not strictly required. The lists below document the rationale for each package in the book.

  • Autoconf This package contains programs for producing shell scripts that can automatically configure source code from a developer's template. It is often needed to rebuild a package after updates to the build procedures.
  • Automake This package contains programs for generating Make files from a template. It is often needed to rebuild a package after updates to the build procedures.
  • Bash This package satisfies an LSB core requirement to provide a Bourne Shell interface to the system. It was chosen over other shell packages because of its common usage and extensive capabilities beyond basic shell functions.
  • Binutils This package contains a linker, an assembler, and other tools for handling object files. The programs in this package are needed to compile most of the packages in an LFS system and beyond.
  • Bison This package contains the GNU version of yacc (Yet Another Compiler Compiler) needed to build several other LFS programs.
  • Bzip This package contains programs for compressing and decompressing files. It is required to decompress many LFS packages.
  • Coreutils

xiii

  • Grep

This package contains programs for searching through files. These programs are used by most packages' build scripts.

  • Groff

This package contains programs for processing and formatting text. One important function of these programs is to format man pages.

  • GRUB

This package is the Grand Unified Boot Loader. It is one of several boot loaders available, but is the most flexible.

  • Gzip

This package contains programs for compressing and decompressing files. It is needed to decompress many packages in LFS and beyond.

  • Iana-etc

This package provides data for network services and protocols. It is needed to enable proper networking capabilities.

  • Inetutils

This package contains programs for basic network administration.

  • IProute

This package contains programs for basic and advanced IPv4 and IPv6 networking. It was chosen over the other common network tools package (net-tools) for its IPv6 capabilities.

  • Kbd

This package contains key-table files, keyboard utilities for non-US keyboards, and a number of console fonts.

  • Kmod

This package contains programs needed to administer Linux kernel modules.

  • Less

This package contains a very nice text file viewer that allows scrolling up or down when viewing a file. It is also used by Man-DB for viewing manpages.

  • Libtool

This package contains the GNU generic library support script. It wraps the complexity of using shared libraries in a consistent, portable interface. It is needed by the test suites in other LFS packages.

  • Linux Kernel

This package is the Operating System. It is the Linux in the GNU/Linux environment.

  • M

This package contains a general text macro processor useful as a build tool for other programs.

  • Make

This package contains a program for directing the building of packages. It is required by almost every package in LFS.

xiv

  • Man-DB

This package contains programs for finding and viewing man pages. It was chosen instead of the man package due to superior internationalization capabilities. It supplies the man program.

  • Man-pages

This package contains the actual contents of the basic Linux man pages.

  • MPC

This package contains functions for the arithmetic of complex numbers. It is required by Gcc.

  • MPFR

This package contains functions for multiple precision arithmetic. It is required by Gcc.

  • Ncurses

This package contains libraries for terminal-independent handling of character screens. It is often used to provide cursor control for a menuing system. It is needed by a number of packages in LFS.

  • Patch

This package contains a program for modifying or creating files by applying a patch file typically created by the diff program. It is needed by the build procedure for several LFS packages.

  • Perl

This package is an interpreter for the runtime language PERL. It is needed for the installation and test suites of several LFS packages.

  • Procps

This package contains programs for monitoring processes. These programs are useful for system administration, and are also used by the LFS Bootscripts.

  • Psmisc

This package contains programs for displaying information about running processes. These programs are useful for system administration.

  • Readline

This package is a set of libraries that offers command-line editing and history capabilities. It is used by Bash.

  • Sed

This package allows editing of text without opening it in a text editor. It is also needed by most LFS packages' configure scripts.

  • Shadow

This package contains programs for handling passwords in a secure way.

  • Sysklogd

This package contains programs for logging system messages, such as those given by the kernel or daemon processes when unusual events occur.

  • Sysvinit

This package provides the init program, which is the parent of all other processes on the Linux system.

  • Tar

xvi

  • The Essential Pre-Reading Hint http://www.linuxfromscratch.org/hints/downloads/files/essential_prereading.txt This is an LFS Hint written specifically for users new to Linux. It includes a list of links to excellent sources of information on a wide range of topics. Anyone attempting to install LFS should have an understanding of many of the topics in this hint.

Host System Requirements

Your host system should have the following software with the minimum versions indicated. This should not be an issue for most modern Linux distributions. Also note that many distributions will place software headers into separate packages, often in the form of “-devel” or “-dev”. Be sure to install those if your distribution provides them. Earlier versions of the listed software packages may work, but has not been tested.

  • Bash-3.2 (/bin/sh should be a symbolic or hard link to bash)
  • Binutils-2.17 (Versions greater than 2.22 are not recommended as they have not been tested)
  • Bison-2.3 (/usr/bin/yacc should be a link to bison or small script that executes bison)
  • Bzip2-1.0.
  • Coreutils-6.
  • Diffutils-2.8.
  • Findutils-4.2.
  • Gawk-3.1.5 (/usr/bin/awk should be a link to gawk)
  • Gcc-4.1.2 (Versions greater than 4.6.2 are not recommended as they have not been tested)
  • Glibc-2.5.1 (Versions greater than 2.14.1 are not recommended as they have not been tested)
  • Grep-2.5.1a
  • Gzip-1.3.
  • Linux Kernel-2.6.25 (having been compiled with GCC-4.1.2 or greater) The reason for the kernel version requirement is that we specify that version when building glibc in Chapter 6 at the recommendation of the developers. It is also required by udev. If the host kernel is either earlier than 2.6.25, or it was not compiled using a GCC-4.1.2 (or later) compiler, you will need to replace the kernel with one adhering to the specifications. There are two ways you can go about this. First, see if your Linux vendor provides a 2.6.25 or later kernel package. If so, you may wish to install it. If your vendor doesn't offer an acceptable kernel package, or you would prefer not to install it, you can compile a kernel yourself. Instructions for compiling the kernel and configuring the boot loader (assuming the host uses GRUB) are located in Chapter 8.
  • M4-1.4.
  • Make-3.
  • Patch-2.5.
  • Perl-5.8.
  • Sed-4.1.
  • Tar-1.
  • Texinfo-4.
  • Xz-5.0. Note that the symlinks mentioned above are required to build an LFS system using the instructions contained within this book. Symlinks that point to other software (such as dash, mawk, etc.) may work, but are not tested or supported by the LFS development team, and may require either deviation from the instructions or additional patches to some packages.

xvii

To see whether your host system has all the appropriate versions, and the ability to compile programs, run the following:

cat > version-check.sh << "EOF" #!/bin/bash

Simple script to list version numbers of critical development tools

export LC_ALL=C bash --version | head -n1 | cut -d" " -f2- echo "/bin/sh -> readlink -f /bin/sh" echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- bison --version | head -n if [ -e /usr/bin/yacc ]; then echo "/usr/bin/yacc -> readlink -f /usr/bin/yacc"; else echo "yacc not found"; fi

bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f diff --version | head -n find --version | head -n gawk --version | head -n if [ -e /usr/bin/awk ]; then echo "/usr/bin/awk -> readlink -f /usr/bin/awk"; else echo "awk not found"; fi

gcc --version | head -n ldd --version | head -n1 | cut -d" " -f2- # glibc version grep --version | head -n gzip --version | head -n cat /proc/version m4 --version | head -n make --version | head -n patch --version | head -n echo Perl perl -V:version sed --version | head -n tar --version | head -n echo "Texinfo: makeinfo --version | head -n1" xz --version | head -n

echo 'main(){}' > dummy.c && gcc -o dummy dummy.c if [ -x dummy ] then echo "gcc compilation OK"; else echo "gcc compilation failed"; fi rm -f dummy.c dummy EOF

bash version-check.sh

xix

passwd will print the first man page it finds that matches “passwd”, which will be /usr/share/man/man1/ passwd.1. For this example, you will need to run man 5 passwd in order to read the specific page being referred to. It should be noted that most man pages do not have duplicate page names in different sections. Therefore, man __ is generally sufficient.

Structure

This book is divided into the following parts.

Part I - Introduction

Part I explains a few important notes on how to proceed with the LFS installation. This section also provides meta- information about the book.

Part II - Preparing for the Build

Part II describes how to prepare for the building process—making a partition, downloading the packages, and compiling temporary tools.

Part III - Building the LFS System

Part III guides the reader through the building of the LFS system—compiling and installing all the packages one by one, setting up the boot scripts, and installing the kernel. The resulting Linux system is the foundation on which other software can be built to expand the system as desired. At the end of this book, there is an easy to use reference listing all of the programs, libraries, and important files that have been installed.

Errata

The software used to create an LFS system is constantly being updated and enhanced. Security warnings and bug fixes may become available after the LFS book has been released. To check whether the package versions or instructions in this release of LFS need any modifications to accommodate security vulnerabilities or other bug fixes, please visit http://www.linuxfromscratch.org/lfs/errata/7.1/ before proceeding with your build. You should note any changes shown and apply them to the relevant section of the book as you progress with building the LFS system.

Part I. Introduction