• DiskPart.exe and managing Virtual Hard Disks (VHDs) in Windows 7


    In Windows 7, new commands have been added in DiskPart to allow for the creation and management of Virtual Hard Disks (.vhd files).  The DiskPart VHD management commands have been provided below in 2 sections – commonly used commands with examples and other commands.  It is assumed in each of the examples that DiskPart.exe has already been launched in an elevated command prompt.

    1. Creating a VHD
      The example below creates a 20GB dynamically expanding VHD called "test.vhd" and places it in the root of the C: drive.  Note that the type parameter is optional and the default type is fixed.

      create vdisk file=c: est.vhd maximum=20000 type=expandable
    2. Attaching a VHD
      The following example shows how to select and attach the VHD.  It also provides steps for partitioning, formatting and assigning a drive letter to the attached VHD.

      select vdisk file=c: est.vhd
      attach vdisk
      create partition primary
      format fs=ntfs label="Test VHD" quick
      assign letter=v

    3. Detaching the VHD
      To detach (i.e. unmount) the VHD, use the following example:

      select vdisk file=c: est.vhd
      detach vdisk

    Note: All 3 of these VHD actions can also be performed in the Disk Management Console of Windows 7.

    In addition, below are some other DiskPart commands that can be used to manage VHDs:

    • create vdisk file=c: estdiff.vhd parent=c: est.vhd – This will create a differencing "child" VHD (testdiff.vhd) so that the existing parent VHD (test.vhd) is not modified.  Useful when you have an image on the parent VHD that you don’t want modified.  When needing to go back to the default image, only the differencing VHD would need to be replaced.  The differencing VHD typically starts out very small – usually less than a megabyte.  As a result, it is easy to back up and replace.
    • expand vdisk maximum=<size in mb> – This expands the maximum size on a VHD.  For this to work, the virtual disk must already be selected, detached and be a non-differencing VHD.  In addition, if you do have a differencing VHD and expand the parent VHD, you will need to create a new differencing VHD.  Otherwise you will encounter a VHD corruption error when trying to select/manage the differencing VHD.
    • merge vdisk depth=1 – Merges a child VHD with its parent.  This command can be used to merge one or more differencing ("child") VHDs with its corresponding parent VHD.
    • compact vdisk – Compacts a selected VHD to reduce the physical size.  Can only be used on VHDs that are type expandable and are either detached, or attached as read only.

    Resources

  • 相关阅读:
    cookie secure属性 导致setcookie失败-test
    vim 常用操作总结(持续更新)-test
    网页重定向(外部重定向和内部重定向)-test
    pat 1002 A+B for polynomials (第二个测试点一直无法通过,最后解决)-test
    pat 1001 A+B Format-test
    验证码无法显示的其中一种原因-test
    str_replace替换换行符失败原因-test
    .net/C#语言web项目内新增js或css文件调用不到,url报错404
    在W10系统中配置Java环境变量后,cmd命令提示符找不到java
    JS使用知识点理解
  • 原文地址:https://www.cnblogs.com/liujx2019/p/11692457.html
Copyright © 2020-2023  润新知