www.virtualbox.org/wiki/Linux_Downloads

http://www.360doc.com/content/12/0313/11/20669_193949223.shtml#

VirtualBox 3.2.12 for Linux ¶

Note: The package architecture has to match the Linux kernel architecture, that is, if you are running a 64-bit kernel, install the appropriate AMD64 package (it does not matter if you have an Intel or an AMD CPU). Mixed installations (e.g. Debian/Lenny ships an AMD64 kernel with 32-bit packages) are not supported. To install VirtualBox anyway you need to setup a 64-bit chroot environment.

Please choose the appropriate package for your Linux distribution:

  • Ubuntu 10.10 ("Maverick Meerkat") i386 | AMD64
  • Ubuntu 10.04 LTS ("Lucid Lynx") i386 | AMD64
  • Ubuntu 9.10 ("Karmic Koala") i386 | AMD64
  • Ubuntu 9.04 ("Jaunty Jackalope") i386 | AMD64
  • Ubuntu 8.04 LTS ("Hardy Heron") i386 | AMD64
  • Debian 6.0 ("Squeeze") i386 | AMD64
  • Debian 5.0 ("Lenny") i386 | AMD64
  • Debian 4.0 ("Etch") i386 | AMD64
  • openSUSE 11.3 i386 | AMD64
  • openSUSE 11.1 / 11.2 i386 | AMD64
  • openSUSE 11.0 i386 | AMD64
  • SUSE Linux Enterprise Server 11 (SLES11) i386 | AMD64
  • SUSE Linux Enterprise Server 10 (SLES10) i386 | AMD64
  • Fedora 14 ("Laughlin") i386 | AMD64
  • Fedora 13 ("Goddard") i386 | AMD64
  • Fedora 12 ("Constantine") i386 | AMD64
  • Fedora 11 ("Leonidas") i386 | AMD64
  • Fedora 9 ("Sulphur") / 10 ("Cambridge") i386 | AMD64
  • Mandriva 2010.0 / 2010.1 i386 | AMD64
  • Mandriva 2009.1 i386 | AMD64
  • Red Hat Enterprise Linux 6 ("RHEL6") i386 | AMD64
  • Red Hat Enterprise Linux 5 ("RHEL5") / Oracle Enterprise Linux 5 ("OEL5") / CentOS 5 i386 | AMD64
  • Red Hat Enterprise Linux 4 ("RHEL4") / Oracle Enterprise Linux 4 ("OEL4") / CentOS 4 i386
  • Turbolinux 11 i386 | AMD64
  • All distributions i386 | AMD64

You might want to compare the

to verify the integrity of downloaded packages.

Debian-based Linux distributions ¶

Add one of the following lines according to your distribution to your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian maverick non-free
deb http://download.virtualbox.org/virtualbox/debian lucid non-free
deb http://download.virtualbox.org/virtualbox/debian karmic non-free
deb http://download.virtualbox.org/virtualbox/debian jaunty non-free
deb http://download.virtualbox.org/virtualbox/debian intrepid non-free
deb http://download.virtualbox.org/virtualbox/debian hardy non-free
deb http://download.virtualbox.org/virtualbox/debian squeeze non-free
deb http://download.virtualbox.org/virtualbox/debian lenny non-free
deb http://download.virtualbox.org/virtualbox/debian etch non-free

The Oracle public key for apt-secure can be downloaded here. You can add this key with

sudo apt-key add oracle_vbox.asc

or combine downloading and registering:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

The key fingerprint is

7B0F AB3A 13B9 0743 5925  D9C9 5442 2A4B 98AB 5139
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>

(As of VirtualBox 3.2, the signing key was changed. The old Sun public key for apt-secure can be downloaded here.)

To install VirtualBox, do

sudo apt-get update
sudo apt-get install virtualbox-3.2

Replace virtualbox-3.2 by

  • virtualbox-3.1 to install VirtualBox 3.1.8
  • virtualbox-3.0 to install VirtualBox 3.0.14
  • virtualbox-2.2 to install VirtualBox 2.2.4
  • virtualbox-2.1 to install VirtualBox 2.1.4
  • virtualbox-2.0 to install VirtualBox 2.0.12
  • virtualbox to install VirtualBox 1.6.6

Note: Ubuntu/Debian users might want to install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrvvboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade. For Debian it is available in Lenny backports and in the normal repository for Squeeze and later. The dkms package can be installed through the Synaptic Package manager or through the following command:

sudo apt-get install dkms

What to do when experiencing The following signatures were invalid: BADSIG ... when refreshing the packages from the repository?

# sudo -s -H
# apt-get clean
# rm /var/lib/apt/lists/*
# rm /var/lib/apt/lists/partial/*
# apt-get clean
# apt-get update

RPM-based Linux distributions ¶

Starting with VirtualBox 3.0.12 we provide a yum-style repository for Fedora/RHEL/openSUSE. Note that 3.0.x .rpm packages are named VirtualBox-3.0.x while 3.1.x .rpm packages are named VirtualBox-3.1-3.1.x. This naming scheme allows to use the older 3.0.x packages without changing the repository.

