前言
在 VirtualBox 4.1.10 软件中安装 openSUSE 12.1 操作系统后,它已经自带了 VBoxGuestAdditions 4.1.4,如下所示:
ben@vbox:~> zypper search virtualbox-guestLoading repository data...Reading installed packages...S | Name | Summary | Type--+------------------------------+--------------------------------------------+-------- | virtualbox-guest-kmp-default | Guest kernel modules for VirtualBox | packagei | virtualbox-guest-kmp-desktop | Guest kernel modules for VirtualBox | package | virtualbox-guest-kmp-pae | Guest kernel modules for VirtualBox | packagei | virtualbox-guest-tools | VirtualBox guest tools | packagei | virtualbox-guest-x11 | VirtualBox X11 drivers for mouse and video | packageben@vbox:~>ben@vbox:~> zypper search -s virtualbox-guest-kmp-desktopLoading repository data...Reading installed packages...S | Name | Type | Version | Arch | Repository--+------------------------------+---------+------------------------+--------+-----------------------i | virtualbox-guest-kmp-desktop | package | 4.1.4_k3.1.0_1.1-3.2.3 | x86_64 | 163/Ossi | virtualbox-guest-kmp-desktop | package | 4.1.4_k3.1.0_1.1-3.2.3 | x86_64 | openSUSE-12.1-Ossi | virtualbox-guest-kmp-desktop | package | 4.1.4_k3.1.0_1.1-3.2.3 | x86_64 | openSUSE-12.1-12.1-1.4v | virtualbox-guest-kmp-desktop | package | 4.1.4_k3.1.0_1.1-3.2.3 | i586 | 163/Ossv | virtualbox-guest-kmp-desktop | package | 4.1.4_k3.1.0_1.1-3.2.3 | i586 | openSUSE-12.1-Ossben@vbox:~>ben@vbox:~> zypper info virtualbox-guest-kmp-desktopLoading repository data...Reading installed packages...Information for package virtualbox-guest-kmp-desktop:Repository: 163/OssName: virtualbox-guest-kmp-desktopVersion: 4.1.4_k3.1.0_1.1-3.2.3Arch: x86_64Vendor: openSUSEInstalled: YesStatus: up-to-dateInstalled Size: 413.0 KiBSummary: Guest kernel modules for VirtualBoxDescription:VirtualBox is an extremely feature rich, high performance productfor enterprise customers, it is also the only professional solutionthat is freely available as Open Source Software under the terms of theGNU Public License (GPL).
这样的好处是不用在 VirtualBox 中另外安装增强功能了,坏处是这个增强功能的版本太低了,才 4.1.4,而最新版本是 4.1.10。
现在让我们开始安装 VBoxGuestAdditions 4.1.10 吧。
卸载旧版本的 VBoxGuestAdditions
首先,使用 zypper 命令卸载 VBoxGuestAdditions 4.1.4:
ben@vbox:~> sudo zypper remove virtualbox-guest-kmp-desktop virtualbox-guest-tools virtualbox-guest-x11Loading repository data...Reading installed packages...Resolving package dependencies...The following packages are going to be REMOVED: virtualbox-guest-kmp-desktop virtualbox-guest-tools virtualbox-guest-x113 packages to remove.After the operation, 6.1 MiB will be freed.Continue? [y/n/?] (y):Removing virtualbox-guest-tools-4.1.4-3.2.3 [done]Additional rpm output:redirecting to systemctlWarning: Unit file of created job changed on disk, 'systemctl --system daemon-reload' recommended.insserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesRemoving virtualbox-guest-x11-4.1.4-3.2.3 [done]Removing virtualbox-guest-kmp-desktop-4.1.4_k3.1.0_1.1-3.2.3 [done]
准备工作
然后做一些准备工作:
ben@vbox:~> sudo zypper refreshRepository '163/NON-Oss' is up to date.Repository '163/Oss' is up to date.Repository '163/Update' is up to date.Repository 'Updates for openSUSE 12.1 12.1-1.4' is up to date.Repository 'openSUSE-12.1-Non-Oss' is up to date.Repository 'openSUSE-12.1-Oss' is up to date.All repositories have been refreshed.ben@vbox:~> sudo zypper updateLoading repository data...Reading installed packages...Nothing to do.ben@vbox:~> sudo zypper install make gccLoading repository data...Reading installed packages...'gcc' is already installed.No update candidate for 'gcc-4.6-15.1.3.x86_64'. The highest available version is already installed.'make' is already installed.No update candidate for 'make-3.82-147.1.2.x86_64'. The highest available version is already installed.Resolving package dependencies...Nothing to do.ben@vbox:~> uname -aLinux vbox 3.1.9-1.4-desktop #1 SMP PREEMPT Fri Jan 27 08:55:10 UTC 2012 (efb5ff4) x86_64 x86_64 x86_64 GNU/Linuxben@vbox:~> sudo zypper install kernel-desktop-develLoading repository data...Reading installed packages...'kernel-desktop-devel' is already installed.No update candidate for 'kernel-desktop-devel-3.1.9-1.4.1.x86_64'. The highest available version is already installed.Resolving package dependencies...Nothing to do.
也就是说要先安装好 make、gcc 和 kernel-desktop-devel 软件包,从上面可以看出,我的机器上以前已经安装过这些软件包了。
另外,需要先安装好 dkms 软件包:
Be sure to install DKMS before installing the Linux Guest Additions. If DKMS is not available or not installed, the guest kernel modules will need to be recreated manually whenever the guest kernel is updated using the command/etc/init.d/vboxadd setupas root.
但是 openSUSE 操作系统不支持 dkms,而其他主流的 Linux 操作系统基本上都支持 dkms。这是很糟糕的,如上所述,以后 openSUSE 操作系统的内核 kernel 有升级的话,每次都要手动运行一次 sudo /etc/init.d/vboxadd setup 命令了。
开始安装
现在,把 VirtualBox 软件安装目录下的 VBoxGuestAdditions.iso 文件拷贝到 openSUSE 操作系统中,然后:
ben@vbox:~/repo/VBoxGuestAdditions> 7z x VBoxGuestAdditions.iso7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)Processing archive: VBoxGuestAdditions.isoExtracting 32BitExtracting 32Bit/OS2Extracting 32Bit/OS2/VBoxGuest.sysExtracting 32Bit/OS2/VBoxService.exeExtracting 32Bit/OS2/gengradd.dllExtracting 32Bit/OS2/libc063.dllExtracting 32Bit/OS2/readme.txtExtracting 32Bit/OS2/vboxmouse.sysExtracting 32Bit/Readme.txtExtracting 64BitExtracting 64Bit/Readme.txtExtracting AUTORUN.INFExtracting VBoxLinuxAdditions.runExtracting VBoxSolarisAdditions.pkgExtracting VBoxWindowsAdditions-amd64.exeExtracting VBoxWindowsAdditions-x86.exeExtracting VBoxWindowsAdditions.exeExtracting autorun.shExtracting runasroot.shEverything is OkFolders: 3Files: 16Size: 50349560Compressed: 50751488ben@vbox:~/repo/VBoxGuestAdditions> sudo ./VBoxLinuxAdditions.runVerifying archive integrity... All good.Uncompressing VirtualBox 4.1.10 Guest Additions for Linux.........VirtualBox Guest Additions installerinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesRemoving existing VirtualBox DKMS kernel modules doneRemoving existing VirtualBox non-DKMS kernel modules doneBuilding the VirtualBox Guest Additions kernel modulesBuilding the main Guest Additions module doneBuilding the shared folder support module doneBuilding the OpenGL support module doneDoing non-kernel setup of the Guest Additions doneYou should restart your guest to make sure the new modules are actually usedinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesinsserv: warning: script 'S01atop' missing LSB tags and overridesinsserv: warning: script 'atop' missing LSB tags and overridesInstalling the Window System drivers failed(Could not find the X.Org or XFree86 Window System.)
最后的 Installing the Window System drivers 失败是正常的,因为我安装 openSUSE 操作系统是文本模式的,根本没有安装 X-Window。
ben@vbox:~/repo/VBoxGuestAdditions> ll /opttotal 8drwxr-xr-x 8 root root 4096 Mar 4 10:08 mono-2.10.9drwxr-xr-x 8 root root 4096 Mar 17 16:20 VBoxGuestAdditions-4.1.10
可以看出,VBoxGuestAdditions 安装在 /opt 目录下。
最后,重启虚拟机以完成安装:
ben@vbox:~> sudo /sbin/shutdown -r nowBroadcast message from ben@vbox on pts/0 (Sat, 17 Mar 2012 16:27:46 +0800):The system is going down for reboot NOW!
安装后的情况
在 VirtualBox 中为 openSUSE 操作系统分配一个数据空间,名称是 ISO,并且设为 Auto-Mount,如下所示:
那么在启动 openSUSE 操作系统后,在 /media 目录下就有一个相应的以 sf_ 开头目录,如下所示:
ben@vbox:~> df -hFilesystem Size Used Avail Use% Mounted onrootfs 9.1G 2.7G 5.9G 32% /devtmpfs 242M 32K 242M 1% /devtmpfs 246M 0 246M 0% /dev/shmtmpfs 246M 308K 245M 1% /run/dev/sda1 9.1G 2.7G 5.9G 32% /tmpfs 246M 0 246M 0% /sys/fs/cgrouptmpfs 246M 308K 245M 1% /var/runtmpfs 246M 308K 245M 1% /var/locktmpfs 246M 0 246M 0% /medianone 80G 42G 39G 53% /media/sf_ISOben@vbox:~> ll /mediatotal 4drwxrwx--- 1 root vboxsf 4096 Mar 17 14:33 sf_ISO
这个目录是属于 vboxsf 用户组的,所以我们使用以下命令将自己加入这个用户组:
ben@vbox:~> sudo /usr/sbin/usermod -A vboxsf `whoami`ben@vbox:~> grep `whoami` /etc/groupvideo:x:33:bensudo:!:1000:benvboxsf:!:1001:ben
如果这个数据空间不是 Auto-Mount 的,则可以用 sudo mount -t vboxsf ISO /mnt 命令手动安装。
参考资料
- VritualBox User Manual: Chapter 4. Guest Additions
为虚拟机中的 openSUSE 12.1 安装 VBoxGuestAdditions 4.1.10
TAG: