最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

给VMWare下的虚拟机扩充硬盘大小【详细过程记录—>>>最后彻底弄废了虚拟机】

VMWare crifan 6689浏览 0评论

给VMWare下的虚拟机扩充硬盘大小【详细过程记录—>>>最后彻底弄废了虚拟机】

在Vmware下,装了个虚拟机Ubuntu 8.10,装的时候,分给了6G的硬盘空间。
在一段时间使用后,结果空间使用完了,只能想办法扩大虚拟机的硬盘。
最麻烦的办法就是,重新安装虚拟机,然后多分点空间。
后来了解到,Vmware中有个工具叫做vmware-vdiskmanager,
就放在你Vmware安装目录下,此工具可以给虚拟机扩充硬盘大小。
不过,我这个vmware是精简版的,没有此工具,幸好之前装过完整版的,
所以,可以将那下面的vmware-vdiskmanager.exe拷贝到当前虚拟机安装目录下,
同样可以使用,呵呵。

关于vmware-vdiskmanager使用方法,之前转了个帖子:
【转】通过vmware-vdiskmanager增加虚拟机Linux硬盘空间
http://hi.baidu.com/serial_story/blog/item/5eae6e0fa1618a226159f3e7.html

现在,可以好好去折腾试试了。
先声明,如下内容,主要参考此帖:
VMWEAR 虚拟硬盘扩大手记
http://magiczsc.blog.51cto.com/697472/140502

详细解决如下:

1.打开windows下的cmd,转到工具vmware-vdiskmanager所在的目录。

2.看看此工具所提供的功能
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager

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 attempt
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]
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.vmdk
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.mycompany.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>)
3.确定你所要扩充硬盘大小,所对应的是那个虚拟机硬盘文件,其以后缀是.vmdk。
方法1:
打开你虚拟机文件存放的地方,找到一个那个后缀是vmx的文件,用UltraEdit打开后,
找到包含有fileName 和其值是XXXX.vmdk的,我的是下面这句话
“。。。
scsi0:0.fileName = “Ubuntu810-000002.vmdk”
。。。。”
其中,Ubuntu810-000002.vmdk,就是此处我们要对其进行扩容的虚拟机硬盘文件。

方法2:
运行虚拟机,打开虚拟机属性,其中
Hardware->HardDisk(SCSI)的右边的硬盘文件一项里面,就写了对应的硬盘文件名:
Ubuntu810-000002.vmdk

4.对其用工具进行扩容
注意,其中的-x 是表示扩充容量 后面9GB意思是包括原先的,一共的打算扩充到9GB大小。
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 9GB F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk
This disk is part of a snapshot chain in ‘F:LinuxVM_OSubuntu810Ubuntu810.vmx
‘.
The selected operation can only be executed on a disk with no snapshots.
说是不能对包含有snapshot快照的硬盘扩容,
所以,只好去
打开虚拟机->虚拟机快照->快照管理器,然后删除了对应的快照,然后再继续下面操作。

5.由于之前不熟悉,所以,又对其他一些vmdk进行了一些操作:
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 9GB F:LinuxVM_OSubuntu810Ubuntu810-000003.vmdk
Failed to expand the disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000003.vmdk’: The
called function cannot be performed on partial chains. Please open the parent vi
rtual disk (0x500003e83).
具体意思,好像是说,003只是整体的那个002硬盘的一部分,所以不能对003进行扩充。

F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 9GB F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk
Failed to open the disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk’ : The p
arent of this virtual disk could not be opened (0x1700003e8c).
Failed to open disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk’ : The paren
t of this virtual disk could not be opened (0x1700003e8c).

F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 10GB F:LinuxVM_OSubuntu810Ubuntu810.vmdk
Failed to open the disk ‘F:LinuxVM_OSubuntu810Ubuntu810.vmdk’ : The specifie
d virtual disk needs repair (0xe00003e86).
Failed to open disk ‘F:LinuxVM_OSubuntu810Ubuntu810.vmdk’ : The specified vi
rtual disk needs repair (0xe00003e86).

