Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Windows CMD – Disk Partition and Format with DiskPart

Posted on December 22, 2016December 22, 2016 By David Kittell

NOTE: This is not put in code as it can be VERY difficult reverse the process below. ONLY do this if you have a clue of what you are doing .

This process has been tested on a USB Hard Drive, Thumb Drive, and Physical (Internal to computer) Hard Drive

Partition Modification:

  1. Open an elevated command prompt.
  2. Run diskpart
    diskpart
    
  3. List Disks
    list disk

    Note the disk number that corresponds to your USB drive (it should be obvious going by size)

    Example:

    DISKPART> list disk
    
      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          160 GB      0 B        *
      Disk 1    Online           28 GB      0 B
    
    DISKPART>
    
  4. select disk X where X is the number from step 4
    select disk 1
    
  5. List Partitions
    list partition
    

    There could be multiple partitions

  6. Select the partition
    select partition 0
  7. Delete the partition
    delete partition
  8. Select the partition
    select partition 1
  9. Delete the partition
    delete partition
  10. Create a primary partition – IMPORTANT
    create partition primary
  11. List volumes – IMPORTANT for next step as this will list the drive letters.
    You should notice that your drive is labeled as “RAW” in the “Fs” column this is the drive letter for the disk we just worked on
    list volume
  12. Exit DiskPart
    exit
  13. Format Disk – depending on your preferred type use ONE of the commands below.
    NOTE: In the example code g: is the drive letter for the drive we just worked with.
    format g: /q /c /FS:FAT32 /v:32GB
    format g: /q /c /FS:NTFS /v:32GB

    Securely Format, the 7 can be set at any number

    format g: /p:7 /x /c /FS:FAT32 /v:32GB
    format g: /p:7 /x /c /FS:NTFS /v:32GB

Exit Command Prompt (type exit or just close the window)

Referenced From: http://superuser.com/questions/536813/how-to-delete-a-partition-on-a-usb-drive

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Windows Windows Batch

Post navigation

Previous post
Next post

Related Posts

PowerShell – Show All Installed Applications

Posted on November 9, 2015

function Get-Installed { <# .SYNOPSIS This function lists data found in the registry associated with installed programs. .DESCRIPTION Describe the function in more detail Author: Stan Miller .EXAMPLE Get all apps whose display names start with a specific string and display all valuenames get-installed -re "^microsoft xna" -valuenameRE ".*" The…

Read More

UNIX Terminal – Secure Copy (SCP)

Posted on May 31, 2016May 31, 2016

Secure Copy (SCP) is a useful UNIX command that allows you to securely copy files and directories between your local machine and a remote computer. In the examples below “-P 22” is not actually needed if the SSH port is 22. Many of the servers I connect to have a…

Read More

NPI Database

Posted on May 7, 2015October 26, 2015

If you work in medical databases you are likely familiar with the site CMS NPI Search I have had a few projects that need the ability to validate NPI numbers so based on data at CMS.gov I have worked out a solution to get the data into a database that…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes