1

Is there any way to erase the partition table in MS-DOS? I've tried looking at the fdisk command, but that is an interactive interface. I want a single command that does not show any output and doesn't need user input.

2

MS-DOS comes with a program called debug. Instructions for using it to erase the MBR interactively can found in many places, and the same input can be fed from a file using debug < script.txt.

Note: This erases the whole MBR – partition table and boot loader code.

Copied into a script file, the same commands would look like:

f 9000:0 200 0            ; zero out 512 bytes at 0x9000:0x0000
a                         ; enter assembly mode
mov dx,9000               ; dx=0x9000
mov es,dx                 ; es=dx
xor bx,bx                 ; bx=0x0000
mov cx,0001               ; ch=0x00 (track#) cl=0x01 (sector#)
mov dx,0080               ; dh=0x00 (head#) dl=0x01 (drive#)
mov ax,0301               ; ah=0x03 (write sectors) al=0x01 (sector count)
int 13                    ; INT 13h BIOS disk access
int 20                    ; INT 20h exit program
                          ; blank line
g
q

Note: I suspect directly writing the zeroed memory to sector 0 using the "write sectors" command would be much simpler than running custom assembly code, but I don't actually have a MS-DOS system around to test this.

f 9000:0 200 0            ; zero out 512 bytes at 0x9000:0x0000
w 9000:0 1 0 1            ; write 1 sector to drive 1
q

See also: More information about how to use DEBUG.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.