LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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

Reply
 
LinkBack Search this Thread
Old 07-18-2009, 10:38 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Rep: Reputation: 60
grub2: Skipping one partition from OS detection


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?
 
Old 07-19-2009, 03:34 AM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu 10.04
Posts: 9,196
Blog Entries: 4

Rep: Reputation: 190Reputation: 190
http://pwet.fr/man/linux/administrat...me/update_grub
You edit /boot/grub/menu.lst and remove the entry for that partition.
 
Old 07-19-2009, 11:26 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Original Poster
Rep: Reputation: 60
yea, simon, but then if I run update-grub2 it'd be back, wouldn't it?
 
Old 07-20-2009, 02:10 AM   #4
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu 10.04
Posts: 9,196
Blog Entries: 4

Rep: Reputation: 190Reputation: 190
Hmmm... looking closer: The old update-grub just added entries for each /boot/vmlinuz-* it saw and did nothing to probe partitions.

The main issue here is lack of documentation:
http://osdir.com/ml/debian-bugs-dist.../msg03754.html

Here is an attempt to rectify this:
http://ubuntuforums.org/showthread.php?t=1195275


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?
 
Old 12-15-2009, 04:24 PM   #5
johanfa
LQ Newbie
 
Registered: Feb 2006
Location: Catalonia
Distribution: Debian testing, Ubuntu
Posts: 2

Rep: Reputation: 0
Hello eantoranz,

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.

GRUB_DEFAULT=0
GRUB_TIMEOUT=7
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="noresume quiet splash verbose vga=788"
GRUB_CMDLINE_LINUX=

# 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

Example:
This is my /usr/sbin/grub-mkconfig:

... ...
# These are optional, user-defined variables.
export GRUB_DEFAULT \
GRUB_HIDDEN_TIMEOUT \
GRUB_HIDDEN_TIMEOUT_QUIET \
GRUB_TIMEOUT \
GRUB_DISTRIBUTOR \
GRUB_CMDLINE_LINUX \
GRUB_CMDLINE_LINUX_DEFAULT \
GRUB_TERMINAL_INPUT \
GRUB_TERMINAL_OUTPUT \
GRUB_SERIAL_COMMAND \
GRUB_DISABLE_LINUX_UUID \
GRUB_DISABLE_LINUX_RECOVERY \
GRUB_GFXMODE \
GRUB_DISABLE_OS_PROBER

# 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):

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`"

# 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)

Regards,

Johan
 
Old 12-15-2009, 06:34 PM   #6
syg00
Guru
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 9,976

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Interesting. What about if the package gets updated ?.
 
Old 12-16-2009, 01:59 PM   #7
johanfa
LQ Newbie
 
Registered: Feb 2006
Location: Catalonia
Distribution: Debian testing, Ubuntu
Posts: 2

Rep: Reputation: 0
Hello syg00,

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.

Regards,

Johan
 
Old 12-16-2009, 05:02 PM   #8
syg00
Guru
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 9,976

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
The question was meant as a warning to others.
Have you submitted the change upstream ? - seems like a worthwhile addition.
 
  


Reply

Tags
configuration, grub2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
altered partition table, Grub2 will not load, how-to chroot? kyrand0047 Linux - General 11 02-25-2011 05:57 PM
skipping dhcp broadcast/network detection xxNEEDHELPxx Linux - Software 1 05-06-2008 08:10 PM
Stuck at Grub2 prompt after deleting Linux partition of dual boot alcorta Linux - Software 3 07-09-2005 12:12 AM
FC2 test 3 mouse skipping a beat, movie skipping also jang Fedora 1 10-28-2004 08:42 PM
Skipping failing HD detection jeanluc_orsai Linux - Hardware 1 04-14-2004 05:02 PM


All times are GMT -5. The time now is 02:43 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration