zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    吴裕雄--天生自然 PHP开发学习:数组
    吴裕雄--天生自然 JAVASCRIPT开发学习:测试 jQuery
    【t065】最敏捷的机器人
    【t079】火星上的加法运算
    【t053】整数去位
    【9604】纪念品分组
    【心情】bjdldrz
    【9601】零件分组
    【9916】编辑距离
    【38.24%】【POJ 1201】Intervals
  • 原文地址:https://www.cnblogs.com/liujx2019/p/11692457.html
Copyright © 2011-2022 走看看