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:


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:


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:


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.

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:


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:


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:

When GDisk runs, it appends the contents of the batch file to the initial command line, performing each of the following commands in sequence: 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: 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:


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:

The disk number can also be supplied in a text file. For instance:


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 /? /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 /? /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 /? /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 /? /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.


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 /STATUS /?
This command displays the command-line format for the /STATUS operation. The /STATUS command displays information about fixed disk partitions.

General command:

GDisk /DISKWIPE /?
This command displays the command-line format for the /DISKWIPE operation. The /DISKWIPE command wipes out all information on the hard disk.


General command: