1

I've installed a Linux distribution on a friend's PC. He does not know how to use Linux or even Windows very well, and I'd like for it to be as easy as possible. When I installed GRUB, it detected his recovery partition that HP installed for him, and its the first Windows in the list.

After some googling and looking through the grub manual and config files, I still can't figure out how to hide a partition from GRUB. I looked at 30_osprober, but didn't see any clear way to exclude an OS.

Can anyone point me in the right direction for excluding an OS/partition from the GRUB menu?

1

//EDIT// Changed due to edits(I swear this changed while I was typing)

A dirty solution is to edit the grub.cfg, but this would need to happen every time a kernel upgrade happened.

In grub v2: (NOTE THIS IS NOT RECOMMENDED)

vim /boot/grub/grub.cfg

The correct way to accomplish this is to edit /etc/grub.d/30_os-prober(as you mentioned) and tell it to ignore certain partitions, a good guide can be found here

Dirty solution #2 could be to run a script that comments out that line from the the grub.cfg for your buddy.

5

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 ${DEVICE} should be the exact contents between the quotes in the menuentry for the recovery partition:

    for OS in ${OSPROBED} ; do
    DEVICE="`echo ${OS} | cut -d ':' -f 1`"
    LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
    LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
    BOOT="`echo ${OS} | cut -d ':' -f 4`"
    
    if [ -z "${LONGNAME}" ] ; then
     LONGNAME="${LABEL}"
    fi
    
    # Added to remove Windows Recovery
    if [ "$LONGNAME" = "Windows Vista (loader)" ] && [ "${DEVICE}" = "/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.

2

In the file /etc/default/grub you can add

GRUB_OS_PROBER_SKIP_LIST with a list of space separated UUIDs@path_to_device

for example GRUB_OS_PROBER_SKIP_LIST=12345@/dev/sda1

to have OS_PROBER skip those file systems.

You can get a list of the UUIDs from lsblk -fs

Here's more about GRUB_OS_PROBER_SKIP_LIST.

  • This solution worked, with one thing to note; When adding multiple partitions to ignore they have to be in quotes. ie this did not work GRUB_OS_PROBER_SKIP_LIST=27a3180c-4b1f-49ac-b0cf-17f48cfcad28@/dev/sdh1 157bea0c-5143-4c17-9636-5f92e4bc3ead@/dev/sdh2 but this worked as intended GRUB_OS_PROBER_SKIP_LIST="27a3180c-4b1f-49ac-b0cf-17f48cfcad28@/dev/sdh1 157bea0c-5143-4c17-9636-5f92e4bc3ead@/dev/sdh2" – Sujimichi Jun 23 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.