Обновить загрузчик grub linux

How to Update Grub on Ubuntu and Other Linux Distributions

This tutorial teaches you to update grub on Ubuntu or any other Linux distribution. You’ll also learn a thing or two about how this grub update process works.

How to update grub

Ubuntu and many other Linux distributions provide a handy command line utility called update-grub. To update grub, all you have to do is to run this command in the terminal with sudo.

[email protected]:~$ sudo update-grub [sudo] password for abhishek: Sourcing file `/etc/default/grub' Generating grub configuration file . Found linux image: /boot/vmlinuz-5.0.0-37-generic Found initrd image: /boot/initrd.img-5.0.0-37-generic Found linux image: /boot/vmlinuz-5.0.0-36-generic Found initrd image: /boot/initrd.img-5.0.0-36-generic Found linux image: /boot/vmlinuz-5.0.0-31-generic Found initrd image: /boot/initrd.img-5.0.0-31-generic Found Ubuntu 19.10 (19.10) on /dev/sda4 Found MX 19 patito feo (19) on /dev/sdb1 Adding boot menu entry for EFI firmware configuration done

You may see a similar command called update-grub2. No need to be alarmed or confused between update-grub and update-grub2. Both of these commands do the same action. Around ten years ago, when grub2 was just introduced, update-grub2 command was also introduced. Today, update-grub2 is just a symbolic link to update-grub and both update grub2 configuration (because grub2 is the default).

Can’t find update-grub command? Here’s what to do in that case

It’s possible that your Linux distribution might not have update-grub command available. What do you do in that case? How do you update grub on such a Linux distribution? There is no need to panic. The update-grub command is simply a stub for running ‘grub-mkconfig -o /boot/grub/grub.cfg’ to generate grub2 config file. Which means that you can update grub with the following command on any Linux distribution:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Of course, remembering update-grub command is a lot easier than the above command and this is the reason why it was created in the first place.

How does update-grub work?

Grub Screen

When you install a Linux distribution, it (usually) asks you to install the grub boot loader. Part of grub is installed on the MBR/ESP partition. Rest of the grub lies in /boot/grub directory of the Linux distributions. As per its man page, update-grub works by looking into the /boot directory. All the files starting with vmlinuz- will be treated as kernels and they will get a grub menu entry. It will also add initrd lines for ramdisk images found with the same version as kernels found. It also looks into all disk partitions for other operating systems with os-prober. If it finds other operating systems, it adds them to the grub menu.

Читайте также:  Поиск больших директорий linux

Why would you need to update grub?

Update Grub

There could be a number of scenarios when you need to update grub. Suppose you changed the grub config file (/etc/default/grub) to change the default boot order or reduce the default boot time. Your changes won’t take into effect unless you update the grub. Another scenario is when you have multiple Linux distributions installed on the same system. For example, on my Intel NUC, I have two disks. The first disk had Ubuntu 19.10 and then I installed Ubuntu 18.04 on it. The second OS (Ubuntu 18.04) also installed its own grub and now the grub screen is controlled by Ubuntu 18.04 grub. On the second disk, I installed MX Linux but I didn’t install grub this time. I want the existing grub (controlled by Ubuntu 18.04) to handle all the OS entries. Now, in this scenario, the grub on Ubuntu 18.04 needs to be updated so that it can see MX Linux. As you can see in the image above, when I update the grub, it finds various Linux kernels installed on 18.04 along with Ubuntu 19.10 and MX Linux on different partitions. If I want MX Linux to control the grub, I can install grub on MX Linux with grub-install command and then the grub on MX Linux will start controlling the grub screen. You get the gist, right? Using a GUI tool like Grub Customizer is a simpler way to make changes in grub. In the end… Initially, I had intended to keep it a short article as a quick tip. But then I thought of explaining a few things associated with it so that (relatively) new Linux users could learn more than just a simple command. Did you like it? Do you have some questions or suggestions? Please feel free to leave a comment.

Источник

Как обновить загрузчик GRUB в Debian и производных дистрибутивах (Kali Linux, Ubuntu, Linux Mint)

Загрузчик операционной системы GRUB устанавливается и обновляется в Linux как и любой другой пакет программного обеспечения. Но особенностью загрузчика является то, что даже после обновления пакета, фактически работающие файлы загрузчика, которые находятся в разделе, монтируемом по пути /boot/grub/, не обновляются автоматически.

То есть при выходе новых версий GRUB, пакет в вашей ОС обновляется автоматически.

Но сам загрузчик, который устанавливается на отдельном разделе диска и монтируется по пути /boot/grub/, не обновляется.

Читайте также:  Linux редактировать файл nano

Чтобы начать использовать новые функции, которые добавлены в новые версии GRUB, вам нужно вручную обновить загрузчик.

Когда нужно обновлять загрузчик GRUB в /boot/grub/

Сигналом, что вышла новая версия GRUB, является примерно следующие сообщения:

Setting up grub-common (2.06-8+kali1) . . Setting up grub2-common (2.06-8+kali1) . . Setting up grub-pc-bin (2.06-8+kali1) …

Ещё один признак, что обновился пакет GRUB — запрос на обновление дефолтного файла конфигурации GRUB.

Чтобы использовать новые функции, представленные в этом обновлении GRUB, рекомендуется установить его в MBR или UEFI. Из-за потенциальной несовместимости конфигурации рекомендуется выполнить как установку, так и создание конфигурации.

То есть если вы видите эти сообщения, значит вам нужно обновить загрузчик в /boot/grub/.

Проверка, используется ли GRUB в операционной системе

Чтобы убедиться, что в качестве загрузчика используется именно GRUB, выполните следующую команду:

Если файл /boot/grub/grub.cfg найден, значит используется GRUB, если файл grub.cfg не найден, значит GRUB не используется и обновлять его не нужно. То есть не нужно выполнять действия, показанные в данной статье!

Как обновить загрузчик GRUB в /boot/grub/

Для обновления загрузчика нужно выполнить команду вида:

grub-install --recheck /dev/DISK

Где в качестве /dev/DISK нужно указать имя вашего диска.

Имена дисков можно проверить командой:

Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 104857566 104855519 50G 83 Linux Disk /dev/vdb: 450 KiB, 460800 bytes, 900 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

В данном случае именем диска является /dev/vda. Обратите внимание, что /dev/vda — это не загрузочный или какой-то другой раздел — это весь диск.

Итак, команда для обновления GRUB в /boot/grub/ в моём случае следующая:

grub-install --recheck /dev/vda
Installing for i386-pc platform. Installation finished. No error reported.

Также необходимо создать новый файл конфигурации следующей командой:

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file . Found linux image: /boot/vmlinuz-6.0.0-kali6-cloud-amd64 Found initrd image: /boot/initrd.img-6.0.0-kali6-cloud-amd64 Found linux image: /boot/vmlinuz-6.0.0-kali5-cloud-amd64 Found initrd image: /boot/initrd.img-6.0.0-kali5-cloud-amd64 Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. done

Обновление загрузчика GRUB и обновление конфигурации GRUB завершилось успешно. При следующей загрузке, ваша операционная система будет использовать новые функции, которые были добавлены обновлением GRUB.

Связанные статьи:

Источник

Как обновить загрузчик GRUB в Arch Linux и производных дистрибутивах (Manjaro, BlackArch)

Загрузчик операционной системы GRUB устанавливается и обновляется в Linux как и любой другой пакет программного обеспечения. Но особенностью загрузчика является то, что даже после обновления пакета, фактически работающие файлы загрузчика, которые находятся в разделе, монтируемом по пути /boot/grub/, не обновляются автоматически.

Читайте также:  Linux difference between files

То есть при выходе новых версий GRUB, пакет в вашей ОС обновляется автоматически.

Но сам загрузчик, который устанавливается на отдельном разделе диска и монтируется по пути /boot/grub/, не обновляется.

Чтобы начать использовать новые функции, которые добавлены в новые версии GRUB, вам нужно вручную обновить загрузчик.

Когда нужно обновлять загрузчик GRUB в /boot/grub/

Сигналом, что вышла новая версия GRUB, является примерно следующее сообщение:

(3/4) upgrading grub [######################] 100% :: To use the new features provided in this GRUB update, it is recommended to install it to the MBR or UEFI. Due to potential configuration incompatibilities, it is advised to run both, installation and generation of configuration: $ grub-install . $ grub-mkconfig -o /boot/grub/grub.cfg

В этом сообщении говориться, чтобы использовать новые функции, представленные в этом обновлении GRUB, рекомендуется установить его в MBR или UEFI. Из-за потенциальной несовместимости конфигурации рекомендуется выполнить как установку, так и создание конфигурации. А также даны примерные команды.

То есть если вы видите это сообщение, значит вам нужно обновить загрузчик в /boot/grub/.

Проверка, используется ли GRUB в операционной системе

В Arch Linux и производных дистрибутивах пакет GRUB может быть установлен, но при этом не используется, поскольку загрузчиком является systemd-boot.

Чтобы убедиться, что в качестве загрузчика используется именно GRUB, выполните следующую команду:

Если файл /boot/grub/grub.cfg найден, значит используется GRUB, если файл grub.cfg не найден, значит GRUB не используется и обновлять его не нужно. То есть не нужно выполнять действия, показанные в данной статье!

Как обновить загрузчик GRUB в /boot/grub/

Для обновления загрузчика нужно выполнить команду вида:

grub-install --recheck /dev/DISK

Где в качестве /dev/DISK нужно указать имя вашего диска.

Имена дисков можно проверить командой:

Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4b23ea92 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 411647 409600 200M 83 Linux /dev/vda2 411648 62914559 62502912 29.8G 83 Linux

В данном случае именем диска является /dev/vda. Обратите внимание, что /dev/vda — это не загрузочный или какой-то другой раздел — это весь диск.

Итак, команда для обновления GRUB в /boot/grub/ в моём случае следующая:

grub-install --recheck /dev/vda

Также необходимо создать новый файл конфигурации следующей командой:

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file . Found linux image: /boot/vmlinuz-linux Found initrd image: /boot/initramfs-linux.img Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings . done

Обновление загрузчика GRUB и обновление конфигурации GRUB завершилось успешно. При следующей загрузке, ваша операционная система будет использовать новые функции, которые были добавлены обновлением GRUB.

Близкие статьи

Источник

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