windows虚拟机通过diskpart扩容磁盘

Extending partitions in Windows using DiskPart (1007266)

Purpose
This article provides steps to expand a virtual disk (VMDK) and then extend a partition using DiskPart in Microsoft Windows.  
Resolution
 
Caution: VMware strongly recommends that you have backups in place before performing any disk partition operation. Also ensure that virtual machine has no snapshots, before starting to extend the VMDK. If the virtual machine has snapshots use "Delete all" from the Snapshot Manager to commit them. Verify again in the Snapshot Manager, in the Edit Settings and the virtual machine datastore that the snapshots were committed.
 
To expand VMDK and extend a partition:
  1. Log in to the VMware ESX/ESXi host as the root user. Verify that the virtual machine does not have any snapshots in the virtual machine's directory and look for Delta files. Run the command:

    #ls -lah /vmfs/volumes/datastore_name/vm_name/*delta*
    -rw------- 1 root root 1.8G Oct 10 10:58 vm_name-000001-delta.vmdk

    Note: For more information on:

  2. If the virtual machine have snapshots, commit them by running these commands:

    #vmware-cmd -l /vmfs/volumes/datastore_name/vm_name/vm_name.vmx
    #vmware-cmd /vmfs/volumes/datastore_name/vm_name/vm_name.vmx removesnapshots removesnapshots() = 1


    Note: For committing snapshots on an ESXi 5.1 or later host, see Committing snapshots on ESXi host from command line (1026380).

  3. Power off the virtual machine.

    Note: The virtual machine can be powered on to increase the vmdk size in steps 4 and 5. However ensure to power off the virtual machine after increasing VMDK size.

  4. To expand the VMDK using the VI Client (if the option exists), edit the settings of the virtual machine and click the hard disk you want to expand.

  5. Enter a new value in the New Size field:

    003.bmp

    To expand the VMDK using the vmkfstools -X command, run the command:

    #vmkfstools -X
    #vmkfstools -X 30G /vmfs/volumes/datastore_name/vm_name/vm_name.vmdk


    Note: Ensure that you point to the vm_name.vmdk, and not to the vm_name-flat.vmdk. Using vmkfstools -X is the only option to expand an IDE virtual disk.

  6. To extend the C: partition, find a helper virtual machine and attach the disk from the first virtual machine to the helper.

    To add an existing virtual disk to the helper virtual machine:

    1. Go to the Edit Settings menu of the virtual machine.

    2. Click Add > Hard Disk > Use Existing Virtual Disk
    3. Navigate to the location of the disk and select to add it into the virtual machine.

      Note: A helper virtual machine is a virtual machine that has the same operating system to which you attach the disk.

  7. Start the helper virtual machine. 
  8. Verify the volume in question has been mounted and has been assigned a drive letter. This can be set in Windows Disk Management or by selecting the volume and typing assign from within the DiskPart command.

    In versions of Windows prior to 2008, open a command prompt and run the DiskPart command:

    C:\Documents and Settings\username>diskpart

    Microsoft DiskPart version 5.1.3565
    Copyright (C) 1999-2003 Microsoft Corporation.
    On computer: USERNAME-HELPER-VM
    DISKPART> list volume

    Volume ### Ltr Label Fs Type Size Status Info
    ---------- --- ----------- ----- ---------- ------- --------- --------
    Volume 0 D CD-ROM 0 B
    Volume 1 C NTFS Partition 30 GB Healthy System
    Volume 2 E NTFS Partition 10 GB Healthy

    DISKPART> select Volume 2
    Volume 2 is the selected volume.

    DISKPART> extend disk=2
    DiskPart successfully extended the volume.
    DISKPART> exit
    Leaving DiskPart...

    Note: Where 2 above is the disk volume number of the volume to extend.

    Note: Ensure to choose the correct volume. The Size is the old value.

    Note: If you are in Windows 2003, and when you see the error The volume you have selected may not be extended. Please select another volume and try again, refer the Microsoft Knowledge Base article 841650.

  9. In Windows 2008, click Start > Computer Management > Disk Manager, right-click on the partition and select Extend Volume. For more information, see the Microsoft Knowledge Base article 325590.

    Note: The preceding links were correct as of March 14, 2013. If you find a link is broken, provide feedback and a VMware employee will update the link.

  10. Power off and detach the disk from the helper virtual machine. Keep all default settings and do not delete the VMDK from the disk.

  11. Power on the first virtual machine and verify the disk size change.

