首先,根据以下官方指引进行安装:
https://www.virtualbox.org/wiki/Linux_Downloads
因此,根据你的操作系统的版本号在/etc/apt/sources.list添加以下记录:
deb http://download.virtualbox.org/virtualbox/debian trusty contrib deb http://download.virtualbox.org/virtualbox/debian saucy contrib deb http://download.virtualbox.org/virtualbox/debian raring contrib deb http://download.virtualbox.org/virtualbox/debian quantal contrib deb http://download.virtualbox.org/virtualbox/debian precise contrib deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free deb http://download.virtualbox.org/virtualbox/debian wheezy contrib deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
1) 我们使用的是Ubuntu 12.10,所以需要添加到/etc/apt/sources.list的记录为:
deb http://download.virtualbox.org/virtualbox/debian quantal contrib
2) 下载并注册Orace的apt-secure公共密钥:
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
3) 安装VirtualBox:
sudo apt-get update sudo apt-get install virtualbox-4.3
4) Ubuntu/Debian用户可能需要安装dkms包来确保当Linux内核版本更改时VirtualBox主机内核模块也被更新:
sudo apt-get install dkms
5) 启动VirtualBox,出现一个警告:
[email protected]:/home/aegis# virtualbox WARNING: The vboxdrv kernel module is not loaded. Either there is no module available for the current kernel (3.5.0-17-generic) or it failed to load. Please recompile the kernel module and install it by sudo /etc/init.d/vboxdrv setup You will not be able to start VMs until this problem is fixed.
6) 运行刚才的警告让我运行的命令:
[email protected]:/home/aegis# sudo /etc/init.d/vboxdrv setup Stopping VirtualBox kernel modules ...done. Uninstalling old VirtualBox DKMS kernel modules ...done. Trying to register the VirtualBox kernel modules using DKMSError! Your kernel headers for kernel 3.5.0-17-generic cannot be found. Please install the linux-headers-3.5.0-17-generic package, or use the --kernelsourcedir option to tell DKMS where it‘s located ...failed! (Failed, trying without DKMS) Recompiling VirtualBox kernel modules ...failed! (Look at /var/log/vbox-install.log to find out what went wrong)
7) 这次我们安装刚才的错误所说的linux-headers-3.5.0-17-generic:
[email protected]:/home/aegis# sudo apt-get install linux-headers-3.5.0-17-generic Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: linux-headers-3.5.0-17-generic 0 upgraded, 1 newly installed, 0 to remove and 473 not upgraded. Need to get 946 kB of archives. After this operation, 11.2 MB of additional disk space will be used. Get:1 http://cn.archive.ubuntu.com/ubuntu/ quantal/main linux-headers-3.5.0-17-generic amd64 3.5.0-17.28 [946 kB] Fetched 946 kB in 2s (404 kB/s) Selecting previously unselected package linux-headers-3.5.0-17-generic. (Reading database ... 142701 files and directories currently installed.) Unpacking linux-headers-3.5.0-17-generic (from .../linux-headers-3.5.0-17-generic_3.5.0-17.28_amd64.deb) ... Setting up linux-headers-3.5.0-17-generic (3.5.0-17.28) ... Examining /etc/kernel/header_postinst.d. run-parts: executing /etc/kernel/header_postinst.d/dkms 3.5.0-17-generic /boot/vmlinuz-3.5.0-17-generic
8) 再跑一次/etc/init.d/vboxdrv setup命令:
[email protected]:/home/aegis# sudo /etc/init.d/vboxdrv setup Stopping VirtualBox kernel modules ...done. Uninstalling old VirtualBox DKMS kernel modules ...done. Trying to register the VirtualBox kernel modules using DKMS ...done. Starting VirtualBox kernel modules ...done.
9) 再次启动VirtualBox,看起来没有问题了:
[email protected]:/home/aegis# virtualbox [email protected]:/home/aegis#
在Ubuntu 12.10上安装VirtualBox
时间: 2024-10-28 02:22:26