From: Zhu Yi <yi.zhu@intel.com>
To: Robert Millan <rmh@aybabtu.com>
Cc: "grub-devel@gnu.org" <grub-devel@gnu.org>,
Zhu Yi <chuyee@octavia.sh.intel.com>
Subject: Re: [PATCH 2/2] Add grub-install --restore option
Date: Thu, 07 Jan 2010 09:10:05 +0800 [thread overview]
Message-ID: <1262826605.15653.157.camel@debian> (raw)
In-Reply-To: <20100106135024.GA2360@thorin>
On Wed, 2010-01-06 at 21:50 +0800, Robert Millan wrote:
> Hi,
>
> On Wed, Jan 06, 2010 at 05:10:04PM +0800, Zhu Yi wrote:
> > diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in
> > index 8a06213..4d0043e 100644
> > --- a/util/i386/pc/grub-install.in
> > +++ b/util/i386/pc/grub-install.in
> > @@ -51,6 +51,7 @@ no_floppy=
> > force_lba=
> > recheck=no
> > debug=no
> > +restore=
> >
> > if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
> > disk_module=biosdisk
> > @@ -77,6 +78,7 @@ Install GRUB on your drive.
> > --no-floppy do not probe any floppy drive
> > --recheck probe a device map even if it already exists
> > --force install even if problems are detected
> > + --restore restore the previous boot sectors
> > EOF
> > if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
> > cat <<EOF
> > @@ -129,6 +131,10 @@ for option in "$@"; do
> > debug=yes ;;
> > -f | --force)
> > setup_force="--force" ;;
> > + --restore)
> > + restore="$grub_prefix/bootsectors.bak" ;;
> > + --restore=*)
> > + restore=`echo "$option" | sed 's/--restore=//'` ;;
> > -*)
> > echo "Unrecognized option \`$option'" 1>&2
> > usage
> > @@ -203,6 +209,29 @@ else
> > exit 1
> > fi
> >
> > +if test -f "$restore"; then
> > + if test `stat -c%s $restore` -eq 512; then
> > + dd if=$restore of=$install_device bs=512 count=1
> > + exit 0
> > + fi
> > + start=`od -j92 -N8 -An -td8 $grubdir/boot.img`
> > +
> > + # Synaty check
> > + if test $((`stat -c%s $restore` - $start * 512)) -ne \
> > + `stat -c%s $grubdir/core.img`; then
> > + echo "Error: $restore doesn't match core.img, restore aborted."
> > + exit 1
> > + fi
> > +
> > + # Restore
> > + dd if=$restore of=$install_device bs=512 count=1 > /dev/null 2>&1
> > + dd if=$restore of=$install_device skip=512 seek=`expr $start \* 512` \
> > + bs=1 > /dev/null 2>&1
> > + rm -f $restore
> > + echo "Restore boot sectors from $restore successfully"
> > + exit 0
> > +fi
>
> Please don't add this to grub-install. This kind of highly BIOS-specific
> logic would suit much better in grub-setup.
Do you prefer to implement above in C code and add a "--restore" option
to grub-setup or create a separate script for doing this?
Thanks,
-yi
next prev parent reply other threads:[~2010-01-07 1:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-06 9:10 [PATCH 1/2] Backup old boot sectors before installation Zhu Yi
2010-01-06 9:10 ` [PATCH 2/2] Add grub-install --restore option Zhu Yi
2010-01-06 13:50 ` Robert Millan
2010-01-07 1:10 ` Zhu Yi [this message]
2010-01-07 1:36 ` Robert Millan
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=1262826605.15653.157.camel@debian \
--to=yi.zhu@intel.com \
--cc=chuyee@octavia.sh.intel.com \
--cc=grub-devel@gnu.org \
--cc=rmh@aybabtu.com \
/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.