Debian как настроить grub

  • ru
  • Grub

GRUB — универсальный, довольно новый загрузчик который может быть использован для загрузки самой операционной системы

Debian содержит GRUB v1 (Legacy) и v2 (GRUB 2).

  • Grub v1 загрузчик по умолчанию на платформах x86 до Debian Lenny.
  • Grub v2 загрузчик по умолчанию в Debian Squeeze.

Установка

Lenny

Grub v1 для Debian может быть установлен командой:

Для установки grub v2, вам нужно установить оптимально подходящий вариант grub v2, который зависит от программы микрокода вашей системы (обычно grub-pc, смотрите также варианты grub2).

Squeeze

Grub v2 для Debian может быть установлен командой:

Если ваша система не является обычным ПК (например, если ваша система EFI или OpenFirmware, а не BIOS), вы можете установить другую версию GRUB (см. см. варианты GRUB 2).

Настройка

Конфигурационный файл — /boot/grub/menu.lst

В Debian, файл конфигурации GRUB обновляется автоматически при установке нового ядра с помощью update-grub.

Вы можете изменить настройки в /boot/grub/menu.lst. Удостоверьтесь, что Вы читаете комментарии , /usr/share/doc/grub/README.Debian.gz for more information and the update-grub(8) manpage from your distribution)

Конфигурационный файл — /boot/grub/grub.cfg, но вы не должны его редактировать напрямую. Grub v2 генерирует автоматически этот файл update-grub(8), основываясь на:

Сниппетах скриптов в /etc/grub.d/

Конфигурационном файле /etc/default/grub

Для конфигурации grub «v2», вы должны редактировать /etc/default/grub, затем запустить update-grub. Продвинутая конфигурация достигается измением сниппетов в /etc/grub.d/.

Обновление с v1 до v2

Для обновления до grub v2, вы должны:

    Установить grub v2 (но не удаляя, прежде, grub 1).

Следовать инструкциям, отображаемым пакетом установки (т.н. grub v1 имеет запись для расположения каскадом с grub v2, таким образом перезагрузитесь и попробуйте эту возможность , затем вы можете действительно включить загрузчик grub2 запуском upgrade-from-grub-legacy).

Переход от V1 до v2

Двойная загрузка

Q : Will GRUB allow me to hibernate Linux and activate another ?operating_systems (such as Windows XP) that I hibernated earlier, i.e. a ?DualHibernate rather than a DualBoot?

A : Nothing will prevent you to hibernating (GRUB isn’t aware that your host is suspended). Howerever, make sure you don’t mount the same partition (RW) under any two suspended OS !

Q : Is there a way to install GRUB in the MasterBootRecord from DOS or Windows XP, i.e. a utility similar to rawrite.exe or fdisk.exe that write a GRUB MBR? What I want here is to install Linux without having a bootable floppy.

A : There is/was a win32 Version of GRUB, i used it to install linux from Windows 2000 , but i am not sure what exactly the source is (google for grubwin32) Just unzip grubwin32 to c:\ then run c:\boot\grub\w32grub This would patch the necessary files(under XP, not linux). Then add : to c:\boot.ini And you now have a grub boot loader on your XP system.

Источник

Настройка GRUB2 в Debian

Решил я настроить свой GRUB 2, потому что не все его параметры меня устраивают. Ну, например, уменьшить таймаут, увеличить разрешение, в конце концов, поменять фоновую картинку. К чему в итоге пришёл, написано ниже.

Настройка разрешения

Первое, что нужно сделать — зайти в консоль самого GRUB’а при запуске. Для этого нужно нажать клавишу c , и, если пароль на загрузчик не установлен, сразу же осуществляется переход к командной строке. Тут вводим одну команду из двух (результат на моём Debian 9 одинаковый):

Читайте также:  Не работает низ батареи

Обе команды дают один и тот же результат — список доступных GRUB’у режимов видеоадаптера. Однако, всё не так просто. Дело в том, что при запуске загрузчика загружается видеодрайвер, НО ЭТО НЕ ТОТ ВИДЕОДРАЙВЕР, который даёт полный доступ ко всем режимам видеоадаптера. Таким образом, у меня, например, максимально доступное разрешение не соответствует параметрам монитора, т. е. тут не всё так просто.

В общем, параметры монитора я выяснил, теперь надо было подкрутить /etc/default/grub . Настраивать нужно именно этот файл, поскольку при вызове скрипта update-grub настройки будут взяты оттуда. Ниже привожу только те настройки, которые менял.

Краткое описание параметров:

