Как скрыть раздел восстановления из Grub2

5730
Nostradamnit

Я установил дистрибутив Linux на компьютер друга. Он не знает, как очень хорошо использовать Linux или даже Windows, и я бы хотел, чтобы это было как можно проще. Когда я установил GRUB, он обнаружил раздел восстановления, который HP установил для него, и его первую Windows в списке.

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

Кто-нибудь может указать мне правильное направление для исключения ОС / раздела из меню GRUB?

0

3 ответа на вопрос

5
Fabrizio C

I followed the guidelines from this post (on the 6 section)

GRUB 2 will find and create a menuentry for the Windows (Vista) Recovery partition. At least in Vista, the menu name is the same as the normal Vista operating partition, the only difference being the parttion designation. To remove the Recovery partition entry from the menu:

  • Backup the existing /etc/grub.d/30_os-prober file, remove the executable bit from the backup so it isn't run during updates, and open the original for editing (the section starts around line 134):

    sudo cp /etc/grub.d/30_os-prober /etc/grub.d/30_os-prober.original && sudo chmod -x 

    /etc/grub.d/30_os-prober.original

    gksu gedit +83 /etc/grub.d/30_os-prober & 
  • Determine the exact title and the Windows recovery partition. These can be located in the /boot/grub/grub.cfg file. Add the entry below. In the example, the menuentry appeared as "Windows Vista (loader) (on /dev/sda1)". Make sure you select the correct partition as the title may be the same for the normal and recovery titles. The contents for $LONGNAME and $ should be the exact contents between the quotes in the menuentry for the recovery partition:

    for OS in $ ; do DEVICE="`echo $ | cut -d ':' -f 1`" LONGNAME="`echo $ | cut -d ':' -f 2 | tr '^' ' '`" LABEL="`echo $ | cut -d ':' -f 3 | tr '^' ' '`" BOOT="`echo $ | cut -d ':' -f 4`" if [ -z "$" ] ; then LONGNAME="$" fi # Added to remove Windows Recovery if [ "$LONGNAME" = "Windows Vista (loader)" ] && [ "$" = "/dev/sda1" ] ; then continue fi # End Added 

Save the file, then run:

sudo update-grub 

Instead of Vista I had to think Windows 7 (the method is the same) and everything worked.

1
Dan M.

// РЕДАКТИРОВАТЬ // Изменено из-за правок (клянусь, это изменилось во время набора текста)

Грязное решение - отредактировать grub.cfg, но это должно происходить каждый раз, когда происходит обновление ядра.

В grub v2: (ПРИМЕЧАНИЕ ЭТО НЕ РЕКОМЕНДУЕТСЯ)

vim /boot/grub/grub.cfg 

Правильный способ сделать это - отредактировать /etc/grub.d/30_os-prober(, как вы упомянули) и сказать ему игнорировать определенные разделы, хорошее руководство можно найти здесь.

Грязное решение №2 может заключаться в запуске сценария, который закомментирует эту строку из grub.cfg для вашего собеседника.

0
user948930

В файл / etc / default / grub вы можете добавить

GRUB_OS_PROBER_SKIP_LIST со списком разделенных пробелами UUID @ path_to_device

например GRUB_OS_PROBER_SKIP_LIST = 12345 @ / dev / sda1

чтобы OS_PROBER пропускал эти файловые системы.

Вы можете получить список UUID из lsblk -fs

Подробнее о GRUB_OS_PROBER_SKIP_LIST .

Похожие вопросы