Saturday, October 23, 2021
HomeLinuxAll the Methods To Run a Virtual Machine on Linux System

All the Methods To Run a Virtual Machine on Linux System

Virtual machines are great if you’re trying to deploy a machine into your current operating system without doing any hard partitioning. No matter if you’re a Linux sysadmin or a developer, using a virtual machine is always fun and interesting. Now, you might question that the virtual machines make your original OS slower, and it’s kind of heavy to run on a regular basis. Yes, it’s always a bit heavy to execute virtual machines on the system. Nonetheless, using a virtual machine/Virtual machine on Linux can be a quick solution to test any program or run any application for a short time. Some power users also claim that using a Virtual machine actually increases the work efficiency as it allows you to test or run programs without restarting the entire system.

Virtual Machine on Linux


A virtual machine is a computer inside a computer that is run through a hypervisor. In Linux, the hypervisor type 1 interacts directly with the Kernel to execute the program for creating virtual RAM, data drive, CPU, NIC, and other virtual hardware.

It can be in both 64 or 32-bit architectures. It executes runtime systems and applications inside your actual operating system. If you’ve ever heard about virtual machines, I’m sure you are already familiar with VirtualBox, which is powered by Oracle.

There are many other hypervisors like VirtualBox for Linux systems that you can install and use on your Linux machine. In this post, we will see the methods to run a virtual machine on Linux.

Method 1: Use VirtualBox for Virtual Machine on Linux


VirtualBox is one of the most popular and well-known tools in the world of virtualization for both Linux and Windows. In the very beginning, we will see how to install and use the VirtualBox on Linux distributions.

1. Install VirtualBox On Ubuntu


Installing the VirtualBox on Ubuntu and Debian distributions is easy and straightforward. Since it’s already available in the official Linux repository, we can get it from the repository. First, update your system repository, then run the following aptitude command on the terminal shell with root access to install the latest VirtualBox on your Ubuntu/Debian Linux distribution.

install virtualbox on ubuntu

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

When the installation ends up, you may now run the following command to get the extra packages for VirtualBox in your system.

sudo apt-get install virtualbox—ext–pack

If you face issues installing the VirtualBox on your machine through the official Linux repository, you might need to use Oracle’s repository to get the tool on your system. You can run the following commands on your terminal shell to load the properties software-common set on your machine for VirtualBox.

sudo apt-get install software–properties–common
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add –

Now, add the VirtualBox repository to your system.

echo "deb [arch=amd64] http://virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Finally, you may now reload the system repository and run the following apt command given below to install the VirtualBox on your Ubuntu system.

sudo apt-get update
sudo apt-get install virtualbox–6.1

Lastly, run the wget command set given below to install the VirtualBox extension pack on your system.

wget https://download.virtualbox.org/virtualbox/6.1.26/Oracle_VM_VirtualBox_Extension_Pack-6.1.26.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.26.vbox-extpack

Once you are done with all the installation steps, you may now fire up the VirtualBox on your system from the terminal shell by typing virtualbox in the shell.

virtualbox

2. Install VirtualBox in Fedora Linux


VirtualBox is popular for all Linux distributions as a unique self-hosted virtual machine. Installing the VirtualBox on a Fedora machine is also easy. Since there are a few versions of the Fedora workstation, we will see methods of installing the VirtualBox on most used distributions. First, run the following DNF command set given below to install the development tools and the kernel library tools for Fedora on the system.

sudo dnf -y install @development-tools
sudo dnf -y install kernel-headers kernel-devel dkms elfutils-libelf-devel qt5-qtx11extras

All the Methods to Run a Virtual Machine on Linux

In this stage, we are ready to load the VirtualBox from the official repository and enable the GPG key. Please execute the following command set on your terminal shell according to your workstation. The command cat <<EOF command set will allow you to execute a shell command which has more than one line in the string.

Run the following command supplied below to add the VirtualBox repository and the GPG key on your Fedora 34 workstation.

cat <<EOF | sudo tee /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Fedora $releasever - $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/fedora/34/\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
EOF

On Fedora workstation 33, you can run the following command set to get the VirtualBox repository and the GPG key.

cat <<EOF | sudo tee /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Fedora $releasever - $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/fedora/33/\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
EOF

In the same way, Fedora 32 users need to execute the following string command set on your shell to get the Virtualbox repo, and the GPG key enabled on your Fedora system.

cat <<EOF | sudo tee /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Fedora $releasever - $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/fedora/32/\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
EOF

Finally, you may now run the following DNF commands given below to install the VirtualBox hypervisor on your system.

sudo dnf search virtualbox
sudo dnf install VirtualBox-6.1

3. Install VirtualBox for Virtual Machine in Manjaro Linux


In Arch and Arch-based Linux systems, installing the VirtualBox hypervisor is easier and hassle-free. You can use both GUI and CLI-based methods to get the VirtualBox on Arch Linux. Here, I’m demonstrating the methods of getting the VirtualBox on the Manjaro KDE Linux.

Method 1: GUI Method to Install Virtualbox

Since the Manjaro KDE allows you to access the largest Linux software repository, you can effortlessly use the Pamac GUI tool for installing the Virtualbox Virtual machine on your Linux system. First, open the system search button and look for the Software Add/Remove tool.

install VM on manjaro

Once you open the tool, you can search for VirtualBox in the ‘Browse‘ section. When the Oracle VM VirtualBox appears, click on the ‘Install‘ button from the top-right corner. Then proceed with your system password, and the installation won’t take much longer time if you have a good internet connection.