下面是删除快照只好正常操作:
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 10GB F:LinuxVM_OSubuntu810Ubuntu810.vmdk
Failed to open the disk ‘F:LinuxVM_OSubuntu810Ubuntu810.vmdk’ : The specifie
d virtual disk needs repair (0xe00003e86).
Failed to open disk ‘F:LinuxVM_OSubuntu810Ubuntu810.vmdk’ : The specified vi
rtual disk needs repair (0xe00003e86).
虽然可以操作了,但是显示需要修复,估计是上面没删除快照之前的操作弄坏了,
所以需要修复。
对此,对照上面的工具中的使用说明,看了半天,觉得,-R参数,也许可以,
最后发现的确是可以用-R修复:

F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-R F:LinuxVM_OSubuntu810Ubuntu810.vmdk
The virtual disk, ‘F:LinuxVM_OSubuntu810Ubuntu810.vmdk’, was corrupted and h
as been successfully repaired.

F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-R F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk
No errors were found on the virtual disk, ‘F:LinuxVM_OSubuntu810Ubuntu810-00
0002.vmdk’.

下面再重新正常扩充容量,就可以了:
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager
-x 10GB F:LinuxVM_OSubuntu810Ubuntu810.vmdk
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

但是,却显示,需要虚拟机中的第三方工具去扩充分区的大小。

