3 Pages V   1 2 3 >  
Reply to this topic
 Grub4dos boot Win XP
post Jul 22 2009, 02:35 AM
Post #1
Hernandito
Newbie   *
Group: Members

  Joined: 23-April 09
Posts: 25
Thank(s): 1


United States


Hi Gang,

I am fairly a newbie, trying to graduate rolleyes.gif ... and I am stuck. I am creating a USB boot device which among other things, should simply boot the WinXP hard drive in the computer. I know all about XP needing to be the (hd0) drive on the computer and how to boot to it using something like this:

CODE
title Boot XP
map (hd1) (hd0)
map (hd0) (hd1)
map --hook
root (hd0,0)
chainloader /ntldr
boot


In the example above, XP is in (hd1) and it boots quite nicely.

My problem lies in that I cannot always determine which (hd#) is XP's hard drive. This will vary from computer to computer. I thought I could generate something like this, but this menu just runs in a loop:

CODE
title Boot XP2
find --set-root /ntldr
map /ntldr (hd32)
map --hook
map (hd32) (hd0)
map (hd0) (hd32)
map --hook
root (hd0,0)
chainloader (hd0)+1
rootnoverify (hd0)


Is what I am trying to achieve at all possible? What can I do to fix my code above?

Many thanks,

Hernando


+Quote Post
post Jul 22 2009, 04:28 AM
Post #2
ktp
Silver Member   ****
Group: Advanced user

  Joined: 16-February 07
Posts: 653
Thank(s): 37


> I know all about XP needing to be the (hd0) drive on the computer

Why ?

Have you tried simply :
CODE
title Boot XP
find --set-root /ntldr
chainloader /ntldr


+Quote Post
post Jul 22 2009, 07:33 AM
Post #3
was_jaclaz
Finder   ******
Group: Advanced user

  Joined: 14-July 06 From: Gone in the mist

Posts: 7,230
Thank(s): 564


Italy


@Hernandito

(hd32) is a "special" hard disk, used to map .iso images.

hd's from (hd0) to (hd31) are "normal" hard disk devices.

A /ntldr file is rather common, since grub4dos scans hard disk in the BIOS order (hd0)...(hd1)...(hd2)... etc., it is likely that it won't work anyway.

If you boot from a USB key, it will become in BIOS (hd0), effectively shifting internal hard disks by one.

Since out of 10000 machines, exactly 10000 will have the first disk (hd0) being the one with NTLDR, the first menu entry you posted will always work.

Otherways, try this:
CODE
title Boot XP2
map (hd0) (hd31)
map --hook
find --set-root /ntldr
chainloader /ntldr


What happens? unsure.gif

Or to avoid that the find --set-root finds first the NTLDR on the USB stick, rename it to something else, like MYLDR. wink.gif

XP doesn't really "need" the booting hard disk to be (hd0) as it uses Disk Signature in the MBR to recognize it.

jaclaz



--------------------
+Quote Post
post Jul 22 2009, 07:59 AM
Post #4
maanu
Silver Member   ****
Group: Advanced user

  Joined: 31-October 08
Posts: 949
Thank(s): 169


Pakistan


@ jaclaz

bt sir , what if we chainload hd0.1(if hd0.0 becomes usb then i guess hd0.1 ll become 1st partition of 1st hdd attached?) to boot ntldr from the hdd ,avoiding to confuse grub4dos to boot ntldr in attached usb's root ?

edit :

we do have --ignore-floppies --ignore-cd that we can use to pinpoint the G4D , bt i guess we dont have it to ignore usb's , hdd's ? just curious
+Quote Post
post Jul 22 2009, 08:12 AM
Post #5
was_jaclaz
Finder   ******
Group: Advanced user

  Joined: 14-July 06 From: Gone in the mist

Posts: 7,230
Thank(s): 564


Italy


QUOTE (maanu @ Jul 22 2009, 09:59 AM) *
bt sir , what if we chainload hd0.1(if hd0.0 becomes usb then i guess hd0.1 ll become 1st partition of 1st hdd attached?) to boot ntldr from the hdd ,avoiding to confuse grub4dos to boot ntldr in attached usb's root ?

we do have --ignore-floppies --ignore-cd that we can use to pinpoint the G4D , bt i guess we dont have it to ignore usb's , hdd's ? just curious


I am not sure to understand your question. unsure.gif

If USB is (hd0), (hd0,0), (hd0,1), (hd0,2),...(hd0,n) will ALL represent partitions on the USB.
(hd1) will be NEXT disk (the internal one).

Re-mapping (hd0) to (hd31) should solve the problem dubbio.gif, unless of course you have 32 or more internal hard disks...happy22.gif

jaclaz


--------------------
+Quote Post
post Jul 22 2009, 08:41 AM
Post #6
ktp
Silver Member   ****
Group: Advanced user

  Joined: 16-February 07
Posts: 653
Thank(s): 37


@jaclaz

> XP doesn't really "need" the booting hard disk to be (hd0) as it uses Disk Signature in the MBR to recognize it.

Could you explain a little more or point to me to some links? I did not fully understand the statement.
+Quote Post
post Jul 22 2009, 10:42 AM
Post #7
maanu
Silver Member   ****
Group: Advanced user

  Joined: 31-October 08
Posts: 949
Thank(s): 169


Pakistan


QUOTE (jaclaz @ Jul 22 2009, 08:12 AM) *
I am not sure to understand your question. unsure.gif

If USB is (hd0), (hd0,0), (hd0,1), (hd0,2),...(hd0,n) will ALL represent partitions on the USB.
(hd1) will be NEXT disk (the internal one).

Re-mapping (hd0) to (hd31) should solve the problem dubbio.gif, unless of course you have 32 or more internal hard disks...happy22.gif

jaclaz



ooooooh , i was taking it very wrongly , hmm so if we have 2 hdd's installed and one usb , and when booting from usb , bios will list it like this

usb =hd0
1st hdd=hd1
2nd hdd=hd2

and why should we map hd0 to hd31 then ? cant we simply use hd1 ?

thanks..
+Quote Post
post Jul 22 2009, 11:15 AM
Post #8
was_jaclaz
Finder   ******
Group: Advanced user

  Joined: 14-July 06 From: Gone in the mist

Posts: 7,230
Thank(s): 564


Italy


QUOTE (ktp @ Jul 22 2009, 10:41 AM) *
@jaclaz

> XP doesn't really "need" the booting hard disk to be (hd0) as it uses Disk Signature in the MBR to recognize it.

Could you explain a little more or point to me to some links? I did not fully understand the statement.

Once the NTLDR or SETUPLDR.BIN are started they invoke NTDETECT.COM which (re-)detects the drives, using Disk Signature in the MBR to identify which is which.
BEFORE that the drives are identified by their ARCPATH (i.e. the BOOT.INI entries, using the BIOS order).
I.e. an entry in BOOT.INI like:
CODE
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect

means more or less "set as boot system the \Windows you can find on first disk rdisk(0), in it's first partition partition(1) as the BIOS sees them".
Same happens for path specified in .SIF file for SETUPLDR.BIN.
NTDETECT.COM reads the Disk Signature in the MBR of the given disk (AND checks the MBR checksum) in order to boot from the "right" drive and have it's partitions mounted properly in "DosDevices" in Registry.

Things to read:
http://mirror.href.com/thestarman/asm/mbr/index.html
http://mirror.href.com/thestarman/asm/mbr/index.html#win2kxp
http://mirror.href.com/thestarman/asm/mbr/Win2kmbr.htm
http://www.911cd.net/forums//index.php?showtopic=19663
http://www.911cd.net/forums//index.php?showtopic=21242

http://www.boot-land.net/forums/index.php?...ic=3515&hl= happy22.gif
http://www.boot-land.net/forums/index.php?showtopic=2568
http://www.boot-land.net/forums/index.php?...c=2568&st=7

Of course, once NTLDR (or SETUPLDR.BIN) is loaded, it all depends on the entries in BOOT.INI (or in .SIF file).

Since changing "on the fly" BOOT.INI is not easy/advisable onthe existing system, re-mapping drives appears the easier solution.

Alternatively one could use a floppy image with NTLDR, NTDETECT.COM and BOOT.INI with several entries or patch "on-the-fly" the BOOT.INI on the floppy image.

QUOTE (maanu @ Jul 22 2009, 12:42 PM) *
and why should we map hd0 to hd31 then ? cant we simply use hd1 ?

See above.

cheers.gif

jaclaz


--------------------
+Quote Post
post Jul 22 2009, 12:47 PM
Post #9
ktp
Silver Member   ****
Group: Advanced user

  Joined: 16-February 07
Posts: 653
Thank(s): 37


@jaclaz
QUOTE
Since changing "on the fly" BOOT.INI is not easy/advisable onthe existing system, re-mapping drives appears the easier solution.


Wow, thank you, this is exactly the illuminating part that I missed. It is the problem of hard coded values (rdisk(x), partition(y)) in boot.ini.

I understand that there is no such problem with Vista or Windows 7 chainloading /bootmgr since it is independent of the hard disk order (using some king of UUID or GUUID ? for disk signature).

QUOTE
Alternatively one could use a floppy image with NTLDR, NTDETECT.COM and BOOT.INI with several entries or patch "on-the-fly" the BOOT.INI on the floppy image.


Excellent idea, I will add an entry to my grub4dos menu.lst of my multiboot USB HDD, so once booted it is capable of booting any XP OS on any of up to 4 HDD (hd0-hd3), inside the first 4 partitions, which should be commonly sufficient.

About patchig on the fly boot.ini, do you mean to patch it in memory or by editing the real file ? If yes, how to patch it on the fly?
Editing the real file (using editbini or other means under grub4dos booting DOS with NTFS support) would then break the normal boot on the system?
+Quote Post
post Jul 22 2009, 01:11 PM
Post #10
was_jaclaz
Finder   ******
Group: Advanced user

  Joined: 14-July 06 From: Gone in the mist

Posts: 7,230
Thank(s): 564


Italy


QUOTE (ktp @ Jul 22 2009, 02:47 PM) *
About patchig on the fly boot.ini, do you mean to patch it in memory or by editing the real file ? If yes, how to patch it on the fly?
Editing the real file (using editbini or other means under grub4dos booting DOS with NTFS support) would then break the normal boot on the system?


I would exclude editing the BOOT.INI on hard disk (for obvious safety reasons), but I see no problems in patching the version in the floppy image.

This can be done as you suggested, in DOS, or even all inside grub4dos, using (and abusing wink.gif) of the newish grub4dos commands write and/or dd:

CODE

******************************************************************************
*** Use 'write' to write a string into a device or file ***
******************************************************************************

Usage:

write [--offset=SKIP] ADDR_OR_FILE INTEGER_OR_STRING

SKIP is an integer and defaults to 0.

If ADDR_OR_FILE is an integer, then it is treated as a memory address, and
INTEGER_OR_STRING must be an integer value. The integer INTEGER_OR_STRING
will be written to address (ADDR_OR_FILE + SKIP).

If ADDR_OR_FILE is a device or a file, then INTEGER_OR_STRING is treated as
a string which will be written to ADDR_OR_FILE at offset SKIP (in bytes).

The string is quoted with nothing, that is, neither with the single quote
char(') nor with the double quote char(").

Space char must be quoted with back slash(\). (Update: need not now)

Single quote char(') and double quote char(") are not interpreted specially
and can be used directly in the string.

Some C-style quote sequences are interpreted as follows:

\NNN character with octal value NNN (1 to 3 digits)

\\ backslash

\a alert (BEL)

\b backspace

\f form feed

\n new line

\r carriage return

\t horizontal tab

\v vertical tab

\xHH byte with hexadecimal value HH (1 to 2 digits)

Just like dd, the write can neither enlarge nor reduce the size of the
destination file, the leftover tail of the string will be discarded.
The destination file cannot be a gzipped file.

Again like dd, the write command is also dangerous, use at your own risk.
And to be on the safe side, you should only write to memory files.

In some cases when writing a file in a NTFS volume, the write might fail.

If you attempt to write a device or a block file that is not in memory by
using write in a menu, you will safely be refused :-) (Update: no restrictions
now)


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!
!!!! Caution! The file to write can be a device name which stands !!!!
!!!! for all the sectors on the device. Take utmost care! !!!!
!!!!______________________________________________________________________!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


CODE
***********************************************************************
*******
*** New command 'dd' to copy files ***
******************************************************************************

Usage:

dd if=IF of=OF [bs=BS] [count=C] [skip=IN] [seek=OUT] [buf=ADDR] [buflen=SIZE]

Copy file IF to OF. BS is blocksize in bytes, default to 512. C is blocks to
copy, default is total blocks in IF. IN specifies number of blocks to skip
when read, default is 0. OUT specifies number of blocks to skip when write,
default is 0. Skipped blocks are not touched. Both IF and OF must exist.

Both IF and OF must have a leading device name, i.e., of the form `(...)'.
You may use `()' for the current root device.

dd can neither enlarge nor reduce the size of OF, the leftover tail of IF
will be discarded. OF cannot be a gzipped file. If IF is a gzipped file,
it will be decompressed automatically when copying.

dd is dangerous, use at your own risk. To be on the safe side, you should
only use dd to write a file in memory.

In some cases when writing a file in a NTFS volume, dd might fail.

If you attempt to write a device or a block file that is not in memory by
starting dd in a menu, you will safely be refused :-) (Update: no restrictions
now)

Update: New options are implemented for user defined buffer. By default,
the buffer is at address 0x50000, and length is 0x10000(=64KB). You cannot
specify ADDR to be lower than 0x100000(=1MB). Besides, you must specify SIZE
larger than 0x10000(=64KB). Normally you want ADDR >= 0x1000000(=16MB), and
SIZE also >= 16MB. A large SIZE could speed up the progression of dd.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!
!!!! Caution! Both IF and OF can be a device name which stands for !!!!
!!!! all the sectors on the device. Take utmost care! !!!!
!!!!______________________________________________________________________!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


A suitable floppy image is described here:
http://www.xxcopy.com/xxcopy33.htm

An old example for a "multiple" BOOT.INI is here:
http://www.msfn.org/board/index.php?showtopic=25365

There is a limit to 9 entries in BOOT.INI:
http://www.msfn.org/board/index.php?showto...134296&st=3


cheers.gif

jaclaz


--------------------
1 user(s) said "Thank you!" to jaclaz for this fantastic post:
ktp
+Quote Post

3 Pages V   1 2 3 >
Reply to this topic
1 User(s) are reading this topic ()