Method 2: CLI Method to Install VirtualBox on Manjaro

As a Linux user, you might not feel good with GUI methods, and here you can find the command lines for installing VirtualBox on Manjaro and other Arch-based Linux systems through shell commands. You can run the following Pacman commands given below to install VirtualBox on the machine.

sudo pacman -Syu
sudo pacman -Syu virtualbox

Please note the following command given below, in case you need to remove the VirtualBox from your Arch Linux.

sudo pacman -R virtualbox

Method 2: Install QEMU Virtual Machine on Linux


The QEMU stands for Quick emulator, which is an open-source machine virtualized and emulator (Virtual machine) that can be installed on Linux systems. It is a type of emulator that allows you to run another operating system inside your host pc.

For instance, you can run Windows 7 in your Ubuntu system through QEMU. The reason you would use the QEMU is performance; the performance is much better on the QEMU than other virtual machines on Linux.

Specifically, if you have old hardware, you should go with the QEMU for hosting another OS. The architecture design of the QEMU allows you to run the virtually hosted OS into the real hardware on your machine, which might sound crazy but actually increases the performance.

Step 1: Install QEMU on Linux


In the starting, you can run the following command on your Linux machine to check if your system already has any virtual machines installed or not.

lscpu

Since the QEMU virtual machine is already available on the official Linux repository, so doesn’t take a bunch of commands. Please execute the terminal command on your shell with root access accordingly from the commands supplied below.

  • Install QEMU on Arch Linux
pacman -S qemu
  • Execute the following command to get QEMU on Debian/Ubuntu
apt-get install qemu

install qemu on Linux

  • Fedora workstation users can run the DNF command to get the QEMU hypervisor.
dnf install @virtualization
  • If you own an RHEL system, execute the YUM command given below.
yum install qemu-kvm
  • OpenSuSE and SUSE Linux users need to execute the zypper command from below.
zypper install qemu

Step 2: Use QEMU on Linux


Finally, when the QEMU installation ends up, you may now execute the following command to find out the useful QEMU commands for Linux.

ls /usr/bin/qemu-*

If you face issues installing the QEMU hypervisor on your Linux machine through the repository commands, you can always use the source code method to install an open-source package on the Linux machine. All the commands that require to install QEMU via source code are provided below. Please run the commands on your shell with root access to get QEMU Virtual machine on Linux.

wget https://download.qemu.org/qemu-6.1.0.tar.xz
tar xvJf qemu-6.1.0.tar.xz
cd qemu-6.1.0
./configure
make

Method 3: Use VMware Workstation Pro on Linux


As the name explains, the VMware Workstation Pro is a professional tool for virtualizing other operating systems inside the host machine. Installing and using the VMware Virtual machine on Linux is comparatively easy and less complex. It supplies a compiled bundle file that you can simply install on your Linux machine.

1. CLI Method to Install VMware Workstation Pro on Linux


The VMware acts as a Virtual machine on Linux. To install the VMware workstation pro on Linux, please ensure that your system repository is up-to-date. Please run the commands given below accordingly on your terminal shell to update the system repo.

# yum update
# dnf update
# apt-get update && apt-get upgrade

Now, run the following wget command on the shell to download the complied bundle package of VMware workstation pro on your filesystem. Usually, it stores the file inside the Downloads directory. The following commands will be executable on all major Linux distributions.

# wget https://download3.vmware.com/software/wkst/file/VMware-Workstation-Full-16.1.0-17198959.x86_64.bundle

download wget vmware on Linux

When the download ends, run the following chmod command to allow you the execution permission. Your current user on Linux.

# chmod a+x VMware-Workstation-Full-16.1.0-17198959.x86_64.bundle

Now run the commands given below to install the VMware workstation Virtual machine in Linux.

# ./VMware-Workstation-Full-16.1.0-17198959.x86_64.bundle
sudo ./VMware-Workstation-Full-16.1.0-17198959.x86_64.bundle

Finally, type vmware on the shell and hit the Enter button to run the VMware Workstation pro on Linux.

# vmware

If you face issues running the VMware on your Linux system, please execute the command given below.

  • Install the development tools on Fedora and Red Hat Linux.
# yum groupinstall "Development tools"
  • Get the build-essential tools on Debian/Ubuntu systems.
# apt-get install build-essential

If you still face issues running the VMware tool, please make sure that the kernel headers are loaded on the system.

# rpm -qa | grep kernel-headers
# dpkg -l | grep linux-headers

2. GUI Method to Install VMware Workstation Pro on Linux


If you find the CLI methods complex to execute the VMware Virtual machine on Linux, try the GUI method. First, you need to download the VMware bundle package on your filesystem. When the download ends, locate the bundle file in the Downloads directory. Then, right-click on the package and turn on the execution permission from the security tab.

When you’re done setting up the package setup, just double-click on the bundle pack to run it on your system.

If you’re not comfortable with the double-clicking design, you can run the following set of commands to run the VMware on the Linux system.

chmod +x ~/Downloads/VMware-Player*
sudo ~/Downloads/VMware-Player*

Insights!


The entire article has been an elaborated guide to choose and install the right type of hypervisor for running different operating systems inside the host PC. You can jump into your distribution section and get the guidance you need. In the entire post, I’ve gone through the concept of Virtualization, hypervisor, and VMs. Later, I’ve elaborately described the methods to run a virtual machine on Linux.

I hope this post has been informative to you. If you find this post has been helpful to you, please share this post with your friends and the Linux community. You can also write down your opinions in the comment section regarding this post.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

spot_img

Latest Post

Must Read