All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Kellermann <axel.kellermann@gmx.de>
To: grub-devel@gnu.org
Subject: [PATCH] Skip partitions during OS probing
Date: Sat, 09 Jul 2011 23:43:34 +0200	[thread overview]
Message-ID: <4E18CB86.8040806@gmx.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

Hello devels,

I attached a patch I use on my machine to skip certain predefined
partitions during OS probing by grub-mkconfig/30_os-prober. I started to
work on this as grub2 adds the Win7 system partition of my dual-booted
laptop to the boot menu, although only Win7s boot partition is actually
needed. Not a big error, but it bugged me... ;)
But apart from this special case on my machine, I think it is handy to
have a standardized way to exclude certain partitions from being
auto-probed during execution of update-grub.

The patch updates two files. grub-mkconfig.in now exports an additional
user variable called GRUB_SKIP_PARTITIONS, 30_os-prober.in adds a few
lines to check whether the currently probed partition is contained in
GRUB_SKIP_PARTITIONS, and if so, skips addition of the boot menu entry.

To skip one ore more partitions during OS probing, the user has to add
the variable GRUB_SKIP_PARTITIONS to the grub config file
(/etc/default/grub) and provide it with a space delimited list of
partition names (e.g. GRUB_SKIP_PARTITIONS="sda2 sdb3").

I created the patch with the command 'bzr patch -p1'. If that is not the
correct way, please let me know. I'm also open for suggestions on
improving the patch.


Please let me know what you think,
thanks for the good work,

Axel

[-- Attachment #2: skip_partitions.patch --]
[-- Type: text/x-diff, Size: 1039 bytes --]

=== modified file 'util/grub-mkconfig.in'
--- old/util/grub-mkconfig.in	2011-07-07 21:52:58 +0000
+++ new/util/grub-mkconfig.in	2011-07-09 21:08:25 +0000
@@ -257,7 +257,8 @@
   GRUB_INIT_TUNE \
   GRUB_SAVEDEFAULT \
   GRUB_ENABLE_CRYPTODISK \
-  GRUB_BADRAM
+  GRUB_BADRAM \
+  GRUB_SKIP_PARTITIONS
 
 if test "x${grub_cfg}" != "x"; then
   rm -f ${grub_cfg}.new

=== modified file 'util/grub.d/30_os-prober.in'
--- old/util/grub.d/30_os-prober.in	2011-07-02 19:22:19 +0000
+++ new/util/grub.d/30_os-prober.in	2011-07-09 21:06:32 +0000
@@ -94,6 +94,12 @@
   LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
   LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
   BOOT="`echo ${OS} | cut -d ':' -f 4`"
+  PARTITION="`echo ${DEVICE} | grep -o '[^\/]\+$'`"
+
+  if [ "x${GRUB_SKIP_PARTITIONS}" != "x" -a "x`echo ${GRUB_SKIP_PARTITIONS} | grep -e '\b'${PARTITION}'\b'`" != "x" ] ; then
+    echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
+    continue
+  fi
 
   if [ -z "${LONGNAME}" ] ; then
     LONGNAME="${LABEL}"


             reply	other threads:[~2011-07-09 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09 21:43 Axel Kellermann [this message]
2011-07-11 15:13 ` [PATCH] Skip partitions during OS probing Phillip Susi
2011-07-11 15:55   ` Axel Kellermann
2011-07-11 18:25     ` Lennart Sorensen
2011-07-11 20:21       ` Axel Kellermann
2011-07-11 20:21     ` Phillip Susi
2011-07-18 18:06       ` Axel Kellermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E18CB86.8040806@gmx.de \
    --to=axel.kellermann@gmx.de \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.