Disk Management

     Microsoft Disk Management 




Format a hard drive using the Command Prompt (CMD) in Windows, follow these steps:

Caution

Formatting a disk erases all the data on it. Ensure you have backed up any important data before proceeding.



Steps to Format a Hard Disk via CMD

1. Open Command Prompt as Administrator:

Press Win + S to open the search bar, type cmd, right-click on Command Prompt, and choose Run as Administrator.



2. Launch Disk Partition Tool:

Type the following command and press Enter:

diskpart



3. List Available Disks:

To see the available disks, type:

list disk

This will display all the disks connected to your computer.



4. Select the Disk to Format:

Identify the disk you want to format (e.g., Disk 1). Select it by typing:

select disk 1

Replace 1 with the appropriate disk number.



5. Clean the Disk (Optional):

To remove all partitions and data, type:

clean



6. Create a New Partition:

Type the following to create a new primary partition:

create partition primary



7. Format the Partition:

To format the disk with a specific file system (e.g., NTFS), type:

format fs=ntfs quick

Replace ntfs with fat32 or exfat if you need a different file system. The quick parameter speeds up the process by performing a quick format.



8. Assign a Drive Letter:

To assign a drive letter (e.g., E), type:

assign letter=E



9. Exit DiskPart:

Once the process is complete, exit DiskPart by typing:

exit

Close the Command Prompt.


Example Commands for Quick Reference:

diskpart
list disk
select disk 1
clean
create partition primary
format fs=ntfs quick
assign letter=E
exit

Now, the hard drive is formatted and ready to use!







Manually assigning a drive letter using CMD/Diskpart :-


[Localization from this article: Manuelles Zuweisen eines Laufwerksbuchstaben mit CMD bzw. Diskpart - Microsoft Community]


Technical Difficulty: Expert


Applies to: Windows 10 & 11


In some cases, Windows will not assign a drive letter automatically to an inserted drive. For example, this can happen when using a Windows installation media.


In that case, you can use diskpart to manually assign a drive letter.


NOTE: If your drive doesn't get assigned a drive letter, even though you are in a normal Windows environment, this can indicate a problem with the drive. Please back up your files in that case.

Procedure :-

Open up a command prompt (CMD/PowerShell).


Type "diskpart" to start up diskpart. You will see the prompt change to "DISKPART>".

Type "list vol" to list all available volumes. You can identify the drive by size and file system. Additionally, the volume doesn't currently have a drive letter.

Select the volume using "sel vol <number>"

Assign the drive letter using "assign letter=<letter>".

You can now exit diskpart by typing "exit" and switch to the drive using "<letter>:".

It should also be available from Windows Explorer now.



Formatting a Pendrive Using Command Prompt :-

Here's how to format a pendrive using the diskpart command in Windows Command Prompt:

  1. Open Command Prompt as Administrator: Right-click on the Start menu and select "Run as administrator".
  2. Start Diskpart: Type diskpart and press Enter.
  3. List Disks: Type list disk and press Enter to see a list of connected disks.
  4. Select the Pendrive: Type select disk [disk number] and press Enter, replacing "[disk number]" with the actual number of your pendrive. You can usually identify the pendrive by its size.
  5. Clean the Disk: Type clean and press Enter. This will erase all data on the disk.
  6. Create a Partition: Type create partition primary and press Enter to create a primary partition.
  7. Select the Partition: Type select partition 1 and press Enter.
  8. Format the Partition: Type format fs=fat32 quick and press Enter. Replace "fat32" with "ntfs" if you prefer the NTFS file system. The "quick" format is faster but might not completely erase all data.
  9. Example:

    diskpart
    list disk
    select disk 1
    clean
    create partition primary
    select partition 1
    format fs=fat32 quick

Important Note:

  • Data Loss: Formatting a disk will erase all data on it. Make sure you have backed up any important data before proceeding.
  • Disk Number: Double-check the disk number to ensure you're formatting the correct drive.
  • File System: Choose the file system that is compatible with your operating system and devices. FAT32 is generally compatible with most devices, while NTFS offers larger file size support.

