GDisk Commands

Bill’s Common Commands

Download GDisk

  • GDisk 1 /status
  • GDisk 1 /del /all deletes the whole disk
  • GDisk 1 /del /p:2 deletes partition 2
  • GDisk 1 /cre /pri /sz:100% /for /v:System create with full format OR
  • GDisk 1 /cre /pri /sz:100% /for /q /v:System create with quick format

Creating a partition

gdisk disk /cre {/pri| /ext| /log} [/sz: {MB|pcent{p|%}}][ /for [/q] [/v[:label]] ] [/-32] [/ntfat16]

  • disk The physical fixed disk, 1 to 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:MB Specifies the size of the partition in megabytes (MB). This is rounded up to the nearest cylinder.
  • /sz:pcent{p|%} Specifies the size of the partition as a percentage of the total disk size, not the available disk space.
  • /for Format the new partition once it has been created. Unless the /ntfat16 or /-32 switches are used, the partition type is determined by the following:
    • -If the partition is less than 16MB: FAT12
    • -If the partition is between 16MB and 512MB: FAT16
    • -If the partition is greater than 512MB: FAT32
  • /q Performs a quick format if used in combination with the /for switch. If you do not use this switch, then GDisk will do a surface scan of the partition and mark any bad sectors.
  • /v[:label] Use in combination with the /for switch to give the new formatted partition the specified label.
  • /-32 Partition is not formatted as FAT32. Limits primary and logical partitions to 204MB. Partitions over 16MB will be formatted as FAT16. This switch is useful if the operating system running does not support FAT32, for example, Windows NT4.
  • /ntfat16 Partition is not formatted as FAT32, but 64KB, cluster FAT16 is allowed. This limits primary and logical partitions to 4097MB. Partitions over 16MB are formatted as FAT16. Windows 9x and DOS systems are unable to access partitions that are over 204MB and were created with this switch.

For example:

  • GDisk 1 /cre /pri /sz:5000 /for /q /v:System creates a primary 5 gig partition, quick format and labeling it “System”.
  • GDisk 1 /cre /pri /sz:100% /for /q /v:System creates a primary partition the full size of the disk, quick format and labeling it “System”.

Reinitializing the Master Boot Record
Use the /mbr switch to rewrite the boot code in the Master Boot Record. The usual reason for needing to reinitialize the MBR is to eliminate a boot sector virus residing there. You can also use the /mbr switch with the / wipe option to delete a dynamic disk.

gdisk disk /mbr [/wipe]

  • /mbr Reinitializes the boot code in the Master Boot Record.
  • /wipe Delete the partition on the disk.

Displaying information about disks
The status switch displays information about the fixed disks and partitions on a disk, including the model of the disk. To display the information about the partitions on a disk, you must specify the disk number. The syntax for this command is as follows:

gdisk [disk] [/status] [/raw] [/lba] [/ser]

  • /raw Displays the contents of the partition table in CHS form if used with the disk switch.
  • /lba Displays the contents of the partition table in logical block form if used with the disk switch.
  • /ser Displays the serial number of the disk.

Deleting and wiping your disk
GDisk provides a choice to delete data and partitions on your disk or wipe your entire disk. You cannot delete a dynamic disk partition. The switch /del/all deletes all partitions that are on the disk. Partitions are removed. Any other space that has not been used for creating a partition will not be deleted. Deleting an extended partition also deletes any logical partition within it. The /diskwipe switch wipes the whole disk, partitions, partition table, MBR and all used and unused spaces.
The syntax for the delete switch command is as follows:

gdisk disk /del {/pri[:nth]|/ext[:nth]|/log:nth|/p:partn-no|/all} [/qwipe|/dod|/custom:n]

The syntax for the diskwipe switch is as follows:

gdisk disk /diskwipe [/dod|/custom:n]

  • /del Delete a DOS partition or logical DOS drive.
  • /pri[:nth] Delete the nth primary DOS partition, the default is 1.
  • /ext[:nth] Delete the nth extended DOS partition, the default is 1. Also deletes any logical partitions in the extended partition.
  • /log:nth Delete the nth logical DOS drive from the extended DOS partition.
  • /p:partn-no The partition to delete. Use the number reported by Gdisk in standard display mode (not using /lba or /raw) for partn-no.
  • /all Delete all partitions.
  • /qwipe Overwrites the partition’s data area before deleting the partition. Makes one pass of the disk.
  • /dod Overwrites the partition’s data area before deleting the partition. Makes 7 passes of the disk. This is the security standard for the U.S. Department of Defence.
  • /custom:n Overwrites the partition’s data area n times before deleting the partition. n can be set from 1 to 100. /custom:7 is equivalent to /dod.

For example:

  • gdisk 1 /del /all /qwipe completes one pass to delete all partitions and data on disk 1.
  • gdisk 1 /del /p:2 /qwipe wipes partition 2 on disk 1 with one pass.
  • gdisk 1 /diskwipe /custom:xx wipes the entire disk with xx passes. /dod wipes 7 times.

Activate or deactivate a partition
The syntax for this command is as follows:

gdisk disk /[-]act /p:partn-no

  • /act Activate a partition.
  • /-act Deactivate a partition.
  • /p:partn-no Partition to activate or deactivate. Only primary partitions can be activated. Use the number reported by GDisk in standard display mode (not using /lba or /raw) for partn-no.

Use Batch Mode
The syntax for this command is as follows:

gdisk [disk] [/y] /batch:[file.name]

  • disk The physical fixed disk, 1 to 8.
  • /y Turns off confirmation prompting.

The text file can contain any number of commands. Command line arguments that apply to all of the batch commands can be specified on the original command line along with the batch mode switch. If the batch mode switch is supplied without a file name, GDisk will prompt for the commands to execute.

For example:

gdisk 1 /batch:file.name

This directs all batch commands to act on disk 1.
Here is an example batch command file called two-new.gg. Blank lines and ones starting with the hash symbol are considered to be comments and are ignored. (Note that, in this example, the commands do not specify the fixed disk to operate on.)

# Delete all partitions.
/del /all
# Create formatted primary DOS partition.
/cre /pri /for /q

The following command deletes all partitions and creates two new ones on the second fixed disk with confirmation prompting turned off:
gdisk 2 /y /batch:two-new.gg

Advanced combinations
Batch modes can nest recursively on the command line as well as within batch files. File-based and interactive batch modes may be mixed in the same command lines. For example, the following command prompts for the number of the fixed disk(s) to execute the commands in two-new.gg against.
gdisk /batch /batch:two-new.gg

If a file named disks.gg contained the following lines:
1
2

then you could delete all partitions and create two new ones on both fixed disks with the following command:
gdisk /batch:disks.gg /batch:two-new.gg