This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
GRUB2 Começo Rápido
Este artigo fornece informações sobre como começar a trabalhar com o GRUB2 nas configurações mais simples. Para uma informação mais abrangente, veja GRUB2. Para migração do GRUB Legacy para o GRUB2, veja GRUB2 Migration.
Instalando o software do GRUB2
O pacote sys-boot/grub está em slot o que significa que ambos grub-0.97 e grub-2.xx podem ser instalados ao mesmo tempo. No entanto, enquanto que ambas as versões do GRUB possam ser instaladas simultaneamente, apenas uma versão do GRUB pode ser ativada de cada vez como inicializador do sistema.
Para instalar o GRUB2, primeiro defina a variável GRUB_PLATFORMS com um ou mais valores apropriados no make.conf do sistema. Se não estiver definida, o GRUB2 vai adivinhar qual plataforma usar no sistema. Ele supõem pc
(que é o estilo MBR de instalação) para a arquitetura x86/amd64.
/etc/portage/make.conf
GRUB_PLATFORMS exemplo# Padrão PC (BIOS) GRUB_PLATFORMS="pc" # UEFI em amd64 GRUB_PLATFORMS="efi-64" # Ambos UEFI e PC GRUB_PLATFORMS="efi-64 pc"
Após definir a variável, instale o software:
root #
emerge --ask sys-boot/grub:2
Ativando o gerenciador de boot do GRUB2
Monte a partição /boot se for o caso:
root #
mount /boot
Ao usar uma plataforma EFI, certifique-se de que EFI System Partition está disponível (montada) em /boot/efi. Isto pode ser através de um determinado ponto de montagem (em /boot/efi) ou por ter uma partição inteira formatada com o sistema de arquivos FAT. Isto irá efetivamente processar /boot em uma grande partição de sistemas EFI.
Presumindo que apenas a partição /boot/efi é FAT:
root #
mount /boot/efi
Run the grub-install utility to copy the relevant files to /boot/grub. On the PC platform, this also installs a boot image to the Master Boot Record (MBR) or a partition's boot sector.
Para instalar o GRUB2 no MBR:
root #
grub-install /dev/sda
Installation finished. No error reported.
Para instalar o GRUB2 em um sistema capaz de suportar EFI:
root #
grub-install --target=x86_64-efi
Installation finished. No error reported.
Quando instalar o GRUB2 em um sistema capaz de suportar EFI (como no exemplo acima) apresentar problemas, certifique-se de que a variável GRUB_PLATFORMS esteja devidamente definida no /etc/portage/make.conf
The grub-install command accepts a --target
option to specify which CPU/Platform to install. If unspecified, grub-install will make a guess: on x86/amd64 it will use the i386-pc
value by default.
Configuração automática
GRUB2 is traditionally configured by using the grub-mkconfig program to generate a configuration file.
grub-mkconfig generates the configuration file based on template sections located in /etc/grub.d. The default templates should cover most common boot setups.
user $
ls /etc/grub.d
00_header 10_linux 20_linux_xen 30_os-prober 40_custom 41_custom README
O comportamento destes modelos pode ser controlado definindo variáveis no /etc/default/grub. Veja o manual do GRUB para maiores informações.
Esquema de nomeação do Kernel
In order for grub-mkconfig to detect the available Linux kernel(s), their names must start with vmlinuz- or kernel-.
Por exemplo:
/boot/vmlinuz-3.4.3 /boot/kernel-2.6.39-gentoo /boot/kernel-genkernel-x86_64-3.17.1-gentoo-r1
Ao usar um initramfs, seu nome deve começar com initramfs- ou initrd- e terminar com .img. A versão deve corresponder a uma das imagens do kernel. Nomes de arquivos gerados pelo genkernel também irão funcionar.
Por exemplo:
/boot/initrd.img-3.4.3 /boot/initrd-3.4.3.img /boot/initrd-3.4.3.gz /boot/initrd-3.4.3 /boot/initramfs-3.4.3.img /boot/initramfs-genkernel-3.4.3-gentoo /boot/initramfs-genkernel-x86_64-2.6.39-gentoo
To generate the grub.cfg file, execute the grub-mkconfig command like so:
root #
grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.2.9 done
Descompressão silenciosa do kernel
Para silenciar a descompressão do kernel em tempo de boot, edite o /etc/default/grub e adicione quiet
à variável GRUB_CMDLINE_LINUX_DEFAULT.
/etc/default/grub
Exemplo de descompressão silenciosaGRUB_CMDLINE_LINUX_DEFAULT="quiet"
Systemd
Para inicializar o systemd ao usar o GRUB2 faça com que a variável GRUB_CMDLINE_LINUX se pareça com isto:
/etc/default/grub
Systemd exemploGRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"
Carregando outro sistema operacional
grub-mkconfig can also generate configurations to load other operating systems. This requires the sys-boot/os-prober package.
To boot Windows, the sys-fs/ntfs3g also needs to be installed. It allows for the grub-mkconfig utility to probe NTFS filesystems.
Configuração manual
Users do not need to use grub-mkconfig. The grub.cfg file can be edited manually as well.
Como muitos usuários tem experiência com o formato do GRUB Legacy, o exemplo a seguir mostra como escrever um arquivo de configuração do GRUB2 com base em informações de configuração do GRUB Legacy.
grub.conf (GRUB Legacy) | grub.cfg (GRUB 2) | |
---|---|---|
timeout 5
|
⇨ | timeout=5 |
GRUB Legacy numbers partitions starting with 0; GRUB2 numbers partitions starting with 1. Both bootloaders number drives starting with 0.
Veja também
- GRUB2 - o artigo 'cheio' do GRUB2 contém maiores informações e uma extensa lista de recursos.