GRUB_DEFAULT Пункт меню по умолчанию
GRUB_TIMEOUT Время в секундах до загрузки пункта по умолчанию
GRUB_GFXMODE Графический режим загрузчика. Можно указать так же значение auto .
GRUB_GFXPAYLOAD_LINUX Разрешение графического режима, которое загрузчик передаст ядру. Если указать правильное значение, можно запускать ОС сразу с нужным разрешением экрана.
GRUB_BACKGROUND Путь к фону загрузчика. Допускается использовать файлы в форматах jpg, png и tga. При необходимости изображение будет отмасштабировано под GRUB_GFXMODE. Если картинки не будет в указанном месте, загрузчик будет запущен в текстовом режиме, без какой-либо графики.
GRUB_DISABLE_OS_PROBER Запретить запуск утилиты osprober , собирающей информацию о других установленных ОС. Поскольку у меня Linux единственная ОС на этом компьютере, могу себе позволить сэкономить немного времени.

После настройки всех параметров обязательно нужно вызвать команду update-grub . Для тех систем, где используется GRUB2, данная команда является символической ссылкой на update-grub2 .

Источник

Installing GRUB Package

Up to Debian Lenny

GRUB v1 for Debian (package grub) can be installed with:

To install GRUB v2, you need install the appropriate variant of grub v2, depending on your system’s firmware (usually grub-pc, see grub2 variants).

Debian Squeeze and later

GRUB «v2» for Debian (package grub) can be installed with:

If your system isn’t a regular PC (i.e if your system has EFI or OpenFirmware rather than a BIOS), you may have to install another version of GRUB (see GRUB 2 variants).

Configuring GRUB

Configuring GRUB v1

The configuration file is /boot/grub/menu.lst

Under Debian, the GRUB configuration file is updated automatically, when you install a new kernel. This is done automatically by update-grub.

You can edit the settings in /boot/grub/menu.lst. Make sure you read the comments, /usr/share/doc/grub/README.Debian.gz for more information and the update-grub(8) manpage from your distribution.

Configuring GRUB v2

The configuration file is /boot/grub/grub.cfg, but you shouldn’t edit it directly. This file is generated by grub v2’s update-grub(8), based on:

The script snippets in /etc/grub.d/

The configuration file /etc/default/grub

To configure grub «v2», you should edit /etc/default/grub, then run update-grub. Advanced configuration are achieved by modifying the snippets in /etc/grub.d/.

Also check the GRUB2 page for more detailed configuration instructions, ideas and suggestions.

Upgrading from v1 to v2

To upgrade to GRUB v2, you should:

    Install GRUB v2 (but don’t remove the grub 1 yet).

Follow the instruction displayed the package installation (i.e GRUB v1 now has an entry to cascade to GRUB v2, so reboot and try it , then you can actually enable grub2 bootloader by running upgrade-from-grub-legacy).

Transition from v1 to v2

Installing GRUB on disk

If you are ok with your GRUB configuration, you can install GRUB on the MBR of your disk using grub-install.

Dual Boot FreeBSD with GPT partition

  1. Edit /etc/grub.d/40_custom, adding the following (replace X with your FreeBSD partition):
  2. Update GRUB.

Dual Boot

Nothing will prevent you to hibernating (GRUB isn’t aware that your host is suspended). However, make sure you don’t mount the same partition (RW) under any two suspended OS ! Is there a way to install GRUB in the MasterBootRecord from DOS or Windows XP, i.e. a utility similar to rawrite.exe or fdisk.exe that write a GRUB MBR? What I want here is to install Linux without having a bootable floppy

Читайте также:  Не работает клавиатура rii

There is/was a win32 Version of GRUB, i used it to install linux from Windows 2000 , but i am not sure what exactly the source is (google for grubwin32) Just unzip grubwin32 to c:\ then run c:\boot\grub\w32grub This would patch the necessary files(under XP, not linux). Then add :

And you now have a GRUB boot loader on your XP system. When I upgraded from GRUB to GRUB2 I lost an entry to XP/WP7 , how can I recover the menu entry to boot there? You have to install os-prober, make sure its enabled in GRUB2 configuration and sync GRUB2.

Then edit /etc/default/grub and make sure you have a line like

Finally run update-grub2 By default GRUB2 in debian will not add ‘resume=/dev/swap-partition’ option. But if you want to perform this by default you can edit /etc/grub.d/10_linux file and make some changes there:

This will add your first swap partition to all found linux entries.

Источник

  • Grub2

Configure console menu colors

As of DebianWheezy, there is no support for easily modifying the colors of the console menu. /etc/default/grub does not have any variables that can set the colors for this video mode.

The easiest way to modify the console menu colors is to create a new file /boot/grub/custom.cfg and put your configurations there:

The variables that control the console menu colors are the following:

color_normal — the “normal” foreground and background terminal colors

color_highlight — the “highlight” foreground and background terminal colors

menu_color_normal — the foreground and background colors to be used for non-highlighted menu entries

menu_color_highlight — the foreground and background colors to be used for the highlighted menu entry

If you configured /boot/grub/custom.cfg, there is no need to run update-grub; the file will be automatically loaded by /boot/grub/grub.conf at boot.

