Ubuntu 8.10上玩转VMware Server 2 (原创)

VMware Server 2是VMware公司免费发布的一个虚拟机软件(不需要破解和SN),功能很强大,支持windows和linux平台,我们获取软件只需要到VMware注册一个帐号就可以下载了。

我们先来注册,打开:http://www.vmware.com/products/server/,点击download那个按钮,然后在右面栏中可以注册,注册好后马上会有两封邮件发到你的邮箱里,一封是你的用户名和密码,另一封是Active你的帐户。

用 你的帐户登入,到达下载页面,下载VMware Server 2 for Linux Operating Systems TAR image这个文件,我使用的是2.0.0 | 122956 - 10/29/08版本,文件名为VMware-server-2.0.0-122956.i386.tar.gz,下载好之后检查一下MD5对不对。然后 记下页面上方的VMware Server 2 for Linux的Licensing,安装的时候需要这个序列号。

我们下面开始正式安装VMware Server 2,首先安装编译需要的程序:
sudo apt-get install linux-headers-`uname -r` build-essential xinetd

将VMware-server-2.0.0-122956.i386.tar.gz解压到我的home目录/home/baiyu,大家可以选择自己的目录:
tar jxvf VMware-server-2.0.0-122956.i386.tar.gz -C /home/baiyu

开始安装:
cd /home/baiyu/vmware-server-distrib
sudo ./vmware-install.pl

安装过程会问很多问题,可以都用默认选项,我在这里只修改了安装目录在/usr/local下,默认的登录用户是root,所以你要为root添加口令:sudo passwd root。

安装过程中会出现vsock模块不能正确挂载的问题,这个问题我们会在后面解决。

安 装成功后,打开firefox,通过https://127.0.0.1:8333就可以访问VMware Server 2了,自动会安装一个插件Vmware Remote Console Plug-in,其他机器也可以通过8333端口访问VMware Server 2,不需要安装任何软件,很方便。

登录虚拟机之后就可以创建虚拟机,也可以直接运行防毒墙的虚拟机了,使用方法比较简单不再多说。

下 面我们来解决vsock模块不能挂载的问题,这个问题是由于vsock模块依赖vmci模块,而vmci模块在2.6.27内核有些符号没有被导出,导致 挂载的时候不能正确引用。VMware Server 2在安装之后把源码放在了/usr/local/lib/vmware/modules/source(我的默认安装目录是/usr/local)目录 下,看到那4个tar文件了吗,我们需要修改vmci和vsock的源码,修改的方法就是将tar解开(如tar xvf vmci.tar),修改代码,然后再创建压缩包(如tar cvf vmci.tar vmci-only/),源码修改参考下面的patch文件,主要是修改Makefile文件,注意Makefile的格式:

diff -dru /tmp/modules/open-vm/modules/linux/vmci/Makefile ./linux/vmci/Makefile
--- /tmp/modules/open-vm/modules/linux/vmci/Makefile 2008-08-08 00:01:44.000000000 -0700
+++ ./linux/vmci/Makefile 2008-11-25 16:47:19.000000000 -0800
@@ -97,8 +97,17 @@

MAKEOVERRIDES := $(filter-out CC=%,$(MAKEOVERRIDES))

-$(DRIVER_KO):
+#
+# Define a setup target that gets built before the actual driver.
+# This target may not be used at all, but if it is then it will be defined
+# in Makefile.kernel
+#
+prebuild:: ;
+postbuild:: ;
+
+$(DRIVER_KO): prebuild
make -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) modules
+ make -C $$PWD SRCROOT=$$PWD/$(SRCROOT) postbuild

else

diff -dru /tmp/modules/open-vm/modules/linux/vmci/Makefile.kernel ./linux/vmci/Makefile.kernel
--- /tmp/modules/open-vm/modules/linux/vmci/Makefile.kernel 2008-08-08 00:01:44.000000000 -0700
+++ ./linux/vmci/Makefile.kernel 2008-11-25 16:54:32.000000000 -0800
@@ -31,7 +31,21 @@