Manually : Assign Drive Letter "Z" (DISKPART)
  1. Open Command Prompt as Administrator:

    • Press Win + X and select Command Prompt (Admin) or Windows Terminal (Admin).
  2. Start Diskpart:

    • Type diskpart and press Enter.
  3. List Volumes:

    • Type list volume and press Enter. This shows all available volumes.
  4. Select the Volume:

    • Identify the volume you want to assign "Z" to, then type select volume X (replace X with the volume number).
  5. Assign Drive Letter "Z":

    • Type assign letter=Z and press Enter.

You’ve now assigned drive letter Z to the selected volume.

Manually: Remove Drive Letter "Z" (DISK PART)

  1. Open Diskpart (if it’s not already open):

    • If you exited Diskpart after assigning the drive letter, type diskpart in Command Prompt and press Enter.
  2. List Volumes:

    • Type list volume and press Enter again to view the volumes.
  3. Select the Volume with Drive Letter "Z":

    • Type select volume X (replace X with the volume number associated with drive letter "Z").
  4. Remove Drive Letter "Z":

    • Type remove letter=Z and press Enter.
  5. Exit Diskpart:

    • Type exit to close Diskpart.

The drive letter "Z" is now removed from the volume.

shrink a disk volume using Command Prompt (CMD):

  1. Open Command Prompt as Administrator:
    • Right-click Start menu
    • Select "Windows PowerShell (Admin)" or "Command Prompt (Admin)"
  2. Start DiskPart:
    diskpart
  3. List all volumes:
    list volume
  4. Select the volume you want to shrink:
    select volume X (replace X with your volume number)
  5. Check available space:
    detail volume
  6. Important Notes:

    • Make sure to backup important data before proceeding
    • Cannot shrink beyond point of immovable files
    • System files might prevent maximum shrinking
    • Use 'querymax' to see maximum possible shrink size:
      shrink querymax
  7. Shrink the volume:
    shrink desired=X (replace X with size in MB you want to shrink)
    For example, to shrink by 10GB:
    shrink desired=10000
    EXIT


Creating a Bootable Media (OS Installation Pendrive ) :-

You can create a bootable USB drive using a Windows 11 ISO file without any third-party apps by using the built-in Command Prompt and DiskPart utility in Windows. Here's how:


Step 1: Prepare the USB Drive

  1. Insert a USB Drive:

    • Ensure the USB drive has at least 8GB of free space.
    • Backup your data from the USB drive, as this process will erase all data on it.
  2. Open DiskPart:

    • Press Win + S, type cmd, right-click Command Prompt, and select Run as Administrator.
    • In the Command Prompt, type diskpart and press Enter.
  3. Select the USB Drive:

    • Type the following commands step-by-step:

      list disk

      Identify the disk number of your USB drive (e.g., Disk 1).

      select disk X

      (Replace X with the USB disk number.)

  4. Clean and Format the USB Drive:

    • Type the following commands:

      clean create partition primary select partition 1 active format fs=ntfs quick assign exit

    Your USB drive is now ready.


Step 2: Mount the Windows 11 ISO

  1. Mount the ISO:

    • Locate your Windows 11 ISO file, right-click it, and select Mount.
    • A new virtual drive will appear in File Explorer (e.g., D:).
  2. Note the Drive Letters:

    • Note the virtual drive letter of the mounted ISO (e.g., D:).
    • Note the drive letter of your USB drive (e.g., E:).

Step 3: Copy Windows Files to USB

  1. In the Command Prompt (still with Administrator privileges), type:

    xcopy D:\* E:\ /E /F /H

    (Replace D: with the ISO drive letter and E: with the USB drive letter.)

  2. This will copy all Windows 11 installation files to the USB drive.


Step 4: Make the USB Bootable

The USB is bootable as long as the copied ISO contains the bootloader. Once the files are copied, you can use the USB to boot into the Windows 11 installer.


Step 5: Test the Bootable USB

  1. Restart your computer.
  2. Enter the BIOS/UEFI (usually by pressing F2, Del, or F12 during startup).
  3. Set the USB drive as the primary boot device.
  4. Save changes and exit. Your system should boot into the Windows 11 installer.

Comments

Popular posts from this blog

Windows Administration

Windows Scripts