Jump to content











Photo
- - - - -

Map command and hard disk first sector: 63 or 2048?


  • Please log in to reply
15 replies to this topic

#1 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 11 January 2015 - 08:10 AM

For the "map" command to work properly which of the statements below is correct (legacy/mbr computer with two hard disks):

 

1) Both (hd0,0) and (hd1,0) must start at sector 63

2) If (hd0,0) starts at sector 63 then (hd1,0) must also start at sector 63

3) If (hd0,0) starts at sector 2048 then (hd1,0) must also start at sector 2048

 

I got into problems with Grub4Dos "map" command when (hd0,0) started at sector 63 and (hd1,0) started at sector 2048. Bart PE installed on (hd1,0) would not boot. Here is "menu.lst":

 

title Bart PE on Hard Disk #2

map (hd0) (hd1)

map (hd1) (hd0)

chainloader (hd1,0)/minint/setupldr.bin

 

Setting the start sector at 63 for both (hd0,0) and (hd1,0) resolved the problem, which might actually be related to Bart PE (it's built from Windows XP SP2) and not Grub4Dos, it's hard to tell.

 

Initially I bootlaced G4D boot sector code to (hd1,0) and booted from there but this setup was not stable so I bootlaced (hd0,2)  and everything works just fine now. My first stage (MBR) bootloader is Boot-US and then I select the partition to boot to with G4D.

 

Lately I decided to install a new second hard disk and install Bart PE on the hard drive (to get it running faster than from a flash drive). I assumed it was going to be a routine task that would take about one hour to complete, but instead I got into all this mind-boggling stuff about Advanced Format Drives with 4096 byte sectors that emulate 512 byte sectors, partitions aligned to 1 MiB instead of CHS, first primary partition starting at sector 2048 instead of 63, etc. I'm slowly trying to sort this out because when you want to keep using some legacy software there are some conflicting requirements to deal with.

 

--------------------------------------

- legacy BIOS / MBR computer

- two new 500 GB hard disks with 4096 / e512 sectors

- 1st stage bootloader (MBR): Boot-US

- 2nd stage bootloader (PBR): Grub4Dos v0.4.5c-2014-12-24

- Bart PE with 2009 Acronis True Image plugin, installed on (hd1,0)

- primary OS: Linux Xubuntu 14.04.1 LTS

- secondary OS: Windows XP SP3


Edited by Kirkx, 11 January 2015 - 08:38 AM.


#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 08:21 AM

What happens if you omit the two map lines?

#3 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 11 January 2015 - 08:30 AM

 

Steve6375: What happens if you omit the two map lines?

It won't boot: Error 14: File txtsetup.sif is corrupt or missing

 

The boot errors I have come across when trying things out were as follows.

 

1) Error 14: File txtsetup.sif is corrupt or missing

 

Encountered: when booting Bart PE

Solution: add "map" command.

 

2) Error 15: File not found

 

Encountered: when booting Bart PE

Solution: align partitions referenced by the "map" command to start at sector 63.

 

3) "Disk read error" (no error code)

 

Encountered: when booting Xubuntu

Solution: align first partitions on both disks to start at sector 63.


Edited by Kirkx, 11 January 2015 - 09:02 AM.


#4 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 08:49 AM

What if you add
map --hook
After the map lines but before chain loader
And use (hd0,0) in the chain loader command?

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 09:02 AM

P.S. If bartpe is on disk 2, did you edit the  \boot.ini file so that it uses disk 2 instead of disk 1?



#6 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 11 January 2015 - 10:05 AM

 

What if you add
map --hook

 

I have never bothered with [ map --hook ]. I have assumed that functionally, at the execution level, the two commands below are identical and that [ map --hook ] only exists to make the code more clear in some situations.

 

title Bart PE on Hard Disk #2

map (hd0) (hd1)

map (hd1) (hd0)

chainloader (hd1,0)/minint/setupldr.bin

 

title Bart PE on Hard Disk #2

map (hd0) (hd1)

map (hd1) (hd0)

map --hook

chainloader (hd0,0)/minint/setupldr.bin

 

 

If bartpe is on disk 2, did you edit the  \boot.ini file so that it uses disk 2 instead of disk 1?

I don't use boot.ini for anything. As mentioned before, my first stage bootloader, at MBR level, is Boot-US. It has "true hide" functionality that prevents currently booted Windows from seeing all other Windows installations. Even Linux can't see those partitions. On the screenshots below I'm booted to sda3 and sda1, sda2, sdb1, sdb2, sdb3 are "true hidden":

 