Configure graphical splashimage

As of Bullseye, splash image is set in the following order:

If the GRUB_BACKGROUND variable in /etc/default/grub is set, this is used upon executing update-grub.

If /boot/grub/ has *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.tga *.TGA, this is used upon executing update-grub.

background image and colors specified by desktop-base (select one via update-alternative), this is used upon executing update-grub

So putting your favorite image file to /boot/grub/` is the easiest way.

If you are to use grub2-splashimages, do as follows.

install the grub2-splashimages package: aptitude install grub2-splashimages
choose one of the nice images to use as the splashimage. You can look at the images with any image viewer (Ex: display)

configure/add the GRUB_BACKGROUND variable in /etc/default/grub. Ex: GRUB_BACKGROUND=»/usr/share/images/grub/Lake_mapourika_NZ.tga»

make sure that GRUB_TERMINAL=console is commented out. The graphical mode will not be enabled if this is uncommented. By default it’s commented, so you shouldn’t worry too much.

the graphical resolution can be changed via the variable GRUB_GFXMODE

run update-grub

  • reboot to observe the change
  • Configure encrypted /boot

    beta2-29 supports reading an encrypted /boot partition.

    Assuming you already have an encrypted system as setup by debian installer:

    add GRUB_ENABLE_CRYPTODISK=y to /etc/default/grub

    backup the contents of your /boot partition somewhere

    create an LUKS container where your /boot partition was and unlock it

    create an ext2 filesystem your LUKS container and mount it to /boot

    restore the backup of your /boot partition to your new encrypted /boot

    Configuring / choosing non-default or older kernel to boot

    Set GRUB_DEFAULT in /etc/default/grub to other value than 0. A good description is in the official grub docs with samples GRUB # Simple-configuration. If SUBMENU is not disabled, use ‘>’ character as an input key, for example, if you want to choose second menu/entry (first screen) and the 3rd kernel/entry in the submenu (second screen), then GRUB_DEFAULT=1>2. Remember that entries in grub2 start with 0/zero counter.

    Читайте также:  Кнопки панели инструментов не работает

    If you’ve changed grub configuration file /etc/default/grub, make sure to run update-grub to update its configuration.

    UEFI vs BIOS boot

    GRUB supports booting x86 systems via either the traditional BIOS method (aka «Legacy» or «CSM»), or more modern UEFI. How they start up is quite different, but in most cases the end result should be all-but-invisible to the user. Here’s a comparison of how each works.

    BIOS world

    The first sector is important — that’s how PCs boot. The firmware is very dumb — it just loads the first sector and executes code from it directly. See https://en.wikipedia.org/wiki/Master_boot_record for more information about the exact layout.

    There’s not very much space in the first sector, just enough for the partition table and a very small bootable stub. That stub knows just enough to be able to locate and load the second-stage loader (aka GRUB core).

    The second stage loader fits in the gap between the first sector and the first partition. On most modern systems, the first partition will start at 1 !MiB into the disk so there’s just under 1 !MiB of space for the GRUB core. That’s a lot more space than just the boot sector, but it’s still quite limited. It has the main bits of GRUB code built-in: typically key things like code to read different storage systems, partitioning layouts and filesystems. It also has a module loader.

    Older systems that have a smaller partition gap here are becoming more and more difficult to support in GRUB — space is getting tighter and tighter as the core code grows and more features are added.

    The core will locate the /boot/grub directory as instructed by its config, then potentially load all sorts of extra GRUB functionalitly from modules contained there.

    Eventually, GRUB will load a kernel and initramfs and start the kernel.

    UEFI world

    In UEFI, the firmware is much more intelligent. Instead of just loading a raw sector from disk and executing code from it directly, the firmware includes (limited) support for storage and filesystems. This allows for many more useful options at boot time.

    By setting UEFI Boot Variables, the firmware can be configured with a list of different UEFI programs to try to load and boot. If it can’t find anything in the configured boot locations, the firmware will fall back to a hard-coded location: the so-called Removable Media Path.

    For extra security, the firmware can also be configured to only allow running EFI programs that are signed with keys the firmware knows about (aka SecureBoot).

    For GRUB, UEFI removes many of the older BIOS limitations. There is no need for the stub loader. Instead, the firmware loads and runs GRUB as a standard UEFI program (typically «grubx64.efi» on a 64-bit PC platform)..

    The default way to configure GRUB for UEFI is to install the GRUB core here. Just as for the BIOS boot case, it can then find /boot/grub and load modules for extra functionality.

    In the SecureBoot case, however, the GRUB EFI binary is different. As GRUB does not (yet!) include support for signed modules, it cannot verify any modules that might be loaded later. So, in this case the module loader is disabled. All of the modules that might be needed are instead built in to a larger monolithic binary that can be signed. At runtime, this single binary is all that will run.

    Источник

    Оцените статью