Furthemore, all .rpm packages are signed. The Oracle public key for rpm can be downloaded here. You can add this key (not necessary for yum users, see below!) with

sudo rpm --import oracle_vbox.asc

or combine downloading and registering:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | rpm --import -

The key fingerprint is

7B0F AB3A 13B9 0743 5925  D9C9 5442 2A4B 98AB 5139
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>

After importing the public key, the package signature can be checked with

rpm --checksig PACKAGE_NAME

Note that importing the key is not necessary for yum users (Fedora/RHEL/CentOS) when using one of the virtualbox.repo files from below as yum downloads and imports the public key automatically''

The package signature is checked by yum/zypper as well:

 

 

 

 

 

 

#################################

 

http://blog.neten.de/?p=241

直接在Server上安装virtualbox-ose(Open Source Edition)版本后, 启动老是提示出错:

MyServer:~#/etc/init.d/virtualbox-ose start
* Starting VirtualBox host networking...          [ OK ]
* Starting VirtualBox kernel module vboxdrv
* No suitable module for running kernel found.

后来发现官方网站上闭源版本的介绍, 真是很详尽: http://www.virtualbox.org/wiki/Linux_Downloads

MyServer:~#vi /etc/apt/sources.list

添加一句:

deb http://download.virtualbox.org/virtualbox/debian lucid contrib
MyServer:~#wget http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
MyServer:~# apt-key add oracle_vbox.asc
MyServer:~#wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
MyServer:~# apt-get update
MyServer:~# apt-get install virtualbox-4.0

第一次运行出错:

MyServer:~# /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules							[ OK ]
* Uninstalling old VirtualBox DKMS kernel modules					[ OK ]
* Trying to register the VirtualBox kernel modules using DKMS
Error! Your kernel headers for kernel 2.6.32-28-server cannot be found at
/lib/modules/2.6.32-28-server/build or /lib/modules/2.6.32-28-server/source.
 
* Failed, trying without DKMS
* Recompiling VirtualBox kernel modules
* Look at /var/log/vbox-install.log to find out what went wrong

查找错误日志 /var/log/vbox-install.log 发现提示要安装linux-headers-2.6.32-28-server

apt-get install linux-headers-2.6.32-28-server

或者

apt-get install linux-headers-`uname -r`
apt-get install linux-headers-generic

再次启动就正常了

MyServer:~# /etc/init.d/vboxdrv start
* Starting VirtualBox kernel modules   								[ OK ]

运行Setup看看:

MyServer:~# /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules							[ OK ]
* Uninstalling old VirtualBox DKMS kernel modules					[ OK ]
* Trying to register the VirtualBox kernel modules using DKMS       			[ OK ]
* Starting VirtualBox kernel modules

如果Linux内核升级后,出现 Failed, trying without DKMS

/etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules                                    [ OK ]
* Uninstalling old VirtualBox DKMS kernel modules                       [ OK ]
* Removing old VirtualBox netadp kernel module                          [ OK ]
* Removing old VirtualBox netflt kernel module                          [ OK ]
* Removing old VirtualBox kernel module                                 [ OK ]
* Trying to register the VirtualBox kernel modules using DKMS
* Failed, trying without DKMS
* Recompiling VirtualBox kernel modules                                 [ OK ]
* Starting VirtualBox kernel modules                                    [ OK ]

那就安装dkms

apt-get install dkms

好了, 现在可以用普通用户的身份来使用虚拟机了
Ubuntu1010是网上下载的IDE硬盘系统
Ubuntu1004是自己装的Sata硬盘系统
在上传虚拟机镜像之前,最好在本地打开虚拟机,清除一下网卡MAC addresses的Cache后再关机:

sudo rm /etc/udev/rules.d/70-persistent-net.rules

创建Windows的虚拟机

user@MyServer:~$VBoxManage createvm --name Ubuntu1010 --register
Virtual machine 'Ubuntu1010' is created and registered.
UUID: b066726c-8559-48f1-b998-fd7ad742e7ce
Settings file: '/home/user/VirtualBox VMs/Ubuntu1010/Ubuntu1010.vbox'
 
user@MyServer:~$VBoxManage createvm --name Ubuntu1004 --register
Virtual machine 'Ubuntu1004' is created and registered.
UUID: 9e2a7030-953e-4935-aad7-07de8269ab1c
Settings file: '/home/www/VirtualBox VMs/Ubuntu1004/Ubuntu1004.vbox'

顺便贴一下如何删除虚拟机,包括虚拟机文件, 下手前要三思:

user@MyServer:~$VBoxManage unregistervm Ubuntu1004 --delete

创建虚拟机所需的存储控制器

user@MyServer:~$VBoxManage storagectl Ubuntu1010 --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on
user@MyServer:~$VBoxManage storagectl Ubuntu1004 --name "SATA Controller" --add sata --controller IntelAHCI --hostiocache on