http://i.imgur.com/Hsq04hA.png

 

http://i.imgur.com/6Wx366u.png

 

Here is my post asking about this functionality in Grub4Dos:

 

http://reboot.pro/to...ide-a-partition

 

So my primary boot menu is not that of Windows/boot.ini but that of Boot-US. From there I will select a primary partition to boot to. In this particular case I'm booting to (hd0,2). It has been bootlaced from Linux using the command shown below so it loads the G4D menu from memu.lst right away and not the Windows menu.

 

sudo ./bootlace.com --floppy=2 --ntfs /dev/sda3

 

My setup is actually a bit complex because I have BartPE installed on (hd0,2) and on (hd1,0). With a properly designed "menu.lst" this alllows forcing BartPE to always assign drive letter C to the primary partition that you want to image. Also, when making a partition image you do it using BartPE installed on a different disk, not the one on which the imaged partition resides. Here is a sample of my menu.lst:

 

title BartPE C-1
unhide (hd0,0)
hide (hd0,1)
hide (hd0,2)
unhide (hd1,0)
hide (hd1,1)
hide (hd1,2)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (hd1,0)/minint/setupldr.bin
 
title BartPE C-2
hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
unhide (hd1,0)
hide (hd1,1)
hide (hd1,2)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (hd1,0)/minint/setupldr.bin

 

title BartPE C-4
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
unhide (hd1,0)
hide (hd1,1)
hide (hd1,2)
# map (hd0) (hd1)
# map (hd1) (hd0)
chainloader (hd0,2)/minint/setupldr.bin



#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 10:24 AM

title Bart PE on Hard Disk #2
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (hd1,0)/minint/setupldr.bin

title Bart PE on Hard Disk #2
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0,0)/minint/setupldr.bin

 

 

I am not sure these are equivalent?

By not using map --hook or root the drives are not actually swapped until grub4dos runs setupldr.bin

 

In the first menu it may pass dl=0x81 as the boot drive to setupldr.bin, in the second case it may pass dl=0x80 as the boot drive.

 

I would be inclined to also use root to set the current drive and partition number, e.g.

 

[Edited]

title Bart PE on Hard Disk #2
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
root (hd0,0) || rootnoverify (hd0,0)
chainloader (hd0,0)/minint/setupldr.bin


#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 10:33 AM

P.S. or maybe try

title Bart PE on Hard Disk #2
root (hd1,0) || rootnoverify (hd1,0)
chainloader (hd1,0)/minint/setupldr.bin


#9 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 11:04 AM

P.S. To true-hide using grub4dos try

# HIDE hd0,1
cat --locate=NTFS --replace=ntfs --skip=3 --length=8 (hd0,1)+1
cat --locate=MS --replace=ms --skip=3 --length=8 (hd0,1)+1
hide (hd0,1)

#UNHIDE
cat --locate=ntfs --replace=NTFS --skip=3 --length=8 (hd0,1)+1
cat --locate=ms --replace=MS --skip=3 --length=8 (hd0,1)+1
unhide (hd0,1)

It seems to work for NTFS, I have not tested MSDOS/FAT.

Presumably more lines could be added for other types of partitions, e.g. DOS, IBM?



#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 11 January 2015 - 12:03 PM

Here is improved version

title HIDE HD0,1
set PTN=(hd0,1)
debug 2
# HIDE hd0,1
cat --locate=NTFS --replace=ntfs --skip=3 --length=8 %PTN%+1 > nul
cat --locate=MS --replace=ms --skip=3 --length=8 %PTN%+1 > nul
cat --locate=OS --replace=os --skip=3 --length=8 %PTN%+1 > nul
cat --locate=IBM --replace=ibm --skip=3 --length=8 %PTN%+1 > nul
cat --locate=FAT --replace=fat --skip=3 --length=8 %PTN%+1 > nul
# make magic bytes invalid
cat --locate=\x55\xaa --replace=\x15\xaa --skip=510  %PTN%+1 > nul
cat --locate=\x55\xaa --replace=\x15\xaa --skip=510  %PTN%1+1 > nul
# set partition type in MBR to hidden
hide %PTN%
pause
errorcheck off
boot

