Jump to content











Photo
- - - - -

Grub4dos SetPtn1.g4b batch file - sets a primary partition as 1st entry

flash drive multiple partitions change

  • Please log in to reply
8 replies to this topic

#1 steve6375

steve6375

    Platinum Member

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

Posted 08 June 2013 - 04:26 PM

Attached is a grub4dos batch file that allows the user to set any 1 of the 4 primary partition entries as the first entry in the partition table.

This allows any one of the four partitions on removable media such as multiple partition USB flash drives or SD cards, to be set as the Windows visible 1st partition.

 

I have 'borrowed' the ViewMBR code from jaclaz/WKS and added some extra code to do the partition table swap.

 

To see the usage type SetPtn1.g4b in the grub4dos console:

 

SetPtn1.g4b (hd0)               - prompts user for partition to set as first ptn
SetPtn1.g4b (hd0) 1            - swap 2nd ptn with first ptn + user must confirm
SetPtn1.g4b (hd0) 1 SURE - no confirmation prompt before updating MBR

 

You can add this to your grub4dos multiboot menu if you have a multipartition USB flash drive and want to boot Windows or WinPE from the 2nd, 3rd or 4th partition. Use with care as this will overwrite the MBR!

Attached Files



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14833 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 08 June 2013 - 04:54 PM

What can I say?

eeeeeeeeeeeeeeee

eeeeeeeeeeeeeeee

;)

 

Very nice work! :thumbup:

 

:cheers:

Wonko



#3 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 08 June 2013 - 05:28 PM

You can add this to your grub4dos multiboot menu if you have a multipartition USB flash drive and want to boot Windows or WinPE from the 2nd, 3rd or 4th partition. Use with care as this will overwrite the MBR!

 

If I have understood correctly, it can be a permanent substitute (precisely, a modification which'll persist across reboot) of

 

 

map (hd0) (hdX)

map (hdX) (hd0)

map --hook



#4 steve6375

steve6375

    Platinum Member

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

Posted 08 June 2013 - 05:36 PM

no

it re-arranges the four ptn table entries in the MBR of a single disk.

 

If you have a USB flash drive, Windows will only access the first entry in the ptn table. So if you had a USB flash drive like:

 

ptn 0 - FAT32 - grub4dos - MS-DOS

ptn 1 - NTFS - ntldr - Windows XP

 

If you try to boot to XP on ptn 1, it will crash as Windows cannot see the 2nd ptn when it starts to boot (same for Vista/7/8).

 

So this utility re-arranges the table:

 

ptn 0 - NTFS - ntldr - Windows XP

ptn 1 - FAT32 - grub4dos - MS-DOS

 

 

so now you can boot to XP.

title boot from XP on 2nd ptn
/SetPtn1.g4b (hd0) 1 SURE && root (hd0,0) && chainloader /ntldr
boot

 

Of course, the change will be permanent. On the NTFS XP ptn 1 you could also have grub4dos installed and a menu.lst which can have a similar menu option:

title Run grub4dos menu on FAT32 partition \n
/SetPtn1.g4b (hd0) 1 SURE && root (hd0,0) && configfile /menu.lst
boot

title Boot XP
chainloader /ntldr



#5 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 08 June 2013 - 05:43 PM

title boot from XP on 2nd ptn
/SetPtn1.g4b (hd0) 1 SURE && root (hd0,0) && chainloader /ntldr
boot


How is it different from

title boot from XP on 2nd ptn
map (hd0) (hd1) 
map (hd1) (hd0) 
map --hook
root (hd0,0) 
chainloader /ntldr
boot


#6 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 08 June 2013 - 05:44 PM


How is it different from

title boot from XP on 2nd ptn
map (hd0) (hd1) 
map (hd1) (hd0) 
map --hook
root (hd0,0) 
chainloader /ntldr
boot

 

Sorry, I re-read your post and just understood. Nice idea Steve



#7 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 08 June 2013 - 05:47 PM

But isn't there a better way to hook INT 13 from within G4D to advertise a modified partition table to the OS (i.e. Windows) without actually touching it?



#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14833 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 08 June 2013 - 05:58 PM

Nice idea Steve

Well, with all due respect :), not really a "new" one ;):

http://www.911cd.net...showtopic=24392

Meet CHPTNORD.CMD:

http://www.911cd.net...pic=24392&st=18

and USB_Part_Flip.exe

http://www.911cd.net...pic=24392&st=20

 

JFYI, the point is not about grub4dos (or DOS or any Linux) it is only about Windows (of the NT family) WITHOUT a filter driver installed.

Windows re-reads the first sector of the device at boot, and if it senses that the device is "removable" it will allow accessing to only the first (primary) partition.

 

:cheers:

Wonko



#9 steve6375

steve6375

    Platinum Member

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

Posted 08 June 2013 - 06:33 PM

But isn't there a better way to hook INT 13 from within G4D to advertise a modified partition table to the OS (i.e. Windows) without actually touching it?

The partition table must be re-written - when Windows (XP/Vista/7/8) goes into protected mode, any patching done by grub4dos is thrown away and protected mode drivers are used which will access the MBR directly.







Also tagged with one or more of these keywords: flash drive, multiple partitions, change

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users