担心创建的虚拟机硬盘容量太大会占用真正的硬盘空间,把硬盘的容量设置得很小,可是等到给虚拟机装好系统后再装其他的软件,才发现硬盘容量不够用了。如果重建虚拟机,还要重新再装一遍操作系统,非常麻烦,而在VMware中又不能直接修改虚拟机的硬盘容量大小,真是麻烦。经过多方请教高人,终于找到了解决之道。
其实在VMware安装目录下就有一个vmware-vdiskmanager.exe程序,它是一个命令行工具,可用来修改虚拟机硬盘的大小。方法如下:
第一步:按Win+R键调出运行对话框,输入“cmd”并按回车键启动命令提示符窗口。
第二步:进入VMware的安装目录(比如我的安装目录为:D:/Program Files/VMware/VMware Workstation),在命令提示符后输入"vmware-vdiskmanager",什么参数也不加直接按回车键,可显示这一命令的说明。
第三步:参考说明,执行类似下面的命令:vmware-vdiskmanager -x l6Gb "D:/VMware/WinXP/Windows XP Professional.vmdk" 参数"-X"表示要扩展虚拟机硬盘空间,紧随其后的数字是要扩展的大小(本例为扩展到16GB,这是一个磁盘总量,包含了原先的磁盘容量)。最后是指定要操作的虚拟机磁盘的具体文件,因为路径名中有空格,所以必须以双引号括起来。按回车键开始执行,执行完毕,退出命令提示符窗口,重启VMware,会发现虚拟机硬盘空间已变成16GB了。
如果原来的虚拟机硬盘已被分成了多个分区,那么在通过vmware-vdiskmanager.exe扩大了硬盘空间后还得在盛拟机系统中安装第三方分区工具对虚拟机分区做出调整。详细信息可参阅:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
新建虚拟机时,为ubuntu划分出了15G的硬盘大小,经过一段时间的折腾,再加上这段时间安装QT,15G的硬盘大小明显不够用了,只剩下2G的大小。所以想到将硬盘扩大。下面给出一种硬盘扩大的方法。
具体操作如下:
1、开始-->运行 输入 cmd
2、set path=d:/vmware/vmware workstation
其中d:/vmware/vmware workstation是VMware的安装路径。
3、切换到ubuntu硬盘的存放目录,我的是存放在F:/ubuntu下。即:cd f:/ubuntu
4、查看当前目录下的*.vmdk文件。使用 dir 命令即可。可以看到你要修改的虚拟机硬盘的文件,我的是ubuntu.vmdk
5、修改虚拟机硬盘的大小。使用如下命令:
vmware-vdiskmanager.exe -x 20Gb "ubuntu.vmdk"
其中vmware-vdiskmanager.exe是VMware自带的硬盘管理工具,x是扩大硬盘的大小,20Gb是扩大到的大小,ubuntu.vmdk是要扩大的虚拟硬盘名称。
6、等待差不多30分钟。与机器的性能有关。等到系统出现如下提示,操作完成。
Grow: 100% done
附:给出vmware-vdiskmanager.exe的一些帮助文件
VMware Virtual Disk Manager - build 118166.
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 drive-letter 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.
Other Options:
-q : do not log messages
Additional options for create and convert:
-a <adapter> : (for use with -c only) adapter type
(ide, buslogic or lsilogic)
-s <size> : capacity of the virtual disk
-t <disk-type> : disk type id
Options for remote disks:
-h <hostname> : hostname of remote server
-u <username> : username for remote server
-f <filename> : file containing password
-P <port> : optional TCP port number (default: 902)
-S : specifies that the source disk is remote, by default
the remote options are assumed to refer to the
destination.
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
The capacity can be specified in sectors, KB, MB or GB.
The acceptable ranges:
ide adapter : [1MB, 950.0GB]
scsi adapter: [1MB, 950.0GB]
下面是8个例子:
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>)
界面中并没有提供增加硬盘容量的方法。
只能在命令行形式下执行。
安装所在盘的Program Files/VMware/VMware Workstation下有一个vmware-vdiskmanager.exe,就是它。
命令参数如下:
------------------------------------------------------------------
Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>
Offline disk manipulation utility
Options:
-c : create disk; need to specify other create options
-d : defragment the specified virtual disk
-k : shrink the specified virtual disk
-n <source-disk> : rename the specified virtual disk; need to
specify destination disk-name
-p : prepare the mounted virtual disk specified by
the drive-letter for shrinking
-q : do not log messages
-r <source-disk> : convert the specified disk; need to specify
destination disk-type
-x <new-capacity> : expand the disk to the specified capacity
Additional options for create and convert:
-a <adapter> : (for use with -c only) adapter type (ide, buslogic o
r lsilogic)
-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
The capacity can be specified in sectors, Kb, Mb or Gb.
The acceptable ranges:
ide adapter : [100.0Mb, 950.0Gb]
scsi adapter: [100.0Mb, 950.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 -k myDisk.vmdk
ex 7: vmware-vdiskmanager.exe -p <mount-point>
(A virtual disk first needs to be mounted at <mount-point>)
-----------------------------------------------------------------
其中的-x参数就是用来扩容的……
如这个:vmware-vdiskmanager.exe -x 36Gb myDisk.vmdk
-------------------------------------------------------
我的执行过程:
E:/Program Files/VMware/VMware Workstation>set path=%path%;E:/Program Files/VMwa
re/VMware Workstation
E:/Program Files/VMware/VMware Workstation>e:
E:/Program Files/VMware/VMware Workstation>cd E:/VM_Machine
E:/VM_Machine>cd Windows Server 2003 Standard Edition
E:/VM_Machine/Windows Server 2003 Standard Edition>dir *.vmdk
2007/07/20 11:17 1,588,527,104 Windows Server 2003 Standard Edition-s001
.vmdk
2007/07/20 11:17 65,536 Windows Server 2003 Standard Edition-s002
.vmdk
2007/07/20 10:56 448 Windows Server 2003 Standard Edition.vmdk
E:/VM_Machine/Windows Server 2003 Standard Edition>vmware-vdiskmanager.exe -x 4G
Windows Server 2003 Standard Edition-s001.vmdk
Diskname or some other argument is missing.
E:/VM_Machine/Windows Server 2003 Standard Edition>vmware-vdiskmanager.exe -x 4G
"Windows Server 2003 Standard Edition-s001.vmdk"
Using log file C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/1/vmware-Administrator/vdiskma
nager.log
The file 'Windows Server 2003 Standard Edition-s001.vmdk' appears to be a sub-co
mponent of a virtual disk.
Did you mean 'Windows Server 2003 Standard Edition.vmdk'?
Failed to open disk 'Windows Server 2003 Standard Edition-s001.vmdk' : The file
specified is not a virtual disk (16).
E:/VM_Machine/Windows Server 2003 Standard Edition>vmware-vdiskmanager.exe -x 4G
"Windows Server 2003 Standard Edition.vmdk"
Using log file C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/1/vmware-Administrator/vdiskma
nager.log
The specified disk size does not fall within acceptable range.
The acceptable ranges:
ide adapter : [100.0Mb, 950.0Gb]
scsi adapter: [100.0Mb, 950.0Gb]
E:/VM_Machine/Windows Server 2003 Standard Edition>vmware-vdiskmanager.exe -x 4G
b "Windows Server 2003 Standard Edition.vmdk"
Using log file C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/1/vmware-Administrator/vdiskma
nager.log
The old geometry C/H/S of the disk is: 261/255/63
The new geometry C/H/S of the disk is: 522/255/63
Disk expansion completed successfully.
WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
==================================================================
总结一下:
1。文件名应该用双引号括起来。
2。vmdk文件用不带001,002的最短的那个文件名。
3。GB,MB,别忘了B。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yxp200401/archive/2009/07/28/4386611.aspx