虽然大部分用户是在Windows环境下使用虚拟机安装Linux以体验Linux环境的,此方法比较简单,此处略过。本文主要面向在Linux环境下使用虚拟机安装Linux。
1. VirtualBox
VirtualBox 是一款开源虚拟机软件。VirtualBox 是由德国 Innotek 公司开发,由Sun Microsystems公司出品的软件,使用Qt编写,在 Sun 被 Oracle 收购后正式更名成 Oracle VM VirtualBox。VirtualBox号称是最强的免费虚拟机软件,它不仅具有丰富的特色,而且性能也很优异。它简单易用,可虚拟的系统包括Windows(从Windows 3.1到Windows 10、Windows Server 2012,所有的Windows系统都支持)、Mac OS X、Linux、OpenBSD、Solaris、IBM OS2甚至Android等操作系统。
安装VirtualBox:Linux_Downloads – Oracle VM VirtualBox
虽然页面提供了二进制文件,但是不如把软件源添加到库中,可以使用包管理器安装和卸载,并且还可以提供更新。
(1)deb
Add the following line to your /etc/apt/sources.list. For Debian 11 and older, replace ‘<mydist>‘ with ‘bullseye‘, ‘buster‘, or ‘stretch‘. For Ubuntu 22.04 and older, ‘replace ‘<mydist>‘ with ‘jammy‘, ‘eoan‘, ‘bionic‘, ‘xenial‘,
deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian <mydist> contrib
The Oracle public key for verifying the signatures can be downloaded here. You can add these keys with
sudo gpg --dearmor oracle_vbox_2016.asc --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
or combine downloading and registering:
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
The key fingerprint for oracle_vbox_2016.asc is
B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
To install VirtualBox, do
sudo apt-get update sudo apt-get install virtualbox-6.1
Replace virtualbox-6.1 by virtualbox-6.0 or virtualbox-5.2 to install the latest VirtualBox 6.0 or 5.2 build.
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
If you previously added the Oracle key(s) to your default keyring (now considered insecure), remove them again with:
sudo apt-key remove 5CDFA2F683C52980AECF sudo apt-key remove D9C954422A4B98AB5139
(As of VirtualBox 3.2, the signing key was changed. The old Sun public key for apt-secure can be downloaded here. Likewise, the Oracle public key for distributions older than Debian 8 and Ubuntu 16.04 can be downloaded here.)
(2)rpm
We provide a yum/dnf-style repository for Oracle Linux/Fedora/RHEL/openSUSE. All .rpm packages are signed. The Oracle public key for rpm can be downloaded here. You can add this key (not normally necessary, see below!) with
sudo rpm --import oracle_vbox.asc
or combine downloading and registering:
wget -q https://www.virtualbox.org/download/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 (Oracle Linux/Fedora/RHEL/CentOS) when using one of the virtualbox.repo files from below as yum downloads and imports the public key automatically! Zypper users should run
zypper refresh
The package signature is checked by yum/dnf/zypper as well:
- Users of Oracle Linux / RHEL can add the Oracle Linux repo file to /etc/yum.repos.d/.
- Users of Fedora can add the Fedora repo file to /etc/yum.repos.d/.
- Users of openSUSE can add the openSUSE repo file to /etc/zypp/repos.d/.