Im doing unattended installs from WinPE and I have a need to write a fresh MBR during the process. Anyone know of a tool that runs inside of WinPE that will do this?
thanks!
Gdisk32.exe from Norton Ghost should do the trick.
http://service1.symantec.com/SUPPORT/ghost.nsf/docid/2000030715304425/
The Powerquest (now symantec) PQI Deploy Toolkit has a tool that will do it.
If you are doing Xp, then Ghost is fine. But if you are doing servers... you'll need adifferent tool. Ghost is not supported on servers.
Chris
fdisk /mbr will do the trick.
If you want something that's already integrated with WINPE then you can use Diskpart's CLEAN command.
Diskpart /s foo.txt
<foo.txt>
sel dis 0
clean
ce par pri
active
assign
</foo.txt>
Upside: known good state to start your deployment/install
Downside: It destroys all partitions/data on the drive, so keeping existing data won't work.
...Further upside: No additional tools required.
<sigh> Typed too fast. the foo.txt should read:
<foo.txt>
sel dis 0
cre par pri
active
assign
</foo.txt>
If the syntax looks weird, note: Diskpart accepts the first three letters of most commands in place of the full command.
select disk 0 == "sel dis 0"
create partition primary == "cre par pri"
etc..
I ended up in the same problem, but my experience is that the diskpart command doesn't insert the boot code into the MBR. That it leaves for the setup program.
I was using Win PE to create a primary partition on a disk, acitvate, assign it. Then formatted using format C: /fs:ntfs.
Lastly copying in a Windows Embeded XP installation to C:.
Would not boot, just booted to a black screen without any errors, hanging around
So it seems that diskpart does not insert the bootcode into the MBR, just defines the partitions.
fdisk /mbr wont work since it is a DOS (heaven forbid) utility.
I found some info on the Internet and set out to make my own utility to write boot code into the MBR. Was finished after a few hours, yesterday.
The utility is written for Win PE, and is tested in Win XP and Win PE. Should work with any version above NT 4.0, including W2K, Win 2003, XP.
Commands:
I know alot of people will be happy to have this functionality inside PE. Thanks!
This looks to be a great program! I know it would have been handy for me the other week. I will definately try it and give some info on it. Thanks again, hope to see more of you in the forums.
I use one that we wrote internally as well (sick options and functionality) but corporate guidelines prohibit the distribution of the app.
Chris
kaares,
very good tool, I made a few tests with it and it works like a charm.
I did my test on win2k.
I think it deserves to get "in the open".
Can you host it on some web page?
Or would you allow me to host it on mine?
I am going to write down a pseudo-GUI for it, I'll post it here as soon as it is done, but I would like to put it on my page together with your prog.
Here is a link to the other pseudo-GUI I have written:
http://home.graffiti.net/jaclaz:graffiti.net/Projects/VDM/vdm.html
Cheers,
jaclaz
@jaclaz
Nice idea to create a small GUI. Let us know when it's ready.
Have you sent a PM to kaares for hosting his tool ?
I'm not sure he will read your proposition on this forum. Only 2 posts 'til he joined MSFN.
OK, guys, here it is:
MBRfix GUI.
Enjoy!
jaclaz
Gotta love corporate policy, I know I do.
Boot from a 98 boot disk or the windows 98 cd and run fdisk /mbr. Way easier than learning new utils.
@jaclaz
I really like all the answers you give to us. There are well documented and you don't forget to add link for valuable infos.
Great !
thank you kaares for mbrfix. great tool. I made small launcher-gui with vb6 for BartPE.
see next post
@dman
What is the
Run-time error '380':
invalid property value
I would like to try your GUI under Windows 2000.
comdlg32.ocx is in my %systemroot%\system32 dir and is registered.
Run-time error '53'
The version of vmbrfix.exe and bat file I posted last night has hard coded paths specific for BartPE. I changed to relative pathing so you should be able to run from anywhere now (must be in path with no long directory names, though), and "should" work under win2k. please let me know.
dman
reposted 2-02 3:15pm - several small changes
reposted 2-02 6:17pm - added "about" box
reposted 2-03 9:25am - added error handler
sorry still Run-time error '53'
that is "file not found" error. when does it occur? what platform are you running? is mbrfix.exe in the dir? any details will help.
Also, put it in a path that has no long directory names (like not on the desktop). shellexecute may have trouble with dir names longer than 8 chars.
see edited post above. must not be in dir path with long names
My pleasure!
I just uploaded a new version of MbrFix. See first page of this thread.
You may also download the utility from this address:
http://www.sysint.no/Nedlasting/MbrFix.zip
Thanks again kaares, nice job.
Just for quick reference:
using the fixmbr utility posted (that was updated september 2005) would the
command "MbrFix /drive 0 fixmbr /yes" be equilvant to the dos command "Fdisk /mbr"?
Exactly, by using the /YES switch the FDISK /MBR is replicated.
The only difference is that the MBR code on win9x/ME (FDISK) system is slightly different from the Win2k/XP/2003 (MBRFIX) one.
jaclaz
Ok, here (attached) is the updated Pseudo-GUI.
You will need, apart from the files in the attachment, the program from Kaare:
http://www.sysint.no/Nedlasting/MbrFix.zip
And the Wizard's Apprentice WIZAPP.EXE:
http://wizapp.sourceforge.net/
Copy all files to the same directory, rename mbrfix.txt to mbrfix.cmd and double click on it.
A mirror of my pseudo-GUI file is here:
http://home.graffiti.net/jaclaz:graffiti.net/Projects/MBRFIX/mbrfix0.2.zip
Let me know if you find any bugs/problems.
jaclaz
hi guys,
i have prob with my WD Caviar 80G.B H.D.D when try to test it with some pprograms i got message that
it is no MBR or damage in MBR can me copy MBR from onther one ?
i want to safe my data on this hdd
Plz help???
Jaclaz,
I have seen from you posts on various forums that you are obviously an MBR wiz and I am having a problem.
I followed your instructions in this thread and this is what is reported:
Drive 1
Disk size = 131069 (MB)
Cylinders = 16709
Tracks per cylinder = 255
Sectors per track = 63
Bytes per sector = 512
Disk size = 137436203520 (Bytes) = 127 (GB)
# Boot Size (MB) Type
1 Yes 190779 7 NTFS or HPFS
2 0 0 None
3 0 0 None
4 0 0 None
My system has two hard drives. For some reason drive 0 is my secondary (non boot) drive. It is a sata 320 gb drive connected to the mainboard.
My drive 1 as seen above is my boot drive. It is a 200 gb ide attached to a western digital controller card.
When the machine boots up the controller card reports 186 gb. Windows recognizes all 186 gb as well. But Norton Ghost says Cannot enable the job because it contains invalid drives. Norton Partition Magic reports Error #109: Partition ends after end of disk.
ucEndCylinder (24320) must be less than 16709.
I looked up the error on Symantec support and they say it's either bios (seems to report 186 gb), controller card (no problem in past) or the MBR.
I have thought of running fixmbr but am reluctant to do so.
I tried to backup the mbr using your program. I tried to attach it to this post but was unable (error not permitted to upload a file with that extension).
I also tried to use TESTDISK as I saw that you recommended that to someone on another post.
It reports 137GB/ 127GiB CHS 16709 255 63. "The hard disk seems too small! Check the hard disk size" .
I tried to change the geometry but received an error message.
Can you please help me?
@Eyedoctor2
From what you report, it appears that you have somehow corrupted records, I have seen this hapen when a tool like Partition Magic or similar has been used and was interrupted, but it could be caused by almost anything.
It is possible that the drive was originally formatted under another operatig system or using a third party tool with full LBA support.
Let see things one by one.
As I see it, the fact that drive 0 is the one attached to mainboard, even if without active partition on it, is normal, I think that Physical drives enumeration is dependant on hardware connections, so I would not be preoccupied by that, it should be quite normal that the BIOS detects drives attached to mainboard BEFORE those attached to expansion cards.
From what you say, the data reported by Disk driver is CHS 16709x255x63, which would mean
16709x255x63x512=137,436,203,520 bytes
In a perfect word, with a NTFS primary partition spanning over the entire disk, you should have, as seen in beeblebrox (don't be afraid to use it, it won't make changes to MBR unless you tell it to do so):
You should have just one entry like these:
Jaclaz,
First thank you very much for replying.
I apologize for not including my OS- Windows XP SP2.
Running beeblebrox I get the exact values you listed except
Numsectors 390716802
I ran http://www.48bitlba.com/enablebiglbatool.htm and it said that since I have sP2 that it passed and there was nothing to do.
Should I purchase the infotool?
You are correct that I have run Partition Magic several times in the past. The most recent time I used it to remove all partitions that I had previously made. I did so after purchasing the new 320gb sata hard drive.
Thanks again for your help!
Jaclaz,
Again thanks!
First, the Atapi.sys version is current.
Second, Windows does report the drive to be 186 gb. Just as it reports that my secondary hardrive is 320gb.
The problem is with partion magic, testdisk and beeblebrox all report it to be 131+gb.
I know that this is a new problem because previously Norton Ghost and Partition Magic worked fine without any reported errors. I have at this time a backup created by Norton Ghost 77 days ago but hate to go back that far as I am always making changes. I thought that all this time Norton Ghost had been making automatically scheduled incremental backups. I didn't realize the problem until I tried to use Ghost to create another full backup.
I believe the problem started after removing the partitions in the C (200gb) drive with partition magic. I have contacted symatec support but am still waiting to hear back from them.
I am not at home so I can't try the other utilities that you suggest. I will try tonight.
Is there a software program that I can use to correct the partition size without losing the data on the hard drive?
Thanks again!
I will run chkdsk when I get home.
I previously ran chkdsk /r and chkdsk /p and it reported uncorrectable errors.
Would it help at all if I opened up the box and connected the hard drive directly to the motherboard, temporarily disconnecting my dvd and dvdrw drives?
My reluctance to blame the controller card stems from the fact that when the card bios screen flashes up at the beginning it detects a 186 gb drive. Also, Norton Ghost previously ran with this controller card though I did not have the sata drive attached to the motherboard at that time.
History- I previously had the 186gb ide drive partitioned and was saving backups via Ghost on one partition. The hard drive was on the controller card and the dvd and dvdrw were on the motherboard along with a cdrw drive. I then purchased the sata drive, removed the partitions on the 186gb drive and removed the cdrw drive.
So presently sata drive is on motherboard, along with dvd and dvdrw. 186 gb ide continues to be on controller card.
I don't know if this information helps much but as an eyedoctor it never hurts to get a good medical history.
Thanks again for your willingness to help.
Edit:
RESULTS OF CHKDSK
I am going to include 3 gifs with this post.
First is screenshot of chkdsk
Second is Norton Partition Magic summary screen
Third is error message given when trying to resize using Norton Partition Magic.
Hope that helps!
Thanks again!
I have not much ideas left:
1) Chkdsk sees the partiiton allright ÷190Gb
2) Windows Explorer ALSO sees it allright ÷190GB
3) Norton Partition Magic ALSO sees it allright ÷190GB
4) The error comes when you try to resize it
That MUST be because somehow the disk (not the partition) is seen as having 16709 Cylinders, i.e. 132 Gb, and this happens with:
a ) MBRFIX
b ) TESTDISK
c ) BEEBLEBROX
d ) NORTON PARTITION MAGIC
Results 1) to 3) are normal as to read information on the partition the MBR is read, which as said, is correct.
Results 4) and a ) to d ) are also all coherent as to read information on the drive geometry the disk driver is interrogated, which actually interrogates the hard disk.
So something must be wrong in
EITHER:
1) the information the hard disk supplies, and this can be only be attributed to:
1a ) a jumper setting on the hard disk
1b ) a jumper or setting in the card or its BIOS
1c ) a setting in the motherboard BIOS that somehow "overrides" board one, though I doubt it
OR:
2) the information the disk driver is correct, but it is badly "translated", and this can be only attributed to:
2a ) a defective driver (disk, card or bus)
2b ) a "hidden" setting or filter somewhere that "overrides" the right values
From the "history" you supplied, the only other thing I can fathom is some kind of conflict with the SATA drive, so, yes, trying the drive hooked directly to the board would be a good troubleshooting step, though cannot say how many "good" info we can get from that.
I would suggest the following:
1) just remove the SATA drive leaving everything else as is, run said apps to check if anything changed
2) remove DVDR leaving everything else as is, run said apps to check if anything changed
3) remove DVDRW leaving everything else as is, run said apps to check if anything changed
4) attach 186 Gb drive directly to MB leaving everything else as is, run said apps to check if anything changed
5) remove the card, run said apps to check if anything changed
6) re-insert card and attach to it 186 Gb drive, run said apps to check if anything changed
7) re-connect just the SATA drive, run said apps to check if anything changed
8) re-connect DVDRW leaving everything else as is, run said apps to check if anything changed
9) re-connect DVDR leaving everything else as is, run said apps to check if anything changed
jaclaz
SUCCESS!!!!!!!!!!!
Thank you so much jaclaz!!
I was able to correct the error by connecting the 200 gb hard drive directly to the motherboard, whether or not the SATA drive was also connected.
Also had no problem if the 200gb drive was on the motherboard, SATA was disconnected and dvd drives were connected to the motherboard.
But when I reconnected the 200gb card to the ide controller card the problem recurred.
I looked up the drivers that the card was using and for some CRAZY reason Windows XP2 was using the older of the two available drivers. When I switched to the newer driver.......
SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I can now go back to using Norton Ghost to backup my C: drive.
Thanks so much for your help!
Have a great Thanksgiving.
God bless,
wz
Happy it worked!
Have a nice thanksgiving !
jaclaz
jaclaz, (my 1st post in this forum) almost a year after the last post in this topic, this wonderful utility is still saving people. I used it to remove System Commander 7 from the MBR and subsequently uninstalled sc7, so that my WinXP boots normally. Now I can install Ubuntu along side WinXp
...thx chris
Is it possible just to restore the boot code from a file?
I think MbrFix can only restore the whole MBR or just fix the boot code for Win and DOS.
But I am searching for a solution to restore the first 446 Byte of the MBR (the boot code).
Maybe it is possible to give MbrFix this feature. ![]()
Thanks
Godzilla
Have a look at both these batches:
http://www.boot-land.net/forums/MBRBatch-001-ALPHA-t3191.html
http://www.boot-land.net/forums/MakeBScmd-ALPHA-RELEASE-t2362.html
You should get enough info to write a few lines of batch to use dsfo/dsfi to perform what you want, or you can do it manually, see here:
http://www.boot-land.net/forums/index.php?showtopic=3226&st=15
and just use "446" instead of "512".
jaclaz
Great.
I will look at it.
thanks for the zip file!
![]()
jaclaz
You can use bootsect.exe (on the vista install disc and maybe the WAIK) to generate the mbr boot code. Just remember to pass it the right switch depending on which os you're booting (xp,2003 or Vista,2008).
Cheers
MBRFix.exe has been updated.
v1.3.0.0 changelog
GOOD news. ![]()
Unrelated, but not much, fuwi has recently released a small GUI for it:
http://www.911cd.net/forums//index.php?showtopic=23189
I'll notify him and see if he will update it with the Windows 7 feature.
jaclaz