Índice
It is wise for you as the system administrator to know roughly how the Debian system is started and configured. Although the exact details are in the source files of the packages installed and their documentations, it is a bit overwhelming for most of us.
I did my best to provide a quick overview of the key points of the Debian system and their configuration for your reference, based on the current and previous knowledge of mine and others. Since the Debian system is a moving target, the situation over the system may have been changed. Before making any changes to the system, you should refer to the latest documentation for each package.
O sistema do computador passa por várias fases de processos de boot strap desde o ligar da energia até que oferece o sistema operativo (OS) totalmente funcional ao utilizador.
Para simplicidade, eu limito a discussão à plataforma PC típica com a instalação predefinida.
O processo de boot strap típico é como um foguete de quatro etapas. Cada etapa do foguete entrega o controle do sistema à próxima etapa.
Of course, these can be configured differently. For example, if you compiled your own kernel, you may be skipping the step with the mini-Debian system. So please do not assume this is the case for your system until you check it yourself.
![]() |
Nota |
---|---|
For non-legacy PC platform such as the SUN or the Macintosh system, the BIOS on ROM and the partition on the disk may be quite different (Secção 9.3.1, “Configuração das partições do disco”). Please seek the platform specific documentations elsewhere for such a case. |
A BIOS é o 1ª etapa do processo de boot que é iniciado com o evento de ligar a energia. A BIOS que reside na read only memory (ROM) é executada a partir de um endereço de memória particular no qual o contador de programa da CPU é inicializado pelo evento de ligar a energia.
Esta BIOS executa a inicialização básica do hardware (POST: power on self test) e entrega o controle do sistema ao próximo passo que você disponibiliza. A BIOS é normalmente disponibilizada com o hardware.
The BIOS startup screen usually indicates what key(s) to press to enter the BIOS setup screen to configure the BIOS behavior. Popular keys used are F1, F2, F10, Esc, Ins, and Del. If your BIOS startup screen is hidden by a nice graphics screen, you may press some keys such as Esc to disable this. These keys are highly dependent on the hardware.
A localização do hardware e prioridade do código iniciado pela BIOS pode ser seleccionado no écran de configuração da BIOS. Tipicamente, os primeiros poucos sectores do primeiro dispositivo seleccionado encontrado (disco rijo, disquete, CD-ROM, ...) são carregados para a memória e este código inicial é executado. Este código inicial pode ser um dos seguintes.
Typically, the system is booted from the specified partition of the primary hard disk partition. First 2 sectors of the hard disk on legacy PC contain the master boot record (MBR). The disk partition information including the boot selection is recorded at the end of this MBR. The first boot loader code executed from the BIOS occupies the rest of this MBR.
The boot loader is the 2nd stage of the boot process which is started by the BIOS. It loads the system kernel image and the initrd image to the memory and hands control over to them. This initrd image is the root filesystem image and its support depends on the bootloader used.
O sistema Debian normalmente usa o kernel Linux como kernel predefinido do sistema. A imagem initrd para o kernel Linux 2.6 actual é tecnicamente a initramfs (sistema de ficheiros de RAM inicial). A imagem initramfs é um arquivo cpio gzipado de ficheiros no sistema de ficheiros raiz.
A instalação predefinida do sistema Debian coloca código da primeira etapa do gestor de arranque GRUB no MBR para a plataforma PC. Existem muitos gestores de arranque e opções de configuração disponíveis.
Tabela 3.1. Lista de gestores de arranque
gestor de arranque | pacote | popcon | tamanho | initrd | descrição |
---|---|---|---|---|---|
GRUB Legacy | grub-legacy * | V:0.4, I:1.1 | 1984 | Suportado |
Isto suficientemente inteligente para compreender partições de disco e
sistemas de ficheiros como vfat, ext3, ... (predefinição em
lenny
|
GRUB 2 | grub-pc * | V:7, I:25 | 2480 | Suportado | Isto suficientemente inteligente para compreender partições de disco e sistemas de ficheiros como vfat, ext3, ... |
GRUB 2 | grub-rescue-pc * | V:0.04, I:0.5 | 3896 | Suportado | Isto são imagens de arranque de recuperação do GRUB 2 (CD ou disquete) (Versão PC/BIOS) |
Lilo | lilo * | V:0.5, I:2 | 1236 | Suportado | Isto baseia-se nas localizações de sectores de dados no disco rijo. (Antigo) |
Isolinux | syslinux * | V:1.3, I:8 | 204 | Suportado | Isto compreende o sistema de ficheiros ISO9660. É usado pelo CD de arranque. |
Syslinux | syslinux * | V:1.3, I:8 | 204 | Suportado | Isto compreende o sistema de ficheiros MSDOS (FAT). É usado pela disquete de arranque. |
Loadlin | loadlin * | V:0.03, I:0.2 | 144 | Suportado | Novo sistema é iniciado a partir do sistema FreeDOS/MSDOS. |
MBR por Neil Turton | mbr * | V:0.8, I:5 | 96 | Não suportado | Isto é software livre que substitui o MBR do MSDOS. Isto apenas compreende partições de disco. |
![]() |
Atenção |
---|---|
Do not play with boot loaders without having bootable rescue media (CD or
floppy) created from images in the |
Para o GRUB Legacy, o ficheiro de configuração do menu está localizado em
"/boot/grub/menu.lst
". Por exemplo, tem entradas como a
seguinte.
title Debian GNU/Linux root (hd0,2) kernel /vmlinuz root=/dev/hda3 ro initrd /initrd.img
For GRUB 2, the menu configuration file is located at
"/boot/grub/grub.cfg
". It is automatically generated by
"/usr/sbin/update-grub
" using templates from
"/etc/grub.d/*
" and settings from
"/etc/default/grub
". For example, it has entries as the
following.
menuentry "Debian GNU/Linux" { set root=(hd0,3) linux /vmlinuz root=/dev/hda3 initrd /initrd.img }
Para estes exemplos, estes parâmetros do GRUB significam o seguinte.
Tabela 3.2. O significado dos parâmetros do GRUB
Parâmetro do GRUB | significado |
---|---|
root
|
usa a 3ª partição no disco primário a defini-la como
"(hd0,2) " no GRUB Legacy ou como
"(hd0,3) " no GRUB 2
|
kernel
|
usa o kernel localizado em "/vmlinuz " com parâmetro de
kernel: "root=/dev/hda3 ro "
|
initrd
|
usa a imagem initrd/initramfs
localizada em "/initrd.img "
|
![]() |
Nota |
---|---|
O valor do número de partição usado pelo programa GRUB legacy é menos um que o normal usado pelo kernel Linux e ferramentas utilitárias. O programa GRUB 2 corrige este problema. |
![]() |
Dica |
---|---|
UUID (see Secção 9.3.2, “Aceder a partição usando UUID”) may be used to identify a block
special device instead of its file name such as
" |
![]() |
Dica |
---|---|
Você pode iniciar um gestor de arranque a partir de outro gestor de arranque usando técnicas chamadas chain loading. |
Veja "info grub
" e grub-install
(8).
The mini-Debian system is the 3rd stage of the boot process which is started by the boot loader. It runs the system kernel with its root filesystem on the memory. This is an optional preparatory stage of the boot process.
![]() |
Nota |
---|---|
The term "the mini-Debian system" is coined by the author to describe this 3rd stage boot process for this document. This system is commonly referred as the initrd or initramfs system. Similar system on the memory is used by the Debian Installer. |
The "/init
" script is executed as the first program in
this root filesystem on the memory. It is a shell script program which
initializes the kernel in user space and hands control over to the next
stage. This mini-Debian system offers flexibility to the boot process such
as adding kernel modules before the main boot process or mounting the root
filesystem as an encrypted one.
You can interrupt this part of the boot process to gain root shell by
providing "break=init
" etc. to the kernel boot
parameter. See the "/init
" script for more break
conditions. This shell environment is sophisticated enough to make a good
inspection of your machine's hardware.
Commands available in this mini-Debian system are stripped down ones and
mainly provided by a GNU tool called busybox
(1).
![]() |
Cuidado |
---|---|
Você precisa de usar a opção " |
Tabela 3.3. Lista de utilitários de arranque para o sistema Debian
pacote | popcon | tamanho | descrição |
---|---|---|---|
initscripts *
|
V:91, I:99 | 284 | scripts para inicializar e desligar o sistema |
sysvinit *
|
V:85, I:99 | 208 |
utilitários de init (8) estilo System-V
|
sysv-rc *
|
V:91, I:99 | 300 | mecanismo de mudança de runlevel estilo System-V |
sysvinit-utils *
|
V:91, I:99 | 224 |
utilitários estilo System-V (startpar (8),
bootlogd (8), …)
|
lsb-base *
|
V:91, I:99 | 36 | Linux Standard Base funcionalidade de script de init 3.2 |
insserv *
|
V:22, I:26 | 292 | ferramenta para organizar a sequência de arranque usando dependências dos scripts init.d LSB |
upstart *
|
V:0.15, I:0.2 | 700 |
daemon de eventos baseado em init (8) para a concorrência
(alternativa a sysvinit )
|
readahead-fedora *
|
V:0.3, I:0.5 | 144 |
readahead (8) para pré-carregar os ficheiros do processo
de arranque
|
uswsusp *
|
V:4, I:14 | 536 | ferramentas para usar a suspensão de software no espaço de utilizador disponibilizadas pelo Linux |
kexec-tools *
|
V:0.17, I:0.5 | 320 |
kexec tool for kexec (8) reboots (warm reboot)
|
bootchart *
|
V:0.13, I:0.7 | 132 | analisador de performance do processo de arranque |
bootchart-view *
|
V:0.10, I:0.6 | 280 | analisador de performance do processo de arranque (visualização) |
mingetty *
|
V:0.2, I:0.5 | 64 |
getty (8) apenas de consola
|
mgetty *
|
V:0.19, I:0.6 | 416 |
substituto inteligente de modem getty (8)
|
![]() |
Nota |
---|---|
This section describes classical System V
style boot system on |
![]() |
Dica |
---|---|
All boot mechanisms are compatible through
" |
![]() |
Dica |
---|---|
O pacote |
The normal Debian system is the 4th stage of the boot process which is started by the mini-Debian system. The system kernel for the mini-Debian system continues to run in this environment. The root filesystem is switched from the one on the memory to the one on the real hard disk filesystem.
The "/sbin/init
" program is executed as the first program
and performs the main boot process. The Debian normally uses the traditional
sysvinit scheme with the sysv-rc
package. See
init
(8), inittab
(5), and
"/usr/share/doc/sysv-rc/README.runlevels.gz
" for the
exact explanation. This main boot process essentially goes through the
following.
/etc/inittab
" description.
The initial runlevel used for multi-user mode is specified with the
"init=
" kernel boot parameter or in the "initdefault"
line of the "/etc/inittab
". The Debian system as
installed starts at the runlevel 2.
Todos os ficheiros script actuais executados pelo sistema init estão
localizados no directório "/etc/init.d/
".
Cada runlevel usa um directório para a sua configuração e tem um significado específico como o seguinte.
Tabela 3.4. Lista de runlevels e descrição da sua utilização
runlevel | directório | descrição da utilização do runlevel |
---|---|---|
N
|
nenhum |
arranque do sistema em NENHUM nível (nenhum directório
"/etc/rcN.d/ ")
|
0
|
/etc/rc0.d/
|
parar o sistema |
S
|
/etc/rcS.d/
|
modo de utilizador singular no arranque (alias: "s ")
|
1
|
/etc/rc1.d/
|
modo de utilizador singular trocado a partir do modo de multi utilizador |
2
|
/etc/rc2.d/
|
modo de multi-utilizador |
3
|
/etc/rc3.d/
|
,, |
4
|
/etc/rc4.d/
|
,, |
5
|
/etc/rc5.d/
|
,, |
6
|
/etc/rc6.d/
|
reiniciar o sistema |
7
|
/etc/rc7.d/
|
modo de multi-utilizador válido mas normalmente não usado |
8
|
/etc/rc8.d/
|
,, |
9
|
/etc/rc9.d/
|
,, |
Você pode mudar o runlevel a partir da consola para, por exemplo 4, com o seguinte.
$ sudo telinit 4
![]() |
Cuidado |
---|---|
The Debian system does not pre-assign any special meaning differences among the runlevels between 2 and 5. The system administrator on the Debian system may change this. (I.e., Debian is not Red Hat Linux nor Solaris by Sun Microsystems nor HP-UX by Hewlett Packard nor AIX by IBM nor …) |
![]() |
Cuidado |
---|---|
The Debian system does not populate directories for the runlevels between 7 and 9 when the package is installed. Traditional Unix variants don't use these runlevels. |
![]() |
Nota |
---|---|
In Debian |
The name of the symlink in each runlevel directory has the form
"S<2-digit-number><original-name>
" or
"K<2-digit-number><original-name>
". The
2-digit-number is used to determine the order in which to run the
scripts. "S
" is for "Start" and "K
" is
for "Kill".
For "CONCURRENCY=none
", when init
(8)
or telinit
(8) commands goes into the runlevel to
"<n>", it execute following scripts.
K
" in
"/etc/rc<n>.d/
" are executed in alphabetical order
with the single argument "stop
". (killing services)
S
" in
"/etc/rc<n>.d/
" are executed in alphabetical order
with the single argument "start
". (starting services)
For example, if you had the links "S10sysklogd
" and
"S20exim4
" in a runlevel directory,
"S10sysklogd
" which is symlinked to
"../init.d/sysklogd
" would run before
"S20exim4
" which is symlinked to
"../init.d/exim4
".
For "CONCURRENCY=makefile
" (new default), package
dependency defined in the header of init scripts are used to order them.
![]() |
Atenção |
---|---|
It is not advisable to make any changes to symlinks in
" |
Por exemplo, vamos configurar o sistema runleve algo como o Red Hat Linux com o seguinte.
init
arranca o sistema em runlevel=3 por predefinição
init
não arranca o gdm
(1) nos
runlevel (0,1,2,6).
init
arranca o gdm
(1) em
runlevel=(3,4,5).
This can be done by using editor on the "/etc/inittab
"
file to change starting runlevel and using user friendly runlevel management
tools such as sysv-rc-conf
or bum
to
edit the runlevel. If you are to use command line only instead, here is how
you do it (after the default installation of the gdm
package and selecting it to be the choice of display manager).
# cd /etc/rc2.d ; mv S21gdm K21gdm # cd /etc ; perl -i -p -e 's/^id:.:/id:3:/' inittab
Please note the "/etc/X11/default-display-manager
" file
is checked when starting the display manager daemons:
xdm
, gdm
, kdm
, and
wdm
.
![]() |
Nota |
---|---|
Você ainda pode arrancar o X a partir de qualquer consola de shell com o
comando |
The default parameter for each init script in
"/etc/init.d/
" is given by the corresponding file in
"/etc/default/
" which contains environment variable
assignments only. This choice of
directory name is specific to the Debian system. It is roughly the
equivalent of the "/etc/sysconfig
" directory found in
Red Hat Linux and other distributions.
For example, "/etc/default/cron
" can be used to control
how "/etc/init.d/cron
" works.
O ficheiro "/etc/default/rcS
" pode ser usado para
personalizar as predefinições no momento de arranque para
motd
(5), sulogin
(8), etc.
Se não consegue obter o comportamento que deseja ao alterar tais variáveis então você pode modificar os scripts de init. Estes são ficheiros de configuração editáveis por administradores de sistemas.
The kernel maintains the system hostname. The init script in runlevel S which is
symlinked to "/etc/init.d/hostname.sh
" sets the system
hostname at boot time (using the hostname
command) to the
name stored in "/etc/hostname
". This file should contain
only the system hostname, not a fully
qualified domain name.
Para escrever o nome de máquina actual corra hostname
(1)
sem argumentos.
Apesar do sistema de ficheiros raiz ser montado pelo kernel quando arranca, outros sistemas de ficheiros são montados no runlevel S pelos seguintes scripts de init.
`/etc/init.d/mountkernfs.sh
" para sistemas de ficheiros
do kernel em "/proc
", "/sys
", etc.
`/etc/init.d/mountdevsubfs.sh
" para sistemas de
ficheiros virtuais em "/dev
"
`/etc/init.d/mountall.sh
" para sistemas de ficheiros
normais usando o "/etc/fstab
"
`/etc/init.d/mountnfs.sh
" para sistemas de ficheiros de
rede usando o "/etc/fstab
"
As opções de montagem do sistema de ficheiros são definidas em
"/etc/fstab
". Veja Secção 9.3.5, “Optimização do sistema de ficheiros por opções de montagem”.
![]() |
Nota |
---|---|
A montagem actual de sistemas de ficheiros de rede espera que a interface de rede arranque. |
![]() |
Atenção |
---|---|
Após montar todos os sistemas de ficheiros, os ficheiros temporários em
" |
As interfaces de rede são iniciadas no runlevel 5 pelo script de init
simbolicamente ligado a "/etc/init.d/ifupdown-clean
" e
"/etc/init.d/ifupdown
". Veja Capítulo 5, Configuração de rede para como os configurar.
Muitos serviços de rede (veja Capítulo 6, Aplicações de rede) são
iniciados sob modo de multi-utilizador directamente como processos daemon
durante o arranque pelo script de init, ex.,
"/etc/rc2.d/S20exim4
" (para RUNLEVEL=2) o que é um link
simbólico para "/etc/init.d/exim4
".
Some network services can be started on demand using the super-server inetd
(or its
equivalents). The inetd
is started at boot time by
"/etc/rc2.d/S20inetd
" (for RUNLEVEL=2) which is a symlink
to "/etc/init.d/inetd
". Essentially,
inetd
allows one running daemon to invoke several others,
reducing load on the system.
Whenever a request for service arrives at super-server inetd
, its
protocol and service are identified by looking them up in the databases in
"/etc/protocols
" and "/etc/services
".
inetd
then looks up a normal Internet service in the
"/etc/inetd.conf
" database, or a Open Network Computing Remote
Procedure Call (ONC RPC)/Sun RPC based service in
"/etc/rpc.conf
".
Sometimes, inetd
does not start the intended server
directly but starts the TCP wrapper
program, tcpd
(8), with the intended server name as its
argument in "/etc/inetd.conf
". In this case,
tcpd
runs the appropriate server program after logging
the request and doing some additional checks using
"/etc/hosts.deny
" and
"/etc/hosts.allow
".
Para segurança do sistema, desactive o máximo possível de programas de serviço de rede. Veja Secção 4.6.3, “Restringindo acesso a alguns serviços de servidor”.
Veja inetd
(8), inetd.conf
(5),
protocols
(5), services
(5),
tcpd
(8), hosts_access
(5),
hosts_options
(5), rpcinfo
(8),
portmap
(8), e
"/usr/share/doc/portmap/portmapper.txt.gz
".
The system message can be customized by
"/etc/default/syslogd
" and
"/etc/syslog.conf
" for both the log file and on-screen
display. See syslogd
(8) and
syslog.conf
(5). See also Secção 9.2.2, “Analizador de log”.
The kernel message can be customized by
"/etc/default/klogd
" for both the log file and on-screen
display. Set "KLOGD='-c 3'
" in this file and run
"/etc/init.d/klogd restart
". See
klogd
(8).
Você pode alterar directamente o nível de mensagens de erro fazendo o seguinte.
# dmesg -n3
Tabela 3.5. Lista de níveis de erro do kernel
valor de nível de erro | nome de nível de erro | significado |
---|---|---|
0 | KERN_EMERG | sistema está inutilizável |
1 | KERN_ALERT | acção tem de ser tomada imediatamente |
2 | KERN_CRIT | condições críticas |
3 | KERN_ERR | condições de erro |
4 | KERN_WARNING | condições de aviso |
5 | KERN_NOTICE | condição normal mas significante |
6 | KERN_INFO | informativa |
7 | KERN_DEBUG | mensagens de nível de depuração |
For Linux kernel 2.6, the udev system
provides mechanism for the automatic hardware discovery and initialization
(see udev
(7)). Upon discovery of each device by the
kernel, the udev system starts a user process which uses information from
the sysfs filesystem (see Secção 1.2.12, “procfs e sysfs”), loads required kernel modules supporting it
using the modprobe
(8) program (see Secção 3.5.12, “A inicialização de módulos do kernel”), and creates corresponding
device nodes.
![]() |
Dica |
---|---|
If " |
The name of device nodes can be configured by udev rule files in
"/etc/udev/rules.d/
". Current default rules tend to
create dynamically generated names resulting non-static device names except
for cd and network devices. By adding your custom rules similar to what cd
and network devices do, you can generate static device names for other
devices such as USB memory sticks, too. See "Writing udev rules" or
"/usr/share/doc/udev/writing_udev_rules/index.html
".
Como o sistema udev é de certa maneira um alvo em movimento, eu deixo os detalhes para outras documentações e descrevo a informação mínima aqui.
![]() |
Dica |
---|---|
Para regras de montagem em " |
The modprobe
(8) program enables us to configure running
Linux kernel from user process by adding and removing kernel modules. The
udev system (see Secção 3.5.11, “O sistema udev”) automates its
invocation to help the kernel module initialization.
There are non-hardware modules and special hardware driver modules as the
following which need to be pre-loaded by listing them in the
"/etc/modules
" file (see modules
(5)).
iptables
(8), Secção 5.9, “Infraestrutura do netfilter”), e
The configuration files for the modprobe
(8) program are
located under the "/etc/modprobes.d/
" directory as
explained in modprobe.conf
(5). (If you want to avoid
some kernel modules to be auto-loaded, consider to blacklist them in the
"/etc/modprobes.d/blacklist
" file.)
O ficheiro "/lib/modules/<version>/modules.dep
"
gerado pelo programa depmod
(8) descreve as dependências
dos módulos usados pelo programa modprobe
(8).
![]() |
Nota |
---|---|
If you experience module loading issues with boot time module loading or
with |
O programa modinfo
(8) mostra informação sobre um módulo
do kernel Linux.
O programa lsmod
(8) formata lindamente o conteúdo de
"/proc/modules
", e mostra que módulos do kernel estão
actualmente carregados.
![]() |
Dica |
---|---|
Você pode identificar o hardware exacto no seu sistema. Veja Secção 9.6.3, “Identificação do hardware”. |
![]() |
Dica |
---|---|
Você pode configurar o hardware durante o arranque par activar as funcionalidades esperadas do hardware. Veja Secção 9.6.4, “Configuração do hardware”. |
![]() |
Dica |
---|---|
Você pode adicionar suporta para o seu dispositivo ao recompilar o kernel. Veja Secção 9.7, “O kernel”. |