Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create and Manage Virtual Disks in Windows

Virtual disks are a powerful feature in Windows that allows you to create and manage disk images as if they were physical drives. This can be particularly useful for testing, data management, and virtualization. In this article, we will explore how to create, attach, and manage virtual disks using both the graphical user interface (GUI) and command-line tools in Windows.

Creating a Virtual Disk Using Disk Management

  1. Open Disk Management:

    • Press Win + X and select "Disk Management" from the menu.
  2. Create a VHD:

    • In Disk Management, click on the "Action" menu and select "Create VHD."
    • Choose a location to save the VHD file and specify the size of the virtual disk.
    • Select the VHD format (VHD or VHDX) and the disk type (Fixed size or Dynamically expanding).
    • Click "OK" to create the virtual disk.
  3. Initialize and Format the VHD:

    • The new virtual disk will appear as "Not Initialized" in Disk Management.
    • Right-click on the disk and select "Initialize Disk."
    • Choose the partition style (MBR or GPT) and click "OK."
    • Right-click on the unallocated space and select "New Simple Volume."
    • Follow the wizard to format the disk and assign a drive letter.

Creating a Virtual Disk Using PowerShell

  1. Open PowerShell as Administrator:

    • Press Win + X and select "Windows PowerShell (Admin)."
  2. Create a VHD:

    New-VHD -Path "C:\Path\To\VirtualDisk.vhdx" -SizeBytes 20GB -Dynamic
  3. Initialize and Format the VHD:

    Mount-VHD -Path "C:\Path\To\VirtualDisk.vhdx"
    Initialize-Disk -Number 1 -PartitionStyle GPT
    New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel "VirtualDisk"

Attaching and Detaching Virtual Disks

Using Disk Management

  • Attach a VHD:

    • In Disk Management, click on the "Action" menu and select "Attach VHD."
    • Browse to the VHD file and click "OK."
  • Detach a VHD:

    • Right-click on the virtual disk and select "Detach VHD."

Using PowerShell

  • Attach a VHD:

    Mount-VHD -Path "C:\Path\To\VirtualDisk.vhdx"
  • Detach a VHD:

    Dismount-VHD -Path "C:\Path\To\VirtualDisk.vhdx"

Managing Virtual Disks

Expanding a VHD

  • Using Disk Management:

    • Right-click on the virtual disk and select "Expand VHD."
    • Specify the new size and click "OK."
  • Using PowerShell:

    Resize-VHD -Path "C:\Path\To\VirtualDisk.vhdx" -SizeBytes 30GB

Compacting a VHD

  • Using PowerShell:
    Optimize-VHD -Path "C:\Path\To\VirtualDisk.vhdx" -Mode Full

Conclusion

Virtual disks in Windows provide a flexible and powerful way to manage storage. Whether you use the GUI tools in Disk Management or the command-line capabilities of PowerShell, you can easily create, attach, and manage virtual disks to suit your needs.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.