Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have this laptop where I have GNU/Linux, Windows and one recovery partition that I haven't removed.
When I run update-grub2, I get the instances of GNU/Linux, memtest, Windows and another for the recovery partition. Is there a way to make os-prober skip one partition?
You issue is that you want to skip the search for non-linux OSs
On a quick look -
* 10_linux searches for installed linux kernels.
* 30_os-prober searches for other Operating Systems.
So you don't want to run the prober.
However, grub2 uses different paradigms to grub and you should look through that link. eg. to remove an entry, change the permissions of the grub.d file ... I can see how you may create a bash alias which will remove the extraneous entry each time update-grub2 is run.
Is it possible that the bootable flag is set for more than one partition?
If you want to skip one (or some) partition/s (not only recovery or memtest entries), this is a simple easy trick that worked for me.
SIMPLE EASY TRICK: EDIT 3 FILES TO PREVENT SOME PARTITIONS BEING AUTODETECTED BY GRUB2
STEP 1)
Add the variable
GRUB_DONT_ AUTODETECT_PART
to the file
/etc/default/grub
This variable must contain the name of the partitions you don't want to be autodetected.
It's the list of these space-separated names.
The partitions naming is the usual one in linux.
If you are not sure, run:
update-grub
as superuser (root),
i.e. if your distribution is, for example, Ubuntu, run:
sudo update-grub
and take a note of the names (without the /dev/)
Example:
This is my /etc/default/grub:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=800x600
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"
# This variable has been added by me
# It prevents some partitions to be autodetected
GRUB_DONT_AUTODETECT_PART="hda1 hda5"
As you can see, in my case I don't want hda1 and hda5 to be autodetected.
STEP 2)
Apply a little patch to the file /usr/sbin/grub-mkconfig.
(This is the really executed program when you run update-grub)
After the second export command, add another one (more or less, in the line 229) export with this new created variable:
export GRUP_DONT_AUTODETECT_PART
# This variable is intended to prevent some partitions to be detected
export GRUB_DONT_AUTODETECT_PART
if test "x${grub_cfg}" != "x"; then
... ...
STEP 3)
And lastly, you must apply 2 little patchs to the file
/etc/grub.d/30_os-prober
Note.- In my package the name begins by 30. It's not mandatory.
This number establishes the execution order (sequence) for all the files (executable files) in the directory.
a) Fisrt patch:
# My patch to prevent some partitions being autodetected
PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
if [ "`echo ${GRUB_DONT_AUTODETECT_PART} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
BOOT="banned"
fi
# End of first part of the patch
Example:
Here you can see where it must be placed (in the line 45, more or less):
# My patch to prevent some partitions being autodetected
PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
if [ "`echo ${GRUB_DONT_AUTODETECT_PART} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
BOOT="banned"
fi
# End of first part of the patch
if [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
b) Second patch:
# My patch to prevent some partitions being autodetected: 2n part
banned)
echo " ${DEVICE} has been prevented to be autodetected." >&2
;;
# End of the 2n part of my patch
Example:
Here you can see where it must be placed (in the line 159, more or less, nearly at the end of the file):
EOF
;;
# My patch to prevent some partitions being autodetected: 2n part
banned)
echo " ${DEVICE} has been prevented to be autodetected." >&2
;;
# End of the 2n part of my patch
hurd|*)
echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2
;;
esac
done
Et voilą!
At this moment you only must run:
update-grub
as superuser (root)
This trick has been applied to the files provided by the package
grub-common 1.97~beta3-1
and checked successfuly on
Debian squeeze (testing)
Unfortunately grub2 is under development yet and this trick is only a workaround.
Well, in short, if the package gets updated, you'll have to reedit the updated files if grub2 developers won’t have included this feature yet.
Anyway, reedit the files is not difficult at all (it's only a pain) and it may be worthwhile if:
a) you have installed a distribution that is not well recognized by grub2 (i.e. Mandriva): in this case the straightforward workaround is preventing its autodetection and booting the system by means of a customized entry in the file
/etc/grub.d/40_custom
Example:
This is my /etc/grub.d/40_custom:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Mandriva Linux release 2010.0 (Official) for x86_64 (on /dev/hda5)" {
insmod ext2
set root=(hd0,5)
linux (hd0,5)/boot/vmlinuz-2.6.31.5-desktop-1mnb
initrd (hd0,5)/boot/initrd-2.6.31.5-desktop-1mnb.img
}
b) you have a partition you don't want to be accessed or booted by users (i.e. Vista recovery partition): in this case the partition only needs to be ignored.
I used this method successfully with 11.04, thanks for this. Just wondered if it was still going to work and when I discovered it did, I figured I'd put a note up (which I looked for but didn't find initially)
this is a simple easy trick that worked for me.
SIMPLE EASY TRICK: EDIT 3 FILES TO PREVENT SOME PARTITIONS BEING AUTODETECTED BY GRUB2
Thanks for this, I simplified it down to 5 lines.
So for anyone coming here from Google, as I did, all you need to do is modify your '30_os-prober' file
For me it is located at '/etc/grub.d/30_os-prober'
So open it with a text editor (I used nano)
then go to line 139, which should look like this
Code:
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`"
#### ::: Line 139 ::: ####
if [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
then modify it to add the following lines, that are highlighted red.
Code:
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`"
# Patch to prevent some partitions being autodetected
SKIP_THESE_DEVICES="sda7 sda1"
PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
if [ "`echo ${SKIP_THESE_DEVICES} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
continue
fi
# End of patch
if [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
You can move the line 'SKIP_THESE_DEVICES="sda7 sda1"' to the top of the '30_os-prober' file if you want so you can easily add or remove devices without scrolling down
Better to generate a patch. Looks like it should also fit on F16 which now also uses grub2.
I am responsible for a netbook that has been booted to Windows recovery twice - this automatically starts a rebuild. Might just apply this ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.