title UNHIDE HD0,1
set PTN=(hd0,1)
debug 2
#UNHIDE
cat --locate=ntfs --replace=NTFS --skip=3 --length=8 %PTN%+1 > nul
cat --locate=ms --replace=MS --skip=3 --length=8 %PTN%+1 > nul
cat --locate=os --replace=OS --skip=3 --length=8 %PTN%+1 > nul
cat --locate=ibm --replace=IBM --skip=3 --length=8 %PTN%+1 > nul
cat --locate=fat --replace=FAT --skip=3 --length=8 %PTN%+1 > nul
cat --locate=\x15\xaa --replace=\x55\xaa --skip=510  %PTN%+1 > nul
cat --locate=\x15\xaa --replace=\x55\xaa --skip=510  %PTN%1+1 > nul
unhide %PTN%
pause
errorcheck off
boot

it should work for MSWIN, MSDOS, EXFAT, IBM, NTFS, MYOS



#11 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 11 January 2015 - 12:36 PM

1) Thanks for your suggestions. After studying the original Manual I was under the impression that without [map --hook] the mapping takes effect right after the "boot" command has been issued and with [map --hook] present it takes effect right after [map --hook] command has been issued. But who knows, it won't do any harm to try [map --hook].

http://diddy.boot-la.../map.htm#direct

I don't want to play around and change the first sector on my disks again just to try out your code, but I have tried it to chainload Bart PE installed on the first primary partition on the second disk (hd1,0) from Grub4Dos bootlaced and installed on the same partition. It won't boot:

Error 15: File not found

title Bart PE & Grub4Dos on Hard Disk #2
hide (hd0,0)
hide (hd0,1)
hide (hd0,2)
unhide (hd1,0)
hide (hd1,1)
hide (hd1,2)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
root (hd1,0)
rootnoverify (hd1,0)
chainloader (hd1,0)/minint/setupldr.bin

2) If you could crack "true hiding" that would be great news. Maybe you could re-post your latest code on my original thread about true hiding. It would be easier for others to find it.

http://reboot.pro/to...ide-a-partition



#12 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 12 January 2015 - 05:20 PM

If you want to boot to hd1,0 then you need this

title Bart PE & Grub4Dos on Hard Disk #2
hide (hd0,0)
hide (hd0,1)
hide (hd0,2)
unhide (hd1,0)
hide (hd1,1)
hide (hd1,2)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
# hd1 is now hd0   and  hd0 is now hd1
root (hd0,0) || rootnoverify (hd0,0)
chainloader (hd0,0)/minint/setupldr.bin


#13 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 14 January 2015 - 08:02 AM

 

Steve6375: # hd1 is now hd0  and  hd0 is now hd1

Obvious error on my part, thanks for the corrected code. However, Bart PE still won't boot:

 

Error 15: File not found



#14 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 14 January 2015 - 11:32 AM

Just to clarify. The Error 15 mentioned above is not a deal breaker for me because I can easily chainload BartPE installed on Disk #2 from Grub4Dos installed on any primary partition on Disk #1. It just won't chainload from Grub4Dos installed on a primary partition on Disk #2. This is not really a big problem, I was just curious how to do it and if I have missed something obvious. Thanks for all your answers.


Edited by Kirkx, 14 January 2015 - 11:33 AM.


#15 steve6375

steve6375

    Platinum Member

  • Developer
  • 7053 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 14 January 2015 - 12:17 PM

sure - but I am just curious a to why you get file not found.

 

Have you tried an ls command just before the chainloader command - e.g.

.....
# hd1 is now hd0   and  hd0 is now hd1
root (hd0,0) || rootnoverify (hd0,0)
ls (hd0,0)/
pause
ls /minint/
pause
chainloader (hd0,0)/minint/setupldr.bin

It should list the correct files. If not try using ls  on other drives/partitions.



#16 Kirkx

Kirkx

    Member

  • Members
  • 31 posts
  •  
    Canada

Posted 25 January 2015 - 12:04 PM

Thanks Steve. I finally had some time to look at it again.

It seems that hard disk's first sector does not make any difference for the map command after all. I have just re-aligned my Disk #2 to 1 MiB so the disks look as follows:

- Disk #1 is aligned to CHS: (hd0,0) starts at sector 63

- Disk #2 is aligned to 1 MiB: (hd1,0) starts at sector 2048

 

Chainloading BartPE works ok as long as it is initiated form Grub4Dos bootlaced to (hd0,2).

Chainloading BartPE does not work if it is initiated from Grub4Dos bootlaced to (hd1,0).

 

I think we can consider this thread "solved" and I will open another thread with the title that properly describes the actual problem:

Booting BartPE from Grub4Dos bootlaced to a second disk:
 

http://reboot.pro/to...-a-second-disk/


Edited by Kirkx, 25 January 2015 - 12:06 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users