GDisk
Switches
Situation:
You want an introduction to using the GDisk switches.
Solution:
GDisk is a DOS program with seven main operations. This document describes
the options available for each operation. The seven operations are:
-
Display partition information (/STATUS)
-
Create a partition (/CRE)
-
Delete a partition (/DEL)
-
Activate or deactivate a partition (/ACT and /-ACT)
-
Hide or unhide a partition (/HIDE and /-HIDE)
-
Reinitialize the master boot record (/MBR)
-
Wipe the disk surface (/DISKWIPE)
These commands can be run from the DOS command-line or from a batch
file (/BATCH). In addition, GDisk provides help from the command-line.
Displaying GDisk help
General help is available by using the ? switch:
Help on a particular operation is available by using the switch
for the operation without additional parameters. The format of this command
is:
For instance, the following command displays information regarding
deleting partitions:
Using GDisk in batch mode
The batch mode switch, /BATCH, allows GDisk to perform multiple operations
with a single command. The operations can be specified interactively at
a DOS command-line, or they can be supplied in advance in a text file.
GDisk's batch mode uses the following command-line format:
gdisk [disk] /BATCH[:filename] [switch[switch...]]
-
Disk tells GDisk which fixed physical disk (1 through 8) the commands
apply to.
-
/BATCH tells GDisk that it will be executing multiple GDisk commands.
This command is optional.
-
Filename provides GDisk with the name of the text file that includes
multiple GDisk commands. If no filename is provided, GDisk prompts the
user (interactively) for the command-line parameters.
-
Switch lists the command-line parameters (switches). If the command-line
calls a batch file, the switches specified on the command-line are run
after running the commands contained in the batch file.
Specifying /BATCH commands interactively
Using the /BATCH command without the name of a text file allows GDisk
commands to be supplied interactively at a prompt. The command-line format
is:
gdisk [disk] /BATCH [switch[switch...]]
For instance, the following command will load GDisk, prompt the
user for additional commands, then wait for further input from the user:
Here is an example of how an interactive session might look. This
session creates an extended partition on the second physical disk.
C:\>gdisk /batch
Complete the following command (ENTER to quit):
>gdisk 2 /cre /ext
Partition Status Type
Volume Label Mbytes System Usage
2 *CREATED* EXT DOS
507.9
17%
>gdisk 2 /cre /log
Partition Status Type
Volume Label Mbytes System Usage
2
EXT DOS
507.9
17%
D: 3 *CREATED* LOG DOS Unformatted
507.9 FAT16 17%
Specifying /BATCH commands in a text file
Using the /BATCH command with the name of a text file allows GDisk
commands to be supplied without user intervention during GDisk operation.
GDisk opens the file and executes the commands within the file until all
commands have been executed or one of the commands encounters an error.
The command-line format is:
gdisk [disk] /BATCH [switch[switch...]]
-
The name of the text file must follow DOS conventions, but the filename
extension does not have to be TXT.
-
In the text file, GDisk ignores blank lines and lines starting with the
hash symbol (#).
-
If all the GDisk commands will operate on the same fixed physical disk,
specify the disk number on the GDisk command-line that calls the batch
file or on each line of the batch file.
-
If the GDisk commands will operate on the various disks, specify the disk
number on each line of the batch file. If there are additional switches
on the initial command-line (the one that calls the batch file), then also
specify the disk number on the initial command-line.
-
Command line arguments that apply to all of the batch commands can be specified
on the original command line. The lines in the batch file (or typed at
the prompt) are appended to the already partially formed command line.
-
A batch file can call another batch file.
Example of a batch file
The following command line runs the batch file two-new.gg to
perform GDisk operations on disk 2, without prompting for confirmation:
gdisk 2 /y /batch:two-new.gg
The file two-new.gg, with the following contents, deletes
all partitions and creates two new ones on the second fixed disk. The hash
marks (#) indicate remarks. Note that, in this example, the commands do
not specify the fixed disk on each line:
# Delete all partitions
/del /all
# Create a new FAT16 primary DOS partition and format it
/cre /pri /-32 /for /q
/cre /ext
# Create a new FAT16 logical DOS partition and format it
/cre /log /-32 /for /q
When GDisk runs, it appends the contents of the batch file to the initial
command line, performing each of the following commands in sequence:
gdisk 2 /y /del /all
gdisk 2 /y /cre /pri /-32 /for /q
gdisk 2 /y /cre /ext
gdisk 2 /y /cre /log /-32 /for /q
Nested batch files
A batch file can call another batch file.
For instance, the following command line calls the file std-init.gg:
Supposing the file std-init.gg contains the following lines, where
the digits 1 and 2 specify the disk number:
1 /batch:two-new.gg
2 /batch:two-new.gg
Then GDisk runs the commands contained in the file two-new.gg on
the first fixed disk, then on the second fixed disk, as follows:
gdisk 1 /y /del /all
gdisk 1 /y /cre /pri /-32 /for /q
gdisk 1 /y /cre /ext
gdisk 1 /y /cre /log /-32 /for /q
gdisk 2 /y /del /all
gdisk 2 /y /cre /pri /-32 /for /q
gdisk 2 /y /cre /ext
gdisk 2 /y /cre /log /-32 /for /q
Mixing interactive commands and text file commands
GDisk accepts the interactive /BATCH command and a text file /BATCH
command on the same command line.
For instance, the following command-line prompts for the number of the
fixed disk or disks to execute the commands in two-new.gg against:
gdisk /batch /batch:two-new.gg
The disk number can also be supplied in a text file. For instance:
gdisk /batch:disks.gg /batch:two-new.gg
Where the contents of the file disks.ggare the numbers of
the physical disks (each number on a separate line):
Switches for GDisk operations
Here are the GDisk switches, as provided by the Gdisk /? <operation>
command.
Gdisk /?
This command displays the command-line formats for the major Gdisk
operations:
gdisk disk /CRE {/PRI|/EXT|/LOG} [/SZ:mbytes] [/FOR [/Q] [/V[:label]]]
[/-32] [/-CE] [/X] [/Y]
gdisk disk /DEL {/PRI[:nth]|/EXT[:nth]|/LOG:nth|/P:partn-no|/ALL}
[/X] [/Y]
gdisk [disk] [/STATUS] [/RAW|/LBA] [/X] [/Y]
gdisk disk /ACT /P:partn-no [/X] [/Y]
gdisk disk /[-]HIDE /P:partn-no [/X] [/Y]
gdisk disk /MBR [/WIPE] [/X] [/Y]
gdisk [disk] /BATCH[:filename] [switch[switch...]]
gdisk /? [/CRE|/DEL|/STATUS|/ACT|/[-]HIDE|/MBR|/BATCH]
GDisk /? /ACT
This command displays the command-line format for the /ACT operation.
The /ACT command sets a partition to Active. The /-ACT command deactivates
the partition.
General command:
gdisk disk /ACT /P:partn-no [/X] [/Y]
-
disk The physical fixed
disk (1-8).
-
/ACT Set the active
partition.
-
/-ACT Deactivate the partition.
-
/P:partn-no The number of the partition to activate. Use /STATUS
to select the partition number.
-
/X Ignore
extended disk-access support.
-
/Y Suppress
prompting to confirm you wish the action to be performed. /SURE has the
same meaning.
GDisk /? /CRE
This command displays the command-line format for the /CRE operation.
The /CRE command creates fixed disk partitions and logical drives.
General command:
gdisk disk /CRE {/PRI|/EXT|/LOG} [/SZ:mbytes] [/FOR [/Q] [/V[:label]]]
[/-32] [/-CE] [/X] [/Y]
-
disk The physical fixed disk
(1-8).
-
/CRE Create a DOS partition
or logical DOS drive.
-
/PRI Create a primary DOS
partition.
-
/EXT Create an extended DOS
partition.
-
/LOG Create a logical DOS
drive in the extended DOS partition.
-
/SZ:mbytes Specifies the size of the partition. Default is to
create a partition of the largest possible size.
-
/FOR Format the new partition
once it has been created.
-
/Q Perform a
quick format on the new partition.
-
/V[:label] Specifies the volume label. Default is no label.
-
/-32 Ignore large-disk support
(FAT32). Limits maximum size of new primary DOS partitions and logical
DOS drives to 2048 MB.
-
/-CE Ignore any free space
in the Customer Engineering (CE) cylinder.
-
/X Ignore extended
disk-access support.
-
/Y Suppress prompting
to confirm you wish the action to be performed. /SURE has the same meaning.
GDisk /? /DEL
This command displays the command-line format for the /DEL operation.
The /DEL command deletes fixed disk partitions and logical drives.
General command:
gdisk disk /DEL {/PRI[:nth]|/EXT[:nth]|/LOG:nth|/P:partn-no|/ALL}
[/X] [/Y]
-
disk The physical fixed
disk (1-8).
-
/DEL Delete a DOS partition
or logical DOS drive.
-
/PRI[:nth] Delete the 'nth' primary DOS partition (1-n).
Default is 1.
-
/EXT[:nth] Delete the 'nth' extended DOS partition. Default
is 1.
-
/LOG:nth Delete the 'nth' logical DOS drive
from the extended DOS partition (1-n).
-
/P:partn-no Delete any partition. Use /STATUS to select the number
of the partition to delete.
-
/ALL Delete all partitions.
-
/X Ignore
extended disk-access support.
-
/Y Suppress
prompting to confirm you wish the action to be performed. /SURE has the
same meaning.
GDisk /? /HIDE
This command displays the command-line format for the /HIDE operation.
The /HIDE command hides a regular partition or unhides a hidden partition.
General command:
gdisk disk /[-]HIDE /P:partn-no [/X] [/Y]
-
disk The physical fixed
disk (1-8).
-
/HIDE Hide a partition.
-
/-HIDE Unhide a hidden partition.
-
/P:partn-no The number of the partition to hide/unhide. Use /STATUS
to select the partition number.
-
/X Ignore
extended disk-access support.
-
/Y Suppress
prompting to confirm you wish the action to be performed. /SURE has the
same meaning.
Gdisk /? /MBR
This command displays the command-line format for the /MBR operation.
The /MBR command rewrites the boot code in the Master Boot Record by overwriting
it.
Although reinitializing (writing over) the Master Boot Record (MBR)
does not alter the disk's partition information, it can be destructive
if other software has written information into the MBR. Typical programs
that use space in the MBR include drive translation software such as OnTrack's
Disk Manager, or a boot manager such as OS/2's Boot Manager. These types
of utility programs are known by various names, such as disk extender,
drive overlay, and operating system loader.
Warning: Do not use the /MBR switch on a disk that is using
drive translation software installed to the MBR. Writing over the translation
software makes the partition data inaccessible unless the drive translation
software can be successfully reinstalled.
The most common reason to use this command is to write over a boot
sector virus. This destroys the virus residing in the MBR. This command
does not prevent reinfection of the MBR.
General command:
gdisk disk /MBR [/WIPE] [/X] [/Y]
-
disk The physical fixed disk (1-8).
-
/MBR Reinitialize the Master Boot Record.
-
/WIPE Delete all partitions and logical DOS drives. Default is
to leave existing partitions unmodified.
-
/X Ignore extended disk-access support.
-
/Y Suppress prompting to confirm you wish the
action to be performed. /SURE has the same meaning.
GDisk /STATUS /?
This command displays the command-line format for the /STATUS operation.
The /STATUS command displays information about fixed disk partitions.
General command:
gdisk [disk] [/STATUS] [/RAW|/LBA] [/X] [/Y]
-
disk The physical fixed disk (1-8). Default
is to list all fixed disks.
-
/STATUS Display partition information. Default mode.
-
/RAW Display raw contents of partition table.
-
/LBA Display raw contents of partition table
using Logical Block Addressing.
-
/X Ignore extended disk-access
support.
-
/Y Suppress prompting to confirm
you wish the action to be performed. /SURE has the same meaning.
GDisk /DISKWIPE /?
This command displays the command-line format for the /DISKWIPE operation.
The /DISKWIPE command wipes out all information on the hard disk.
Warning: The /DISKWIPE command wipes out the entire contents
of the physical disk. Make sure you specify the correct fixed physical
disk before proceeding. You can use the /STATUS command with a disk number,
to check the identity of the fixed disk you specify.
General command:
gdisk disk /DISKWIPE [/DOD|/CUSTOMWIPE:n]
|
The physical fixed disk (1-8). Default is to list all
fixed disks. |
|
Wipes the contents of the whole disk. |
|
DoD 5200.28-STD Wipe of the contents of the whole disk. |
|
DoD 5200.28-STD Wipe of the contents of the whole disk. |
|
Ignore extended disk-access support. |
|
Ignore direct IDE disk-access support |
|
Ignore SCSI disk-access support. |
|
Suppress prompting to confirm you wish the action to
be performed. /SURE has the same meaning. |
|
Restart after execution of command |