All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Javier Martín" <lordhabbit@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Drivemap module
Date: Wed, 06 Aug 2008 19:31:19 +0200	[thread overview]
Message-ID: <1218043880.6890.32.camel@localhost> (raw)
In-Reply-To: <721379.55348.qm@web31608.mail.mud.yahoo.com>

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

El mié, 06-08-2008 a las 07:43 -0700, Viswesh S escribió:
> Hi,
> 
>  
> 
> Could you let all know how to use your drivemap command.Is it similar
> to the map command in legacy grub.

Hi there. Information about the use of a command is better placed in the
wiki than in this list, however this command is not merged in yet, and I
reckon its "help" feature could be quite better.

Currently, the "safe" GRUB2 commands for booting from (hd1,1) is:

drivemap (hd0) (hd1)
drivemap (hd1) (hd0)
set root=(hd0)
chainloader (hd1,1)+1
boot

Maybe an explanation of what "drivemap" does would put a bit of light
here:

	* The BIOS hard disks are numbered from 0 to 128 (actually from 0x80 to
0xFF because the lower numbers are reserved for floppy disks). These
numbers are used to select the target drive when issuing I/O requests
through the BIOS routines (INT 13h)
	* When the BIOS loads a boot sector and transfers control to it, the DL
register contains the "boot disk number", i.e. the disk from which the
bootsector was loaded. This allows the bootsector to load its OS from
the same disk it was run, instead of having to probe every single disk
in the system.
	* The "chainloader" command works like the BIOS: it loads a bootsector
into memory and jumps to it. In this case, the value in DL corresponds
to the disk that was set as "root drive" to GRUB. If no root drive is
set, the OS receives 0xFF, which should be recognized as an impossible
drive. Some OSes will just trust this and fail (i.e. FreeDOS) while
others will try to boot from the first hard disk (0x80).
	* The "drivemap" command acts as the old TSRs from the DOS times: when
the "boot" command is issued, it installs its own handler for INT 13h
requests, which performs the requested mappings and then call the old
(usually BIOS) handler with the changed parameters. Thus, an OS
accessing the drive through the BIOS routines will see the drives moved,
duplicated or whatever the mappings provided. Again: drivemap does NOT
modify the "live" drive mappings within GRUB; its changes only affect
the booted OS.

The strange root=(hd0) line that appears to contradict the chainloader
line is there because drivemap has no communication with the particular
loader. If you set root to (hd1,1) and then issue chainloader and boot,
the OS will receive 0x81 in DL because hd1 was the second hard drive
when chainloader was issued (remember that drivemap doesn't act until
"boot"). Thus, the target OS will try to boot from what _it_ sees as the
second hard disk, which will now be the old hd0 - wrong.

If the target OS does not need to access the old hd0 or it only uses the
BIOS routines for the boot process (i.e. it later uses ATA drivers and
will redetect everything from scratch), you can leave the second
drivemap line out and use a more compact script like this:

drivemap (hd0) (hd1)
set root=(hd1,1)
chainloader +1
boot

This will work on Windows, because no matter where it tries to boot from
it will find the same disk: both the first and second BIOS disks point
to hd1 now. However, if you use a DOS-like system which uses the BIOS
routines exclusively (i.e. FreeDOS) then your hd0 disk would have
disappeared to it and you'd have D: to be a mirror of C:. In order to
have hd0 as D:, hd1 as C: and everything working, you need the first
script I posted, which makes the complete swap and then makes FreeDOS
load from the "first" hard drive (i.e. hd1). This is the setup I have
extensively tested in QEMU, while the Windows boot has been tested in
both QEMU (with ReactOS) and some random computers including mine (with
Windows XP Home and Windows XP Pro x64).

I'm looking forward to streamline the drivemap syntax, so that the two
drivemap lines can be fused into one like "drivemap --swap (hd0) (hd1)".
However, given that it's not a bug and that GRUB is still in heavy
development (and thus syntax changes are acceptable), I'd prefer to have
the patch integrated as it is - so we have the functionality - and then
modify what's needed - so we have it pretty.

-Habbit

[-- Attachment #2: Esta parte del mensaje está firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

  reply	other threads:[~2008-08-06 17:28 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 14:43 [PATCH] Drivemap module Viswesh S
2008-08-06 17:31 ` Javier Martín [this message]
2008-08-08 13:20   ` Felix Zielcke
  -- strict thread matches above, loose matches on Subject: below --
2008-08-08 13:43 Viswesh S
2008-08-07 12:15 Viswesh S
2008-07-04  2:12 Javier Martín
2008-07-05 11:04 ` Marco Gerards
2008-07-16 15:39   ` Javier Martín
2008-07-20 19:40 ` Marco Gerards
2008-07-21  0:55   ` Javier Martín
2008-07-21 11:07     ` Javier Martín
2008-07-22 21:32     ` Robert Millan
2008-07-31 19:01     ` Marco Gerards
2008-08-03 23:29       ` Javier Martín
2008-08-04 20:51         ` Marco Gerards
2008-08-04 23:10           ` Javier Martín
2008-08-05  0:50             ` Isaac Dupree
2008-08-05  2:38               ` Javier Martín
2008-08-05 11:31                 ` Marco Gerards
2008-08-05 11:23             ` Marco Gerards
2008-08-05 17:18               ` Colin D Bennett
2008-08-05 11:28             ` Marco Gerards
2008-08-05 16:39               ` Javier Martín
2008-08-09 15:33                 ` Javier Martín
2008-08-13 10:13                   ` Marco Gerards
2008-08-13 12:16                     ` Javier Martín
2008-08-13 13:00                       ` Robert Millan
2008-08-13 14:28                         ` Javier Martín
2008-08-13 14:51                           ` Marco Gerards
2008-08-13 15:14                           ` Robert Millan
2008-08-13 15:57                             ` Marco Gerards
2008-08-13 22:38                               ` Javier Martín
2008-08-14 17:15                                 ` Marco Gerards
2008-08-14 22:17                                   ` Javier Martín
2008-08-13 13:01                       ` Robert Millan
2008-08-05 17:15             ` Colin D Bennett
2008-06-10 20:09 Javier Martín
2008-06-10 20:23 ` Vesa Jääskeläinen
2008-06-10 21:31   ` Javier Martín
2008-06-12 20:31     ` Pavel Roskin
2008-06-12 22:43       ` Javier Martín
2008-06-12 22:58         ` Colin D Bennett
2008-06-13  1:00           ` Pavel Roskin
2008-06-13  4:09             ` Colin D Bennett
2008-06-13  1:37         ` Pavel Roskin
2008-06-13  2:29           ` Javier Martín
2008-06-11 14:44 ` Marco Gerards

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=1218043880.6890.32.camel@localhost \
    --to=lordhabbit@gmail.com \
    --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.