coreygoOctober 7, 2009

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:\test.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:\test.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:\test.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:\testdiff.vhd parent=c:\test.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

DiskPart.exe and managing Virtual Hard Disks (VHDs) in Windows 7的更多相关文章

  1. QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt

    libvirt is a library that provides a common API for managing popular virtualization solutions, among ...

  2. Windows Azure Virtual Machine (32) 如何在Windows操作系统配置SFTP

    <Windows Azure Platform 系列文章目录> 下载地址:http://files.cnblogs.com/files/threestone/Windows_SFTP.pd ...

  3. [转]Uploading and Downloading VHDs to Windows Azure

    The article shows how to download and upload VHD to Azure. http://michaelwasham.com/windows-azure-po ...

  4. softlayerFastUploadVHDtoBS

    Object Storage Uploader Overview We’ve recently added the option to import customer-supplied Virtual ...

  5. PowerShell 在hyper-v中创建虚拟机

    # This script configures the Hyper-V machines used for the 50331 Course. # PowerShell 3.0 and Window ...

  6. [SQL in Azure] Getting Started with SQL Server in Azure Virtual Machines

    This topic provides guidelines on how to sign up for SQL Server on a Azure virtual machine and how t ...

  7. QEMU KVM Libvirt手册(11): Managing Storage

    When managing a VM Guest on the VM Host Server itself, it is possible to access the complete file sy ...

  8. Virtual Machine Definition File 2.2

    Virtual Machine Definition File 2.2 http://archives.opennebula.org/documentation:archives:rel2.2:tem ...

  9. 教程:使用Diskpart创建、扩展或删除磁盘分区

    在Windows Server环境下进行基本的磁盘操作时,管理员可以使用Disk Partition Utility或Diskpart等工具.后者是一个命令行解释器,可作为磁盘管理工具. 管理员可以使 ...

随机推荐

  1. E - Fire! UVA - 11624(bfs + 记录火到达某个位置所需要的最小时间)

    E - Fire! UVA - 11624 题目描述 乔在迷宫中工作.不幸的是,迷宫的一部分着火了,迷宫的主人没有制定火灾的逃跑计划.请帮助乔逃离迷宫.根据乔在迷宫中的位置以及迷宫的哪个方块着火,你必 ...

  2. python中的两个高阶函数map()和reduce()

    1.map()传入的有两个参数,函数和可迭代对象(Itreable),map()是把传入的函数依次作用于序列的每个元素,结果返回的是一个新的可迭代对象(Iterable). map()代码如下: # ...

  3. 什么是ansible

                                                                 什么是ansible l Ansible是2013年推出的一款IT自劢化和De ...

  4. Python:Day05-2

    面向对象进阶 在前面的章节我们已经了解了面向对象的入门知识,知道了如何定义类,如何创建对象以及如何给对象发消息.为了能够更好的使用面向对象编程思想进行程序开发,我们还需要对Python中的面向对象编程 ...

  5. docker+nginx 微信支付回调

    制作微信支付发现回调有问题: docker-compose中接口要映射对应地址 然后再进行访问

  6. Django 已生成数据时怎么查询数据库

    数据库已写好时,怎样查询数据库 1.输入命令:python manage.py inspectdb  > model1.py     注:>重定向 到model1.py

  7. Struts2-学习笔记系列(15)-ajax支持和JSON

    7.1stream类型的result 使用stream就无需jsp页面,直接在action想浏览者生成指定的响应 @Override public java.lang.String execute() ...

  8. defer使用小结

    defer 前言 defer的定义 defer执行的规则 为什么需要defer defer进阶 作为匿名函数 作为函数参数 defer命令执行的时机 defer配合recover 总结 参考 defe ...

  9. python初学(二)

    1.输入一个整数列表L,判断L中是否存在相同的数字: (1)若存在,输出YES,否则输出NO: (2)若存在,输出YES,同时输出相同的数字:否则输出NO. l=list(input()) print ...

  10. 【Tool】Windows系统安装Maven依赖管理工具

    安装Maven依赖管理工具 官网下载地址:http://maven.apache.org/download.cgi 系统环境要求: [JDK]Maven3.3版本+需要JDK1.7版本以上支持 [内存 ...