My sequence for using diskpart.exe involves specifying the disk number first, and then proceeding to format the disk.
C:\>diskpart
Microsoft DiskPart version 10.0.18362.1
Copyright (C) Microsoft Corporation.
On computer: AAAAAAA
DISKPART> select disk 2
Disk 2 is now the selected disk.
DISKPART> clean
DiskPart succeeded in cleaning the disk.
DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.
DISKPART> format fs=ntfs label="My USB Disk" quick
There is no volume selected.
Please select a volume and try again.
DISKPART>
The script appears to be functional and may work on Windows 7, as various online sources suggest. However, when I attempted to use it on my Windows 10 system, I encountered issues.
There is no volume selected
From the displayed screenshot, it is evident that Disk 2 contains a volume. Since my USB flash drive has only one volume, the format process should be successful.
What are your thoughts on this?
2 Answers
Introduction
Formatting a USB disk using DiskPart is a common task for many computer users. DiskPart is a powerful command-line utility that enables users to manage disks, partitions, and volumes on Windows-based computers. In this blog post, we will discuss the common error encountered while formatting a USB disk using DiskPart and how to resolve it.
Background
DiskPart is a built-in command-line tool that comes with all recent versions of Windows. It is a powerful utility that enables users to manage disks, partitions, and volumes on Windows-based computers. DiskPart can be used to create, delete, and format partitions, assign drive letters, and set partition attributes. It is a useful tool for system administrators, IT professionals, and advanced users who need to manage disks and partitions on Windows computers.
One of the common tasks performed using DiskPart is formatting a USB disk. Formatting a USB disk involves erasing all data on the disk and setting up a new file system. This is useful when you want to reuse a USB disk or when you want to prepare a USB disk for a specific purpose, such as installing an operating system or creating a bootable disk.
The Error: “No volume selected”
When using DiskPart to format a USB disk, you may encounter the error message “There is no volume selected. Please select a volume and try again.” This error occurs when DiskPart is unable to determine which volume to format. It can occur even when the USB disk has only one volume.
The reason for this error is that the format
command in DiskPart requires a volume to be selected before it can format the disk. If DiskPart is unable to select a volume, it will display the error message.
Resolving the Error
To resolve the “No volume selected” error in DiskPart, you need to ensure that a volume is selected before running the format
command. There are several ways to select a volume in DiskPart:
Method 1: Using the “list volume” command
The easiest way to select a volume in DiskPart is to use the list volume
command. This command displays a list of all volumes on the selected disk, along with their sizes and drive letters. To select a volume using the list volume
command, follow these steps:
- Open DiskPart by typing “diskpart” in the command prompt.
- Type “list disk” to display a list of all disks on the computer.
- Type “select disk X” (where X is the number of the disk you want to format).
- Type “list volume” to display a list of all volumes on the selected disk.
- Type “select volume X” (where X is the number of the volume you want to format).
- Type “format fs=ntfs label=”My USB Disk” quick” to format the selected volume.
Method 2: Using the “select” and “assign” commands
Another way to select a volume in DiskPart is to use the select
and assign
commands. This method is useful when the volume you want to format does not have a drive letter assigned. To select a volume using the select
and assign
commands, follow these steps:
- Open DiskPart by typing “diskpart” in the command prompt.
- Type “list disk” to display a list of all disks on the computer.
- Type “select disk X” (where X is the number of the disk you want to format).
- Type “list volume” to display a list of all volumes on the selected disk.
- Type “select volume X” (where X is the number of the volume you want to format).
- Type “assign letter=Y” (where Y is the drive letter you want to assign to the volume).
- Type “exit” to exit DiskPart.
- Type “format Y: /fs:ntfs /q /v:”My USB Disk”” to format the selected volume.
Method 3: Using the “diskpart” command
You can also use the diskpart
command to format a USB disk. This method is useful when you want to format the entire disk, including all volumes and partitions. To format a USB disk using the diskpart
command, follow these steps:
- Open the command prompt.
- Type “diskpart” to open DiskPart.
- Type “list disk” to display a list of all disks on the computer.
- Type “select disk X” (where X is the number of the disk you want to format).
- Type “clean” to erase all data on the disk.
- Type “create partition primary” to create a new primary partition on the disk.
- Type “format fs=ntfs label=”My USB Disk” quick” to format the partition.
- Type “exit” to exit DiskPart.
Conclusion
Formatting a USB disk using DiskPart is a useful task that enables you to prepare a USB disk for a specific purpose. However, you may encounter the “No volume selected” error when using DiskPart to format a USB disk. This error occurs when DiskPart is unable to determine which volume to format. To resolve this error, you need to ensure that a volume is selected before running the format
command. There are several ways to select a volume in DiskPart, including using the list volume
command, the select
and assign
commands, and the diskpart
command.
The code is mostly accurate, but there is a section that is absent. Please make the necessary adjustments to suit your requirements.
create partition primary
select partition 1
active
format fs=ntfs label="My USB Disk" quick
assign letter=D