$(DRIVER)-y := $(subst $(SRCROOT)/, , $(patsubst %.c, %.o, $(wildcard $(SRCROOT)/*.c)))

+T := /tmp
+MODPOST_VMCI_SYMVERS := $(T)/VMwareVMCIModule.symvers
+
clean:
rm -rf $(wildcard $(DRIVER).mod.c $(DRIVER).ko /
.tmp_versions Module.symvers Modules.symvers /
+ $(MODPOST_VMCI_SYMVERS) /
$(foreach dir,./,$(addprefix $(dir),.*.cmd .*.o.flags *.o)))
+
+#
+# If this build generated a Module.symvers, copy it to a public place where
+# the VMCI Sockets build will be able to find it.
+#
+postbuild::
+ifeq ($(call vm_check_file,$(SRCROOT)/Module.symvers), yes)
+ cp -f $(SRCROOT)/Module.symvers $(MODPOST_VMCI_SYMVERS)
+endif
+
diff -dru /tmp/modules/open-vm/modules/linux/vsock/Makefile ./linux/vsock/Makefile
--- /tmp/modules/open-vm/modules/linux/vsock/Makefile 2008-08-08 00:01:43.000000000 -0700
+++ ./linux/vsock/Makefile 2008-11-25 16:57:00.000000000 -0800
@@ -97,8 +97,17 @@

MAKEOVERRIDES := $(filter-out CC=%,$(MAKEOVERRIDES))

-$(DRIVER_KO):
+#
+# Define a setup target that gets built before the actual driver.
+# This target may not be used at all, but if it is then it will be defined
+# in Makefile.kernel
+#
+prebuild:: ;
+postbuild:: ;
+
+$(DRIVER_KO): prebuild
make -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) modules
+ make -C $$PWD SRCROOT=$$PWD/$(SRCROOT) postbuild

else

diff -dru /tmp/modules/open-vm/modules/linux/vsock/Makefile.kernel ./linux/vsock/Makefile.kernel
--- /tmp/modules/open-vm/modules/linux/vsock/Makefile.kernel 2008-08-08 00:01:43.000000000 -0700
+++ ./linux/vsock/Makefile.kernel 2008-11-25 16:55:22.000000000 -0800
@@ -32,6 +32,9 @@
# This test is inverted.
EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/sk_filter.c,, -DVMW_HAVE_NEW_SKFILTER )

+T := /tmp
+MODPOST_VMCI_SYMVERS := $(wildcard $(T)/VMwareVMCIModule.symvers)
+
obj-m += $(DRIVER).o

$(DRIVER)-y := $(subst $(SRCROOT)/, , $(patsubst %.c, %.o, $(wildcard $(SRCROOT)/linux/*.c)))
@@ -41,3 +44,16 @@
.tmp_versions Module.symvers Modules.symvers /
$(foreach dir,./ linux/ /
,$(addprefix $(dir),.*.cmd .*.o.flags *.o)))
+
+#
+# The VSock kernel module uses symbols from the VMCI kernel module. Copy the
+# Module.symvers file here so that the Vsock module knows about the VMCI version.
+#
+prebuild::
+ifeq ($(MODPOST_VMCI_SYMVERS),)
+ $(shell echo >&2 "Building VMCI Sockets without VMCI module symbols.")
+else
+ $(shell echo >&2 "Building VMCI Sockets with VMCI module symbols.")
+ cp -f $(MODPOST_VMCI_SYMVERS) $(SRCROOT)/Module.symvers
+endif
+

然后我们重新安装VMware Server 2,运行sudo vmware-config.pl,选项按上次安装的即可,这次vsock可以被正确挂载了。

如果在虚拟机中安装linux出现方向键不能用的情况,可以创建~/.vmware/config文件,其中增加一行:
xkeymap.nokeycodeMap = true
问题就解决了。

我们基本上大功告成了,可以关机休息一会儿了,这时突然发现不能关机了,停到关闭VMware服务那里不动了,实际上没有死机,只是服务没有响应了,大概要等20-30分钟,所有服务才能停掉。

我试过在关机之前手动停止服务是正常的,这说明有某个服务先于VMware服务停止导致了VMware服务停止的时候出现异常(不清楚是哪个服务导致的,网卡的服务有重大嫌疑)。

解决的办法也很简单,我们把/etc/rc2.d和/etc/rc6.d下面的K**vmware改为K01vmware即可,但是如果再用vmware-config.pl安装还需要修改,我们做事要求简捷,于是修改vmware-config.pl。

先给文件加入写权限:sudo chmod 755 /usr/local/bin/vmware-config.pl
打开文件:sudo vi /usr/local/bin/vmware-config.pl
修改link-services函数:
#my $K_level = shift;
my $K_level = "01";
这样再次安装的时候就变为K01vmware了,现在关机、重启都没有问题了,速度很快。

到这里我们的VMware Server 2就安装好了,VMware Server 2和linux配合起来还有很多神奇的用法,当然最神奇的地方就是everything is free and everything is open。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值