网上下载一个已经装好了的Virtualbox镜像 (user/passwd: ubuntu/reverse), 解压, 移到相应目录下

user@MyServer:~$wget http://downloads.sourceforge.net/project/virtualboximage/Ubuntu%20Linux/10.10/Ubuntu%2010.10.vdi.bz2
bzip2 -d Ubuntu\ 10.10.vdi.bz2
mv Ubuntu\ 10.10.vdi /home/user/VirtualBox\ VMs/Ubuntu1010/Ubuntu1010.vdi
 
user@MyServer:~$mv Ubuntu\ 1004.vdi /home/user/VirtualBox\ VMs/Ubuntu1004/Ubuntu1004.vdi

添加硬盘到虚拟机

user@MyServer:~$VBoxManage storageattach Ubuntu1010 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /home/user/VirtualBox\ VMs/Ubuntu1010/Ubuntu1010.vdi
 
user@MyServer:~$VBoxManage storageattach Ubuntu1004 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /home/user/VirtualBox\ VMs/Ubuntu1004/Ubuntu1004.vdi

配置虚拟机网卡(桥接模式):

user@MyServer:~$VBoxManage modifyvm Ubuntu1010 --acpi on --memory 1024 --nic1 bridged --cableconnected1 on --bridgeadapter1 eth0
user@MyServer:~$VBoxManage modifyvm Ubuntu1004 --acpi on --memory 4096 --nic1 bridged --cableconnected1 on --bridgeadapter1 eth0

查看桥接状态:

user@MyServer:~$VBoxManage list bridgedifs
user@MyServer:~$VBoxManage showvminfo Ubuntu1004

可以看看更详细的桥接方法:
http://blog.csdn.net/Dreamcode/archive/2009/08/20/4464994.aspx
不知道几种网络连接方式到底有什么区别的, 可以看看VMWare的介绍, 原理一样:
http://bbs.neten.de/viewthread.php?tid=988

想追踪网络,保存在trace.pcap文件中:

user@MyServer:~$VBoxManage modifyvm Ubuntu1004 --nictrace1 on --nictracefile1 trace.pcap

取消追踪

user@MyServer:~$VBoxManage modifyvm Ubuntu1004 --nictrace1 off

启动虚拟机, headless也就是无头模式, 显示器就是电脑的头, 形象吧

user@MyServer:~$VBoxManage startvm Ubuntu1010 --type headless
user@MyServer:~$VBoxManage startvm Ubuntu1004 --type headless

如果你装的是Windows, 想用RDP登录, 还想把3389改掉:

user@MyServer:~$VBoxManage modifyvm Windows2008 --vrdp on
user@MyServer:~VBoxManage modifyvm Windows2008 --vrdpport 3390

查看系统中正在运行的虚拟机:

user@MyServer:~$VBoxManage list runningvms
"Ubuntu1010" {b066726c-8559-48f1-b998-fd7ad742e7ce}

关机

user@MyServer:~$VBoxManage controlvm Ubuntu1010 poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

poweroff 的兄弟姐妹们:

pause resume reset savestate acpipowerbutton acpisleepbutton

如果磁盘空间不够了, 那VBox4.0支持resize:

user@MyServer:~$VBoxManage modifyhd Ubuntu1010.vdi --resize 40000

clone一个虚拟机:

user@MyServer:~$VBoxManage clonehd Ubuntu1004.vdi destination.vdi

什么? 不想这么折腾了, 那删了吧:

user@MyServer:~$VBoxManage unregistervm Ubuntu1010 --delete

=======================

设置ssh端口转发:

user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 22222

错误记录:

user@MyServer:~$VBoxManage startvm Ubuntu1004 --type headless
Waiting for the VM to power on...
VBoxManage: error: Configuration error: Failed to get the "MAC" value (VERR_CFGM_VALUE_NOT_FOUND).
VBoxManage: error: Unknown error creating VM (VERR_CFGM_VALUE_NOT_FOUND)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Console, interface IConsole, callee

可能因为原来设置过nic2, 还给nic2设置了端口转发, 后来删除了nic2, 却忘了把转发删除:
设置:

user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/Protocol" TCP
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/GuestPort" 22
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/HostPort" 22222

删除:

user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/Protocol"
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/GuestPort"
user@MyServer:~$ VBoxManage setextradata "Ubuntu1004" "VBoxInternal/Devices/pcnet/1/LUN#1/Config/guestssh/HostPort"

升级:

如果升级遇到错误信息:

VirtualBox is currently running. Please close it and try again...

那就找到虚拟机进程, 然后杀掉

ps -aux | grep virtualbox
root     12909  0.0  0.0   7624   920 pts/0    S+   12:30   0:00 grep virtualbox
user     13438  0.0  0.0 167956  2628 ?        Sl   May08  13:14 /usr/lib/virtualbox/VBoxSVC --auto-shutdown

 

 

 

posted @ 2012-03-13 13:34  陳聽溪  阅读(1641)  评论(0)    收藏  举报