Skip to main content

Diskpart Tutorials

339 words·
Diskpart PowerShell Bootable USB-Stick Windows
Table of Contents

Delete Partition
#

# List disks
list disk

# Select disk: Define disk number
select disk 0
# List partitions of disk
list partition

# Shell output:
Partition ###  Typ               Größe    Offset
-------------  ----------------  -------  -------
Partition 1    System             100 MB  1024 KB
Partition 2    Reserviert          16 MB   101 MB
Partition 3    Primär              79 GB   117 MB
Partition 4    Wiederherstellun   515 MB    79 GB

# Select partition: Define partition number
select partition 1
# Delete partition
delete partition

# Delete protected partition
delete partition override

Create Bootable Windows USB-Stick
#

Prerequisites
#

Find the USB-Stick oder Disk with PowerShell: Get-Disk

The PowerShell output should look like this:

Number Friendly Name Serial Number   HealthStatus         OperationalStatus      Total Size Partition Style
------ ------------- -------------   ------------         -----------------      ---------- ----------
2      Samsung SS... ...             Healthy              Online                  465.76 GB GPT
...
5      USB SanDis... ...             Healthy              Online                   28.65 GB GPT

Clean Disk
#

# Start Diskpart
diskpart

# List Disks
list disk

# Select Disk
select disk 5

# List Disks: Check if right disk is selected (marked with *)
list disk

# Clean Disk
clean

# Exit Diskpart
exit

Create Bootable USB-Stick
#

Clean the USB-Stick or Disk and continue as follows:

# Create a primary partition
create partition primary

# Select the partition
select partition 1

# Make the partition active
active

# Format the partition
format fs=exfat quick label="windows"

# Exit Diskpart
exit

# Make USB-Stick bootable
bootsect /nt60 I: # Replace "I" with your Disk Letter

Copy Files
#

# Mount ISO file, the drive letter is assigned automatically
Mount-DiskImage -ImagePath "path\to\Ubuntu.iso"

# Copy Files from Mounted ISO to USB-Stick
xcopy J:\*.* I:\ /E /H /F # Replace "J" with the Letter from your mounted Disk

# Unmount ISO file
Dismount-DiskImage -ImagePath "path\to\Ubuntu.iso"

Convert Disk during Windows Setup
#

Open CMD during Windows Setup: Shift + F10


# Open Diskpart
diskpart

# Select Disk
select disk

# Clean Disk
clean

# Convert to GPT Partition Style
convert gpt

# Exit Diskpart
exit

Click “Refresh” and install Windows on the converted disk.