To expand VMDK and extend a partition using the vSphere Web Client:
  1. Log in to the VMware ESX/ESXi host through the console or SSH as the user root . Verify that the virtual machine does not have any snapshots in the virtual machine's directory and look for Delta files. Run the command:

    #ls -lah /vmfs/volumes/datastore_name/vm_name/*delta*
    -rw------- 1 root root 1.8G Oct 10 10:58 vm_name-000001-delta.vmdk


    Note: For more information on:

  2. If the virtual machine does have snapshots, commit them by running these commands:

    #vmware-cmd -l /vmfs/volumes/datastore_name/vm_name/vm_name.vmx
    #vmware-cmd /vmfs/volumes/datastore_name/vm_name/vm_name.vmx removesnapshots removesnapshots() = 1


    Note: For committing snapshots on an ESXi 5.1 or later host, see Committing snapshots on ESXi host from command line (1026380).

  3. Power off the virtual machine.

    Note: The virtual machine can be powered on to increase the vmdk size in steps 4 and 5. However ensure to power off the virtual machine after increasing VMDK size.

  4. Log in to the vSphere Web Client and navigate to Virtual Machines and Templates.

  5. Right-click on the virtual machine with the hard disk you want expand the hard disk and select Edit Settings....

  6. To extend the C: partition, find a helper virtual machine and attach the disk from the first virtual machine to the helper.

    To add an existing virtual disk to the helper virtual machine:

     

    1. Right-click on the helper virtual machine and select Edit Settings....

    2. Select Existing Hard Disk from the New Device menu and click Add.

    3. Navigate to the location of the disk and select it.

      Note: A helper virtual machine is a virtual machine that has the same operating system to which you attach the disk.

    4. Click OK to add the disk to the helper virtual machine

  7. Start the virtual machine.

  8. Verify the volume in question has been mounted and has been assigned a drive letter. This can be set in Windows Disk Management or by selecting the volume and typing assign from within the DiskPart command.

    In versions of windows prior to 2008, open command prompt and run the DiskPart command:

    C:\Documents and Settings\username>diskpart

    Microsoft DiskPart version 5.1.3565
    Copyright (C) 1999-2003 Microsoft Corporation.
    On computer: USERNAME-HELPER-VM
    DISKPART> list volume

    Volume ### Ltr Label Fs Type Size Status Info
    ---------- --- ----------- ----- ---------- ------- --------- --------
    Volume 0 D CD-ROM 0 B
    Volume 1 C NTFS Partition 30 GB Healthy System
    Volume 2 E NTFS Partition 10 GB Healthy

    DISKPART> select Volume 2
    Volume 2 is the selected volume.

    DISKPART> extend disk=2
    DiskPart successfully extended the volume.
    DISKPART> exit
    Leaving DiskPart...

    Note: Where 2 above is the disk volume number of the volume to extend.

    Note: Ensure to choose the correct volume. The Size is the old value.

    Note: If you are in Windows 2003, and when you see the error: The volume you have selected may not be extended. Please select another volume and try again, refer the Microsoft Knowledge Base article 841650.

  9. In Windows 2008, click Start > Computer Management > Disk Manager, right-click on the partition and select Extend Volume. For more information, see the Microsoft Knowledge Base article 325590.

    Note: The preceding links were correct as of March 14, 2013. If you find a link is broken, provide feedback and a VMware employee will update the link.

  10. Power off and detach the disk from the helper virtual machine. Keep all default settings and do not delete the VMDK from the disk.

  11. Power on the first virtual machine and verify the disk size change.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8551823/viewspace-1669196/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8551823/viewspace-1669196/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值