一、通过vmware-vdiskmanager增加虚拟机Linux硬盘空间
按Win+R键调出运行对话框,输入“cmd”并按回车键启动命令提示符窗口。
C:\Documents and Settings\hjun>D:
D:\Program Files\VMware>cd "VMware Workstation" (进入vmware工具安装目录,我的目录在D:\Program Files\VMware\VMware Workstation)
D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager(运行该命令可以查看命令的使用方法)
VMware Virtual Disk Manager - build 703057.
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>)
D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager -x 50GB "I:\Virtu
al Machines\Ubuntu\Ubuntu.vmdk" (参数 -x 表示要扩展虚拟机硬盘空间;紧随其后的数字指要扩展的大小(如12Gb,表示磁盘总量,包含原来的磁盘容量);最后是要操作的虚拟机Linux的具体文件。)
Grow: 0% done.
Received signal 2. (中途意外停止)
D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager -x 30GB "I:\Virtu
al Machines\Ubuntu\Ubuntu.vmdk"
Failed to open the disk 'I:\Virtual Machines\Ubuntu\Ubuntu.vmdk' : The specified
virtual disk needs repair (0xe00003e86).
Failed to open disk 'I:\Virtual Machines\Ubuntu\Ubuntu.vmdk' : The specified vir
tual disk needs repair (0xe00003e86). (再次运行出现该错误)
D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager -R "I:\Virtual Ma
chines\Ubuntu\Ubuntu.vmdk" (上面错误的解决方法)
The virtual disk, 'I:\Virtual Machines\Ubuntu\Ubuntu.vmdk', was corrupted and ha
s been successfully repaired.
D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager -x 30GB "I:\Virtu
al Machines\Ubuntu\Ubuntu.vmdk" (再次运行命令,执行成功)
Grow: 33% done.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
二、虚拟机系统中安装第三方分区工具来调整分区
原文参考: http://hi.baidu.com/yaosheng001/item/c7cb124f7f012ee1a4c066e0
环境说明:
虚拟机版本:VMware® Workstation 7.1.2 build-301548
Linux版本 :Linux version 2.6.18-1.2798.fc6
分区工具 :gparted-live-0.6.4-1.iso
GParted http://gparted.sourceforge.net/
1)设置CD/DVD 加载GParted镜像,勾选Connect at power on。
2)启动到BIOS界面。旧版本VMware 可以直接启动时按F2进BIOS。
3)按“+”将CD-ROM Drive 调为第一启动项,按F10保存并重启。
(待分区调整结束后需改回原样,或将Hard Drive调作第一启动项)
4)按默认选择GParted Live (Default settings),直接Enter。
5)默认不更改keymap,直接Enter。
6)系统语言设置,输入26,回车。注:26 表示简体中文。
7)选择图形系统模式,按默认的(0),直接回车。
第三步:调整分区大小。
1)选择 /dev/sda3,选择“更改大小/移动”。
(若有多出的已经格式化的分区,可以选择删除/Delete,使之合并到未分配空间中,方便扩容)
2)拖动箭头扩大分区,再点“更改大小/移动”。
3)选择 Apply (应用,使刚刚的扩容操作生效),确认Apply。
4)等待扩容操作结束。
第四步:退出系统,双击Exit,选择shutdown,OK。提示取出CD再Continue时,直接回车即可。
扩容后使用df命令查看磁盘使用情况如下:
[root@localhost ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 14G 3.1G 82% /
/dev/sda1 190M 11M 171M 6% /boot
tmpfs 252M 0 252M 0% /dev/shm
别忘了恢复VMware Workstation BIOS 第一启动项。