old-www/LDP/LG/issue63/okopnik.html

145 lines
7.9 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>Clearing out the Master Boot Record (MBR) LG #63</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<CENTER>
<A HREF="http://www.linuxgazette.com/">
<H1><IMG ALT="LINUX GAZETTE" SRC="../gx/lglogo.png"
WIDTH="600" HEIGHT="124" border="0"></H1></A>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="nielsen3.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue63/okopnik.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="sharma.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
<P>
</CENTER>
<!--endcut ============================================================-->
<H4 ALIGN="center">
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">Clearing out the Master Boot Record (MBR)</font></H1>
<H1>--Danger, Will Robinson!</H1>
<H4>By <a href="mailto:ben-fuzzybear@yahoo.com">Ben Okopnik</a></H4>
</center>
<P> <HR> <P>
<!-- END header -->
Experimentation is fun. After all, one of the things that makes Linux
so interesting to a number of people is the ability to twiddle settings
and see what happens - I'll admit that it's a major factor for me. One
of the problems with that, though, is that some types of twiddling can
lead to <EM>serious</EM> problems. A bit like sawing off the branch you're
sitting on, in fact...
<p>A number of people write to the Answer Gang with a query that goes something
like this:
<BLOCKQUOTE>
"Dear TAG: I have a stick of dynamite strapped to the CPU, and I'm not
afraid to use it. Now that I have your undivided attention: I ran into
a problem while trying to reinstall..."
</BLOCKQUOTE>
<p>What it turns out to be - after the police, the fire department, and
the burly men in the white coats have come and gone - is that they've run
into the classic "fried MBR" problem: install Linux, realize that Windows
will screw up the boot record, delete the Linux partition, try to install
Windows first... OOPS. The Windows setup runs into a problem and stops.
<p>The reason for all of the above is that they forgot to uninstall LILO,
which would have written out the original MBR; as it is, the boot code
in the MBR is trying to pass control to the Linux kernel - and that's no
longer there.
<p>Nothing helps. The undocumented "fdisk/mbr" option that is supposed
to write a clean Master Boot Record seems to have no effect; "fdisk" in
interactive mode refuses to delete the "Non-DOS" partition; even the detonator
fails to explode. What to do, what to do...
<p>By the way, a factor in the first two problems might be the Windows
"lock" command - by default, 'raw writes' to disk are disallowed, and "lock
c:" 'locks' the drive to allow writing to it. (For the last problem, stick
to the bridge-wire type detonators from Dynamit Nobel, and store them
<br>properly. :)
<br>&nbsp;<b><tt><font size=-1></font></tt></b>
<p><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; Note: The following advice
will <u>completely</u> wipe your Master Boot Record,</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; which contains all your partition
information. DO NOT DO THIS unless you</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; know that this is exactly the
result you want - it will leave your HD in</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; an unbootable state, in effect
bringing it back to "factory-fresh", i.e.,</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; empty of data and requiring
partitioning and formatting.</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *</font></tt></b>
<br>&nbsp;<b></b>
<p><b>Linux-based solution</b>
<p>If you can still somehow fire up Linux - say, via
<A HREF="http://www.toms.net/rb/">Tom's Root-Boot</A> floppy
- you can simply invoke "dd", like so:
<p><tt>dd if=/dev/zero of=/dev/hda bs=512 count=1</tt>
<p>Yep, that's it. That MBR is <EM>gone</EM>. Obviously, you have to be root
to do this.
<br>&nbsp;
<p><b>DOS-based solution</b>
<p>Boot with a DOS floppy that has "debug" on it; run "debug". At the '-'
prompt, "block-fill" a 512-byte chunk of memory with zeroes:
<p><tt>f 9000:0 200 0</tt>
<p>Start assembly mode with the 'a' command, and enter the following code:
<p><tt>mov dx,9000</tt>
<br><tt>mov es,dx</tt>
<br><tt>xor bx,bx</tt>
<br><tt>mov cx,0001</tt>
<br><tt>mov dx,0080</tt>
<br><tt>mov ax,0301</tt>
<br><tt>int 13</tt>
<br><tt>int 20</tt>
<p>Press &lt;Enter&gt; to exit assembly mode, take a deep breath - and press
"g" to execute, then "q" to quit "debug". Your HD is now in a virgin state,
and ready for partitioning and installation.
<p>Obviously, you have to be root... oh, oops. <b>Anybody</b> that walks
up with a DOS floppy can do this to your system in about a minute, including
boot time. Let's see; where was that article about securing your box, again?...
<H3>References</H3>
<p>The "dd" man page.
<p>DOS-based fix: Original idea and code by Mark Minasi, used for clearing
infected/damaged MBRs in a course of his that I used to teach; all code/command
modifications mine.
<!-- *** BEGIN copyright *** -->
<P> <hr> <!-- P -->
<H5 ALIGN=center>
Copyright &copy; 2001, Ben Okopnik.<BR>
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
Published in Issue 63 of <i>Linux Gazette</i>, Mid-February (EXTRA) 2001</H5>
<!-- *** END copyright *** -->
<!--startcut ==========================================================-->
<HR><P>
<CENTER>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="nielsen3.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue63/okopnik.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="sharma.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
</CENTER>
</BODY></HTML>
<!--endcut ============================================================-->