Computing.Net > Forums > Disk Operating System > automate fdisk

automate fdisk

Reply to Message Icon

Original Message
Name: uli_glueck
Date: July 27, 2005 at 02:43:04 Pacific
Subject: automate fdisk
OS: WInNT / MS-DOS
CPU/Ram: PIII 256MB
Comment:

I have to delete and create partitions with fdisk at a number of pcs. (always the same).
(I use a MS-DOS 6.22 Bootdisk.)
So I tried to make a txt file to control fdisk.
It seems to work until fdisk asks me to hit the ESC key.
How can I "write" the ESC Command in a txt file?

thanks in advance for any help
uli


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: July 27, 2005 at 03:45:09 Pacific
Reply: (edit)

I wrote some BATs for w98 DOS [even though some here we tell you ad nauseum that it does not exist] which might work in 6.22 with some tweaking.

The relevant lines are:

if %1!==! FDISK 1/PRI:22222
if not %1!==! FDISK 1/PRI:%1

If no parameter is passed, it creates a primary partition of size 22222. If the disk is smaller than the 22222 it uses total capacity.

In 6.22 it may not 'roll back' to 2048, so you mau need to hardwire it.

I also have a BAT to nuke existing partitions, if you need it.

HTH


M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: uli_glueck
Date: July 27, 2005 at 05:18:25 Pacific
Reply: (edit)

Thanks M2

I can also use the Win98 Dos Version.
I need the BAT to nuke existing Partitions also.

What I have to do is:

Delete 3 partitions
Create a partition
format the HD

Deleting 3 partitions with fdisk is not funny
all the time.

uli



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: July 27, 2005 at 05:43:51 Pacific
Reply: (edit)

Hi uli,

Put this into a text file; let's call it nuke.d:

::== nuke.d
f 200 L200 0
a 100
mov ax,301
mov bx,200
mov cx,1
mov dx,0080
int 13
int 3

d 100 LF
g=100
q

::== make sure that there is a blank line [enter] below the q ; or else debug will hang

Then in your BAT to wipe all partitions:

debug < nuke.d

WARNING: this is not a toy. It will wipe out everything on the first, or only, IDE HD.

HTH

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 4
Name: uli_glueck
Date: July 28, 2005 at 00:46:50 Pacific
Reply: (edit)

Hi M2

Thank you very much. It works perfect.
Thats what I need. :-))
I don“t really understand how it works.
Only that it overwrites data from Adress 200 with 0.
So any information is lost.

Uli


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: July 28, 2005 at 00:53:26 Pacific
Reply: (edit)

Hi uli,

It uses BIOS to write to absolute disk sectors.

It writes 0s to the first 200 hex [512 decinal] bytes. That's where the partition table is.

[was]

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal


Response Number 6
Name: MercadianDragon
Date: August 10, 2005 at 12:29:52 Pacific
Reply: (edit)

Hi Mechanix2Go

I see that this thread is fairly recent. Which is good :). Ok, well I found this site searching for something regarding an FDISK automation, and found your partionion nuker, I copied it into a text file and booted up old faithful virtual machine, ran it and it worked, however it gives me a bad partition table when I try format the drive. Do I still need to use fdisk to partion it? If so, how would I get a working fdisk script? Mine hangs after creating partition.Maybe doing something wrong :(


... Ahh yes, but is it art?


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: August 10, 2005 at 12:45:51 Pacific
Reply: (edit)

Hi M D,

As mentioned above, the different versions of fdisk may behave differently.

What version are you using and where does it hang?

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 8
Name: MercadianDragon
Date: August 11, 2005 at 04:40:01 Pacific
Reply: (edit)

Hi Mechanix2Go

Well, fdisk hangs when I try use a script. It goes in and does it's then, but doesn't exit fdisk like it should. the FDISK version is what comes with Dos 6.22. I thought that I could maybe use the partition nuker to nuke all drives and then format without rebooting. But it doesn't seem to work :(. It does however give me an error before it starts tho. Below is the out put:

::== nuke.d
^ERROR
f 200 L200 0
a 100
mov ax,301
mov bx,200
mov cx,1
mov dx,0080
int 13
int 3

d 100 LF
g=100
q

::==

I tried using an alternative to normal fdisk called ffdisk and the script also hangs it. but I can go in and do it manually whereas the dos 6.22 version of fdisk just doesn't go in. :(.

... Ahh yes, but is it art?


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: August 11, 2005 at 04:59:50 Pacific
Reply: (edit)

Hi M D,

I'm not with you.

First you need to remove all partitions like this:

debug < nuke.d

Can you get that far?

M2
If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 10
Name: MercadianDragon
Date: August 11, 2005 at 07:50:42 Pacific
Reply: (edit)

Hi

Yeah the script runs and removes all partitions. Then when I try and format it says "Invalid partition table".

Then I try running fdisk >fdisk.txt which contains the script to recreate a partition and it hangs at the end. Sorry for it being so confusing.

... Ahh yes, but is it art?


Report Offensive Follow Up For Removal

Response Number 11
Name: Mechanix2Go
Date: August 11, 2005 at 23:43:12 Pacific
Reply: (edit)

"Then I try running fdisk >fdisk.txt which contains the script"

That is not what you need. You need this BAT:

::== makepart.bat
if %1!==! FDISK 1/PRI:22222
if not %1!==! FDISK 1/PRI:%1
fdisk /status
::== end

Reboot before attempting to format the new partition.

M2
If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 12
Name: MercadianDragon
Date: August 11, 2005 at 23:51:23 Pacific
Reply: (edit)

Thanks. Will try it out tonight. I appreciate the help.

... Ahh yes, but is it art?


Report Offensive Follow Up For Removal

Response Number 13
Name: wizard-fred
Date: August 11, 2005 at 23:58:16 Pacific
Reply: (edit)

Maybe using something like ghost would be more productive partition and install the software in one step.


Report Offensive Follow Up For Removal

Response Number 14
Name: uli_glueck
Date: August 19, 2005 at 01:44:30 Pacific
Reply: (edit)

Sorry I am a bit late, have been on holidays. :-))

With FDISK in MS-DOS 6.2 you can only make 2GB Partitions:

FDISK 1/PRI:2222
then reboot and
format c:

My "new" question: Is it possible to pick up the following line of a Batch-Script after a reboot? (That I can make a partition and format it in one Script.)

uli


Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: August 19, 2005 at 02:51:23 Pacific
Reply: (edit)

Hi uli,

Well, to let the BATCH know what stage it's at and have it go to the
appropriate step, you need to "leave a marker".

Something like this:

::== your.bat
if exist nuked goto :makepart
if exist partmade goto :format
:: == here's the nuke section
nuke
type nul > nuked
goto :eof
:: ==
:nuked
del nuked
:: == here's your makepart section
makepart
type nul > partmade
goto :eof
:format
del partmade
format

:eof

M2
If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 16
Name: uli_glueck
Date: August 19, 2005 at 06:13:05 Pacific
Reply: (edit)

Hi M2,

thank you very much. Now it works.

nukes
creates
reboot
format

all in one batchfile. That save me lots of time and nerves. ;-)

uli


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: automate fdisk

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge