Managing MBR's by jaclaz MBRBatch Release 0.01 ALPHA
This tutorial is based on information given by "jaclaz" in link below.Thanks jaclaze for
One that works in boot projects needs to have informations about MBR ,savingit,changing
that and ...to be able to work by various OS's,boot loaders,and else
He needs to make several images to test his ideas and realy should work hard and hard
to exprement new things and make new methodes.
To help this kind of users , jaclaz has made an small nice script, that works fast and
safe with few small free files,and by using that you can do a lot of operations fastly
and easy for example:
save MBR code of disk or an mbr file.
Copy MBR code of disk or an mbr file to another file.
Can write the MBR code of source file to destdrive.
Creates MBR from a 2k/XP file saving it as targetfile.
Show partition entries in source MBR(either a MBR file or a drive).
Edit one partition entry in MBR file.
Patches sourcefile with "HP" USB/int13 modification.
create HD like images of arbitrary size and to format them with various geometries.
In this small tutor I just have put together informations from link above,In other
words i have just bring you files needed,and some descriptions of commands by examples
for each command.
All You need at this time is to Download MBRBatch.zip from attachment ,extract that
some where .Contents of MBRBatch.zip are as below:
mbrbatch.cmd ( mbrbatch002)
Now you can go to cmd prompt and use commands in next paragraph to do your works.
Only Note that:
1.All commands must be DOS 8.3 format and using spaces in names and else are not allowed.
2.When using syntaxes,[source] can be a file or a drive number, [sourcefile] must be
a <=512 bytes file.source can be ANY file or PhysicalDrive number, the batch extracts just
the first 512 bytes of "source".if "source" does not has a MBR as first sector, results of
the VIEW command will be pretty much garbage.Drive numbers begin with 0.
3.When using syntaxes,[target] can be a file or a drive number, [targetfile] must be a NEW
file .If any non-optional parameter is missing, it will enter interactive mode.
4.In general syntax,first argument passed to the batch is ALWAYS a COMMAND, second and
further arguments are ALWAYS [parameters].
Hope if i had missed some thing or had any mistake,jaclaz will help.
Commands and Examples
The general syntax is: MBRBATCH COMMAND [parameters]
Commands and examples:
MBRBATCH COPY source targetfile length
Copies length bytes from source, saving it as targetfile
mbrbatch copy xxx.bin yyy.bin 512
will make yyy.bin and will copy xxx.bin code on it.(see pic_b from attachment)
here xxx.bin is a mbr file that you had placed in the same directory as
mbrbath file,and yyy.bin will be made in this directory too.
mbrbatch.cmd COPY C:\MBRBATCHDIR\my_MBR.mbr C:\ANOTHERDIR\SomeMBR.bin
mbrbatch.cmd COPY 0 my_MBR.mbr
MBRBATCH WRITE source target [/F]
Simply writes the MBR code of source file to destdrive.For security reasons, if you input
first disk, i.e. 0, you NEED to add the parameter /F (for FORCE) when mbrbatch.cmd is
invoked from command line or from amother batch.In interactive mode, a confirmation will be
C:\MBR>mbrbatch write xxx.bin zzz.bin
writes from xxx.bin to zzz.bin (see pic_c from attachment)
mbrbatch.cmd WRITE C:\A_directory\my_MBR.mbr 1
will write contents of file my_MBR.mbr (512 bytes) to \\.\PHYSICALDRIVE1
mbrbatch.cmd WRITE C:\A_directory\my_MBR.mbr 0 /F
will write contents of file my_MBR.mbr (512 bytes) to \\.\PHYSICALDRIVE0
MBRBATCH HELP command
Displays help for the given command
mbrbatch help copy
will show help for copy command (pic_d)
MBRBATCH CREATE targetfile
Creates MBR from a 2k/XP file saving it as targetfile.
MBRBATCH VIEW source
Shows partition entries in source MBR.Source can be either a MBR file or a drive number.
Drive numbers begin with 0.
mbrbatch view xxx.bin 512
will show as pic_a from attachment
mbrbatch.cmd VIEW C:\MBRBATCHDIR\my_MBR.mbr
mbrbatch.cmd VIEW 0
MBRBATCH EDIT sourcefile [params]
Edits one partition entry in MBR file.Source can be ONLY a MBR file (CREATEd or COPYed).
This command is compex.run "mbrbatch help edit" to see more help
mbrbatch.cmd CHANGE my_MBR.mbr 255/63 1 0B 80 CHS 0 1 1 127 254 63
mbrbatch.cmd CHANGE my_MBR.mbr 255/63 1 0B 80 LBA 63 2056257
MBRBATCH UPATCH sourcefile
Patches sourcefile with "HP" USB/int13 modification. sourcefile (MBR) must contain
2K/XP/2003 MBR code).Simply changes the MBR code of source file to skip Extended INT13h
checks, exactly as the DataSystem/HP utility does.This is only worth a try if you are
managing a MBR on a USB Mass Storage Device, be it an external hard disk or Flash memory
device, and only if the drive does not boot on a certain type of motherboard with the
normal MBR, i.e. the one you can CREATE with this batch.
mbrbatch.cmd UPATCH C:\A_directory\my_MBR.mbr
by typing this command it will:
1) asks for a file name (for the moment use the same directory where the script and all
2) asks for an image size in bytes, Kbytes, Mbytes or Gbytes
3) asks for the desired geometry
4) asks for the desired Partition (filesystem) type
5) asks whether you want to use the (default) mksparse.exe to create a sparse image or
fsz.exe to create a full image
6) creates the image
7) autocalculates partition table entries to create the single biggest possible partition
for given image size and creates a MBR with this data and 2K/XP MBR code
8) copies this MBR to the image
9) mounts the image with VDK and formats it using "standard" FORMAT
10) opens with Explorer the freshly mounted Virtual Disk
The script works both in interactive mode and invoked from command line with all parameters,
in this case it accepts a further switch "/np" for "NO PROMPTS" that COMPLETELY REMOVES any
confirmation to delete existing files and to format the Virtual Disk.
have nice times
hope that jaclaz will complete tutor