GRUB2 (Русский)
From ArchWiki
Article summary |
---|
Covers various aspects of the next generation of the GRand Unified Bootloader (GRUB2). |
Available in languages |
English |
Česky |
Français |
Italiano |
Русский |
Contents |
Предисловие
Комманды – разница между GRUB и GRUB2. Вероятно вам будет интересно познакомиться с ними поближе, прежде чем начать. К примеру, "find" был заменен на "search"
http://grub.enbug.org/CommandList
Установка пакета Grub2
Для начала установим grub2 с помощью pacman'а:
# pacman -Sy grub2
Внесем изменения в файл конфигурации согласно нашим настройкам. Прежнее menu.lst заменило на grub.cfg:
# nano /boot/grub/grub.cfg
Ниже пример простого файла конфигурации:
# 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 #}
Если вы не выделяли отдельного раздела на диске под /boot, добавьте его в grub.cfg. Например:
# (0) Arch Linux menuentry "Arch Linux" { set root=(hd0,1) linux /boot/vmlinuz26 root=/dev/sda1 ro initrd /boot/kernel26.img }
Установка или восстановление GRUB в Master Boot Record
GRUB может быть установлен из уже установленного дистрибутива, или непосредственно в течении установки Arch-а.
В большинстве случаев, установка grub2 столь же легка как выполнение команды grub-install с правами root:
# grub-install /dev/sda
где /dev/sda назначение установки (в этом случае установка производится в MBR первого SATA диска)
Если команда завершится с ошибкой:
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.
Try adding --recheck to the arguments as follows:
# grub-install --recheck /dev/sda
Alternatively, you should be able to install grub2 by booting the system and running the grub command as root:
# grub {this section is still incomplete, some steps should be added!!!}
(grub2 doesn't have an interactive prompt)
Настройка загрузчика
Все настройки GRUB содержаться в файле:
/boot/grub/grub.cfg
Далее приведены некоторые опции.
- (hdn,m) - это раздел m на диске n, нумерация разделов начинается с 1,а дисков с 0
- set default=n - пункт меню загружаемый по умолчанию, т.е. будет загружен этот пункт по истечении таймера
- set timeout=m – - время m в секундах,до начала загрузки пункта меню по умолчанию
- menuentry "str"{опции загрузки ОС} – текстовая строка str используется для оглавления пункта меню & basic layout
- set root=(hdn,m) – партиция, на которой находится ядро
- linux /path ro root=/dev/device initrd /initrd.img – используйте опцию root, если ядро находится не в корневом разделе (/)
- chainloader +1 активирует опциюroot и передает управление другому загрузчику (например загрузчику Windows)
Для того,чтобы просмотреть UUID разделов:
# blkid
Мультизагрузка
These are the two most common ways of configuring the grub.cfg file. For more complex uses, feel free to add descriptions here.
Загрузка GNU/Linux дистрибутива
Такие опции используются для загрузки Arch linux. Здесь подразумевается,что дистрибутив установлен на [s/h]da2.
menuentry "Other Linux" { set root=(hd0,2) linux /boot/vmlinuz26 (используйте свои опции,если это необходимо) initrd /boot/initrd26.img }
Загрузка Windows
Добавьте это в конец файла /boot/grub/grub.cfg. В этих настройках предусмотрено,что раздел Windows - [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).
Загрузка Windows Vista, использующая EasyBCD и NeoGRUB
EasyBCD NeoGRUB не понимает опции меню GRUB v2 , 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
Советы и хитрости
Фоновое изображение & растровый шрифт
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
Цветное меню
Для того, чтобы именить цвета меню GRUB2, необходимо добавить опцию в файл /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.
Скрытое меню
Для того чтобы скрыть меню,необходимо добавить следущие опции в файл /boot/grub/grub.cfg после объявления фонового рисунка (т.е. background_image /boot/grub/archlinux.tga) и до первого пункта меню (menuentry).
set timeout=5
echo -n "Press ESC to see the menu... " if sleep --verbose --interruptible 5 ; then set timeout=0 fi
Диагностика
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:
E.g. (as root:)
# mount /boot # cp -a /boot/grub / # umount /boot # mv /grub /boot/ # grub-install /dev/sda