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. 文件输入输出实例&Ptask的编写

    前言 最近在写Ptask,顺便了解了如何进行文件读入输出.而在Ptask中最重要,也是最最容易出bug的地方就是文件操作.那么如何进行文件输入输出,在程序中起到重要作用呢? 输入 首先为了保证可以在控 ...

  2. 封装属于自己的Python包

    将自己的程序打包为whl/tar.gz文件 有时候自己写了一个开发基本类,我们把这个类打包为whl或者tar.gz文件,这样的话同事也可以使用自己开发的基本类了 安装setuptools pip in ...

  3. Scala环境及IDEA配置

    Scala环境及IDEA配置 1 语言介绍 他已经出生15年了,就像明星一样,谁都不可能一开始就人气爆棚粉丝无数,得慢慢混. 成功原因:完全兼容java代码. 身世介绍 Scala在2004年正式问世 ...

  4. Http协议中Cookie使用详细介绍

    Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie.内存Cookie由浏览器维护,保存在内存中,浏览器关闭后就消失了,其存在时间是短暂的.硬盘Cookie ...

  5. Vlan间通讯,动态路由

    Vlan间通讯,动态路由 案例1:三层交换vlan间通信 案例2:多交换机vlan间通信 案例3:三层交换配置路由 案例4:RIP动态路由配置 案例5:三层交换配置RIP动态路由 1 案例1:三层交换 ...

  6. Scratch 第4课满天星

    素材及视频下载 链接:https://pan.baidu.com/s/1qX0T2B_zczcLaCCpiRrsnA提取码:xfp8

  7. JAVA中基础类型和字串类型之间的相互转换

    转自:https://www.imooc.com/code/2251 仅做个人学习记录之用,侵删. 在程序开发中,我们经常需要在基本数据类型和字符串之间进行转换. 其中,基本类型转换为字符串有三种方法 ...

  8. Python 1基础语法一(注释、行与缩进、多行语句、空行和代码组)

    一.注释Python中单行注释以 # 开头,实例如下: # 第一个注释 print ("Hello, Python!") # 第二个注释 输出结果为: ============== ...

  9. Python之GUI编程(Tkinter))

    不足之处,还请海涵,请指出不足.本人发布过的文章,会不断更改,力求减少错误信息. 一.重要放在开头:模块 如出现这种错误 ModuleNotFoundError: No module named 'n ...

  10. 36 Thread 多线程

    /* * 多线程的实现方式: * 方式1:一种方法是将类声明为 Thread 的子类.该子类应重写 Thread 类的 run 方法.接下来可以分配并启动该子类的实例 * * Thread * Str ...