GRUB2 (Español)

From ArchWiki

Jump to: navigation, search
Article summary
Cubre varios aspectos de la próxima generación del GRand Unified Bootloader (GRUB2).
Idiomas disponibles
English
Česky
Español
Français
Italiano
Русский

Contents

Introducción

Warning: La próxima generación del GRand Unified Bootloader (GRUB2) está todavía bajo desarrollo y por lo tanto pueden pasar todas las cosas comunes en este tipo de casos: GRUB2 puede freír tu computadora, quemar tu casa, hacerte el desayuno o matar a tu gato. ¡Haz sido avisado! Para la mayoría de personas, excepto aquellos con configuraciones exóticas, GRUB2 debería funcionar sin problemas.

Han habido alguno cambios en los comandos entre GRUB y GRUB2. Sería mejor que te familiarices con estos antes de proceder. Por ejemplo "find" ha sido reemplazado por "search"

http://grub.enbug.org/CommandList

Instalar el paquete Grub2

Primero instale grub2 con pacman:

# pacman -Sy grub2

Edite el archivo de configuración de grub2. El 'viejo' menu.lst es reemplazado por un nuevo archivo llamado grub.cfg:

# nano /boot/grub/grub.cfg
Note: Use hd[a-z] para IDE y sd[a-z] para SCSI y SATA.

Aqui hay un ejemplo de un archivo configuración:

# Config file for GRUB2 - The GNU GRand Unified Bootloader
# /boot/grub/grub.cfg

# DEVICE NAME CONVERSIONS
#
#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/sda        (hd0)
#  /dev/sdb2       (hd1,2)
#  /dev/sda3       (hd0,3)
#

# Timeout for menu
set timeout=5

# Set default boot entry as Entry 0
set default=0

# (0) Arch Linux
menuentry "Arch Linux" {
set root=(hd0,1)
linux /vmlinuz26 root=/dev/sda1 ro
initrd /kernel26.img
}

## (1) Windows
#menuentry "Windows" {
#set root=(hd0,3)
#chainloader +1
#}

Si usted no tiene una partición de inicio separada, /boot debe ser añadido a grub.cfg. Ejemplo:

# (0) Arch Linux
menuentry "Arch Linux" {
set root=(hd0,1)
linux /boot/vmlinuz26 root=/dev/sda1 ro
initrd /boot/kernel26.img
}

Si usa LVM para su directorio /boot añada lo siguiente antes de menuentries:

insmod lvm

y especifique su root en menuentries como:

set root=(su_nombre_del_grupo_lvm-su_nombre_partición_lógica_de_inicio_lvm)

Instalar o Restaurar GRUB en el Master Boot Record

GRUB puede ser instalado desde una sesión en vivo o directamente desde una instalación de Arch.

En la mayoría de los casos, instalar grub2 será tan fácil como correr el comando "grub-install" como root:

# grub-install /dev/sda

donde /dev/sda es el destino de la instalación (en este caso el MBR del primer disco SATA)

Si esto falla mostrando el error:

grub-probe: error: Cannot get the real path of `/dev/fd0'
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.

Intente añadiendo --recheck a los argumentos, asi como se muestra:

# grub-install --recheck /dev/sda

Alternativamente, se podría instalar grub2 iniciando el sistema y ejecutanto el comando grub como root:

# grub
{esta sección todavía está incompleta, se deben añadir algunos pasos!!!}

(grub2 no tiene una interfaz interactiva)

Configuración del Cargador de Inicio

La configuración del GRUB es hecha en este archivo:

/boot/grub/grub.cfg

Está avisado que esta sección está incompleta, siéntase libre de añadir todas las opciones de configuración faltantes aquí!

  • (hdn,m) es la partición m en el disco n, números de las particiones empiezan con 1, los números de los discos comienzan con 0
  • set default=n is the default boot entry, that is choosen after timeout for user action
  • set timeout=m – time m to wait in seconds for a user selection, before default is booted
  • menuentry "str"{entry options} – title string str for a boot entry & basic layout
  • set root=(hdn,m) – base partition, where the kernel is stored to
  • linux /path ro root=/dev/device initrd /initrd.img – use the root option, if the kernel not placed in /
  • chainloader +1 sets root active and gives booting procedure to its boot-loader (for Windows, e.g.)

For UUID entries:

# blkid

This gives you the UUID. We were doing the following command to set the root device:

# root=/dev/device
Instead, replace it with this:
# root=/dev/disk/by-uuid/bc285871-413 .... and so on, for your UUID.

Dual booting

These are the two most common ways of configuring the grub.cfg file. For more complex uses, feel free to add descriptions here.

With other GNU/Linux distributions

This is done exactly the same way that Arch linux is loaded. Here we assume that the other distro is on partition [s/h]da2.

menuentry "Other Linux" {
set root=(hd0,2)
linux /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)
}

With Windows

Add this at the end of your /boot/grub/grub.cfg. This assumes that your Windows partition is [s/h]da3.

# (2) Windows XP
menuentry "Windows XP" {
set root=(hd0,3)
chainloader +1
}

Note, that although commonly believed to be the case, Windows 2000 and later versions do not need to be on the first partition to boot. If the Windows partition changes number (i.e. if you after install add a partition before the windows partition), you will need to edit the Windows boot.ini file to reflect the change (see this article for details on how to do that).

With Windows Vista, via EasyBCD and NeoGRUB

Since EasyBCD's NeoGRUB currently can't understand the GRUB v2 menu format, chain-load to it by replacing the contents of your "C:\NST\menu.lst" file with lines similar to the following:

default 0
timeout 1
title       Chainload into GRUB v2
root        (hd0,7)
kernel      /boot/grub/core.img

Tips and tricks

Background Image & Bitmap Fonts

GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename unicode.pf2, or, as only ascii characters under the name ascii.pf2. Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. A configuration sample setting a tga file as background is shown below.

if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode="1024x768x32"
  insmod gfxterm
  insmod vbe
  terminal_output gfxterm
  if terminal_output gfxterm; then true ; else
     terminal gfxterm
  fi
fi
insmod tga
background_image /boot/grub/archlinux.tga

Menu Colors

To change the colors in GRUB2 you would specify one option in /boot/grub/grub.cfg:

color light-blue/black light-cyan/blue

These are the default colors for Arch's release of GRUB-legacy. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/color.html.

Hidden menu

For hiding menu put that code in grub.cfg after picture initialization but before menuentries (e.g. background_image /boot/grub/archlinux.tga).

  set timeout=5
  echo -n "Press ESC to see the menu... "
if sleep --verbose --interruptible 5 ; then
  set timeout=0
fi

Troubleshooting

Any troubleshooting should be added here.

I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename menu.lst.pacsave or whatever, to menu.lst (in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type "chainloader +1". This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the menu.lst's timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.

P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it :) .

In my case it had to do with my boot partition. Say boot-partition is (hd0,1) and your root is (hd0,3) (grub2 naming). grub-setup searches for (hd0,3)/boot/grub/core.img. Just because it's on (hd0,1)/grub/core.img, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:

Ejemplo (como root:)

# mount /boot
# cp -a /boot/grub /
# umount /boot
# mv /grub /boot/
# grub-install /dev/sda

Otras fuentes

Personal tools