此处的第三方软件,对于我的Ubuntu,根据这人介绍:
如何对VMware内的虚拟主机进行空间扩充(Ubuntu)(
http://blog.sina.com.cn/s/blog_4905fa450100ce19.html
“2.下载分区软件:
VM提供了一些分区软件的下载地址http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1647 ,我用的是GParted.
GParted有几种模式,一种是Live CD,即启动光盘,提供一个ISO文件,名为gparted-live-0.4.3-2.iso,下载该文件后在VMware菜单VM->Removeable Devices->CDROM->Edit,在界面上的Device status标签内选中Connect at power on选项,Connection标签选择‘Use ISO image:’,选中下载的文件,即gparted-live-0.4.3-2.iso。
第二种是光盘模式,不过这种模式不能对宿主机进行分区,所以不能用。”

去Gparted的下载页面:
http://gparted.sourceforge.net/download.php
下载了该软件,具体下载地址:
gparted-live-0.4.5-2(1).iso
文件大小:98.00MB
文件类型:WinRAR 档案文件
完成进度:5.1%
存放位置:F:downloadsoft
URL:http://transact.dl.sourceforge.net/sourceforge/gparted/gparted-live-0.4.5-2.iso
引用页:http://sourceforge.net/project/downloading.php
注释:Download GParted
创建时间:2009-05-28 19:41:07

但是,按照上面提示的去设置后,启动虚拟机,还是不能启动,出现错误:

Cannot open the disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk’ or one of the snapshot disks it depends on.
Reason: The parent virtual disk has been modified since the child was created.

同理,也就无法像这位说的,进入Ubuntu了:
增加虚拟机硬盘分区大小
http://dikar.javaeye.com/blog/361653

去网上百度了一下,找到这个:
虚拟机启动失败: connot open the disk or one of the snapshot disks it depends on
http://bbqdp.spaces.live.com/blog/cns!FCE38046E95EC79C!190.entry?wa=wsignin1.0&sa=382698609
其是通过该对应的被破坏的文件的parentCID,使得正常的关联起来,然后就OK了。

自己就去看自己的对应的Ubuntu810.vmsd
发现,目前已经是正常的,我已经删除了之前3个快照了,所以:
snapshot.numSnapshots = “0”
snapshot.current = “0”
而且去看了对应的文件,里面的依赖关系也是OK的:
Ubuntu810.vmdk 中的:
CID=686aeb42
parentCID=ffffffff
createType=”twoGbMaxExtentSparse”

Ubuntu810-000002.vmdk 中的:
CID=f958798a
parentCID=7d3eed83
createType=”twoGbMaxExtentSparse”
parentFileNameHint=”Ubuntu810-000003.vmdk”

Ubuntu810-000003.vmdk中的:
CID=7d3eed83
parentCID=686aeb42
createType=”twoGbMaxExtentSparse”
parentFileNameHint=”Ubuntu810.vmdk”

也就是,810-003依赖于810,810-002依赖于810-003
父子关系就是810-> 003->002

而去虚拟机选项进行设置的时候,发现其所用的
Ubuntu810-000002.vmdk,
而此硬盘文件,由于被上面扩容了,导致现在无法识别。

无意中,就删除此块硬盘,然后又去
添加->HardDisk->Next,选择
使用一个已存在的虚拟磁盘(E)
选择该选项重新使用一个先前已配置的磁盘

然后Next,浏览选中上面提到的,最根本的那个Ubuntu810.vmdk磁盘文件,
接着,此时添加的硬盘,
系统就能正常识别出来相关信息了:
当前大小: 2.2G 系统释放:4.8G
最大大小 : 10G

这样,就可以继续启动Ubuntu了。

但是,事实证明,此处系统启动虽然能进入桌面,但是系统会挂掉,
跳出2个窗口,后面的盖住了前面的,所以都看不起是啥错误。。。

现在看来,好像是自己的这个虚拟机,比较特殊,所用的磁盘是
Ubuntu810-000002.vmdk ,而不是那个最根本的磁盘文件Ubuntu810.vmdk,
所以,出现这类很怪的问题。
或者是我-x 扩容的时候,不是直接对Ubuntu810-000002.vmdk操作,
而是对Ubuntu810.vmdk进行扩容了,
导致后面再对Ubuntu810-000002.vmdk扩容,而不能操作,出现:
F:LinuxVMWareInstallha_vmware_cn-v6.03ha_vmware_cn-v6.03>vmware-vdiskmanager -x 10GB F:LinuxVM_OSubuntu8
810-000002.vmdk
Failed to open the disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk’ : The parent virtual disk has been mod
ce the child was created (0x1200003e88).
Failed to open disk ‘F:LinuxVM_OSubuntu810Ubuntu810-000002.vmdk’ : The parent virtual disk has been modifie
he child was created (0x1200003e88).

而对那几个vmdk文件进行-R修复的结果,都是没有错误。。。

看来,还是自己操作的问题,搞得最后不能用了。
正常应该是可以的,因为,这位:
救命啊!vmware上的ubuntu空间被我用光了,重启后login不进去
http://cache.baidu.com/c?m=9d78d513d98411e804abd3690d6793395c07c0342bd7a1512091c008c4735a31506695ac265254528884253852f31a09bdb02235775d2feddd8eca5ddcc88f356acd6223706bd91a548349eedc4652907c8d09a9e942b6e4a72594da94cea10f0f8d19187b83f38f5e0612cf78f0636ba5f9c7&p=8b2a9017978011a05ee9d72c4e57&user=baidu
也是可以正常扩容然后用分区工具弄的。

后来,去按照:
http://blog.sina.com.cn/s/blog_4905fa450100ce19.html
“3.重启虚拟主机(模拟光盘启动):
VMware默认不是光盘启动,在重启虚拟主机(Ubuntu)是要先按F2进入BIOS,设定光盘启动。
系统会进入gparted软件的界面,根据提示进入图形界面。具体分区方法见http://gparted.sourceforge.net/larry/resize/resizing.htm

另注:
http://infotech.blogbus.com/logs/19801998.html
“推荐使用gparted,这是parted的一个GUI前端”

中说明的,按F2,设置了光盘启动,
然后启动了gparted,选择了繁体中文语言,进入后,可以看到除了我原先有的6G,还有扩充的4G,然后对4G格式化成ext3后,
重启,结果系统启动后,说是文件系统被破坏了,要允许fsck修复,结果还是没修复成功,
让手动运行fsck修复,这一修复就是N多N多个yes或者no让你选择,无穷无尽的选择,
所以索性放弃了。。。

再次重启系统,系统彻底无法启动,进入了busybox了。。。

至此,彻底决定了,我的系统挂了。。。。
又要重新安装Ubuntu,又要重新折腾里面原有的所有的所有的东西了。。。
包括buildroot,skyeye等等。。。
欲哭无泪啊~~~~~

转载请注明:在路上 » 给VMWare下的虚拟机扩充硬盘大小【详细过程记录—>>>最后彻底弄废了虚拟机】

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (5)

  1. nnd
    finwo11613年前 (2011-09-02)回复
  2. 转走。
    张博的新生活14年前 (2010-11-16)回复
  3. 靠 我跟你的经历是一样!
    匿名网友15年前 (2009-10-14)回复
  4. 经验只谈!有用!顶一下!
    匿名网友15年前 (2009-06-22)回复
  5. 你为什么不备份呢??????????????
    hehe15年前 (2009-06-13)回复
85 queries in 0.173 seconds, using 22.20MB memory