vmware workstation的多个vmdk转换成单个vmdk

将多个vmware的vmdk文件转化成单个文件的方法

通过vmware workstation软件创造出来的虚拟机,在虚拟机目录下有时会出现多个以vmdk后缀名结尾的文件,多个文件占用的空间都很大,感觉很乱,并且这样虚拟机运行的效率也很低。

出现这种情况的原因是在创建虚拟机时,在指定硬盘容量时,选择了Split virtual disk into multiple files(将虚拟磁盘分割为多个文件),并且下面有说明,这种多个文件模式更易于将虚拟机转移到其他的电脑上,并且会降低性能且会占用更多的硬盘空间

如果选择Store virtual disk as a single file模式,虚拟机就会在一个文件中,不仅会提高性能减少占用硬盘空间,而且看着更舒服。

但是这两个模式之间可以转换吗,通过vmware workstation自带的一个工具就可以做到。

在vmware workstation的安装目录下,有一个vmware-vdiskmanager.exe文件,在命令行下执行,可以看到这个软件的用法,如下:

VMware Virtual Disk Manager – build 471780.
Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>
Offline disk manipulation utility
  Operations, only one may be specified at a time:
     -c                   : create disk.  Additional creation options must
                            be specified.  Only local virtual disks can be
                            created.
     -d                   : defragment the specified virtual disk. Only
                            local virtual disks may be defragmented.
     -k                   : shrink the specified virtual disk. Only local
                            virtual disks may be shrunk.
     -n <source-disk>     : rename the specified virtual disk; need to
                            specify destination disk-name. Only local virtual
                            disks may be renamed.
     -p                   : prepare the mounted virtual disk specified by
                            the mount point for shrinking.
     -r <source-disk>     : convert the specified disk; need to specify
                            destination disk-type.  For local destination disks
                            the disk type must be specified.
     -x <new-capacity>    : expand the disk to the specified capacity. Only
                            local virtual disks may be expanded.
     -R                   : check a sparse virtual disk for consistency and atte
mpt
                            to repair any errors.
     -e                   : check for disk chain consistency.
     -D                   : make disk deletable.  This should only be used on di
sks
                            that have been copied from another product.

  Other Options:
     -q                   : do not log messages

  Additional options for create and convert:
     -a <adapter>         : (for use with -c only) adapter type
                            (ide, buslogic, lsilogic). Pass lsilogic for other a
dapter types.
     -s <size>            : capacity of the virtual disk
     -t <disk-type>       : disk type id

  Disk types:
      0                   : single growable virtual disk
      1                   : growable virtual disk split in 2GB files
      2                   : preallocated virtual disk
      3                   : preallocated virtual disk split in 2GB files
      4                   : preallocated ESX-type virtual disk
      5                   : compressed disk optimized for streaming
      6                   : thin provisioned virtual disk – ESX 3.x and above

     The capacity can be specified in sectors, KB, MB or GB.
     The acceptable ranges:
                           ide adapter : [1MB, 2040.0GB]
                           scsi adapter: [1MB, 2040.0GB]
        ex 1: vmware-vdiskmanager.exe -c -s 850MB -a ide -t 0 myIdeDisk.vmdk
        ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
        ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vm
dk
        ex 4: vmware-vdiskmanager.exe -x 36GB myDisk.vmdk
        ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
        ex 6: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 4 -h esx-name.mycomp
any.com \
              -u username -f passwordfile “[storage1]/path/to/targetDisk.vmdk”
        ex 7: vmware-vdiskmanager.exe -k myDisk.vmdk
        ex 8: vmware-vdiskmanager.exe -p <mount-point>
              (A virtual disk first needs to be mounted at <mount-point>)

用法已经说的很清楚了,这里假设需要转化的虚拟机位于F:windows.vmdk,那么通过以下命令操作来实现将多个vmdk文件转化成一个文件:

vmware-vdiskmanager.exe -r “F:\windows.vmdk” -t 0 “F:\b.vmdk”

"C:\Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager.exe" -r "E:\software\软件\win10\Windows 10 x64.vmdk" -t 0 MyNewImage.vmdk

注意目标文件和源文件名不能一样,转换后原有虚拟机仍然存在,删除并新建后,使用现有磁盘添加新的vmdk文件即可。

 

本文转载于:http://www.eumz.com/2013-07/946.html

vmware workstation的多个vmdk转换成单个vmdk

上一篇:Ansible模块lineinfile替换指定行内容、多行replace及j2的shell/yaml


下一篇:Linux 主机性能测试工具