1. Home
  2. Linux
  3. Host minecraft game on a linux virtual machine

How to host a Minecraft game on a Linux virtual machine

Dedicating an entire Linux PC or server just to run a Minecraft game is a waste of resources. If you’re looking to get a quick Minecraft server running, it’s much better to host it from a Virtual machine.

There are many choices for easy virtualization for modern computers. However, Oracle VM VirtualBox is the best, as it’s cross-platform, easy to use, and is free of charge. In this article, we’re going to explain how you can use Oracle’s VirtualBox to host a Minecraft game on a Linux virtual machine.

Install VirtualBox

In this section of the tutorial, we’ll be going over how to install Oracle VirtualBox. To get the app working on your Linux PC, scroll down and follow the instructions that correspond with the OS you use.

Mac/Windows

Interested in hosting your virtual Linux-powered Minecraft server on a Mac or Windows PC? If so, you’ll need first to install VirtualBox.

Installing VirtualBox on a Windows or Mac computer is quite easy, as both operating systems don’t require the user to interact with a terminal or anything like that. Instead, head over to the official Vbox website, find the download option for your Mac or Windows PC and download the installer file.

Once the VirtualBox installer is done downloading, go through the process of installing the program to your computer and move on to the next step of the tutorial!

Ubuntu

VirtualBox on Ubuntu is in the “Multiverse” repository. So, if you want to install it, you must enable it with:

sudo apt-add-repository multiverse

Once the repo is added to your Ubuntu system, run the update command on Ubuntu.

sudo apt update

Finally, install Virtualbox on Ubuntu with the apt command.

sudo apt install virtualbox

Debian

VirtualBox on Debian is available in the Contributor repository. However, this repo isn’t available by default, so you must enable it first. Here’s how to do it.

Step 1: Open up your sources file in Nano.

sudo nano /etc/apt/sources.list

Step 2: Find all of the lines that start with “deb.” At the end of each line, add “contrib.” You may also want to add the “non-free” line too if you require proprietary libraries and programs.

Step 3: Run the update command to finalize adding the new “contrib” and “non-free” lines.

sudo apt-get update

Now that “Contrib” is up and running on your Debian PC, you’ll be able to install the VirtualBox app with the following Apt-get command easily.

sudo apt-get install virtualbox

Arch Linux

On Arch Linux, you’ll be able to install and use Virtualbox if you have “Community” enabled in your Pacman configuration file.  Unsure about how to enable it? Follow the steps below.

Step 1: Open up Pacman.conf in Nano and scroll through it to find the “Community” section.

sudo nano /etc/pacman.conf

Step 2: Remove the # symbol from in front of “Community” and the lines below it.

Step 3: Save Nano with Ctrl + O. Then, exit with Ctrl + X and return to the terminal. Once back at the terminal, resync Pacman.

sudo pacman -Syyu

Step 4: With “Community” up and running, you can install VirtualBox on Arch with:

sudo pacman -S virtualbox

Fedora

Fedora’s software repositories are open source, and the developers aim to keep it that way. For this reason, you won’t find the VirtualBox application. However, if you enable the RPM Fusion software source, you’ll be able to get it working.

To enable RPM Fusion, run these two DNF commands.

Note: replace the X with the release number of Fedora you are currently using.

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-X.noarch.rpm -y
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-X.noarch.rpm -y

With RPM Fusion up and running, install Virtualbox on Fedora with:

sudo dnf install VirtualBox -y

OpenSUSE

If you’re a SUSE user, VirtualBox is very easy to install. Simply open up a terminal and run the following Zypper command.

sudo zypper install virtualbox

Generic Linux

VirtualBox has a standalone, downloadable binary for Linux systems that do not have VirtualBox in their software sources. To install it, head over to the download page, grab the latest release and run it to start up the installation process.

Ubuntu Server in VirtualBox

Once VirtualBox is done installing, it’s time to set up Ubuntu server. The fastest way to install and set up Ubuntu server in VirtualBox is to grab a pre-setup appliance.

Mac/PC download instructions

Head over to the official download page, click on the “VirtualBox” tab. From there, locate “Download” and get the latest release of Ubuntu Server 18.04.1 LTS.

Please do not download Ubuntu Server 18.10 instead of 18.04.1. The networking on 18.10 doesn’t work very well in the latest OSimages release for VirtualBox.

Note: you will need 7z (or a decompression tool that can handle the 7z archive format).

Linux download instructions

Download the Ubutnu server image by running the following command;

wget https://sourceforge.net/projects/osboxes/files/v/vb/59-U-u-svr/18.04.1/1804164.7z/download -O 1804164.7z

Install the P7zip tool to enable your Linux system to extract 7zip files. Then, extract the archive with your file-manager by right-clicking on 181064.7z, and selecting “extract.”

When you’ve extracted the files, open up VirtualBox, click “New,” type “Ubuntu Server” as the name and set the ram to 2048 MB.

After setting the RAM, go to the “Hard disk” page and select “Use an existing virtual hard disk file.” From there, browse for “Ubuntu 18.04.1 Server (64bit).vdi” and click “open” to assign it to your VM.

Finish the VM creation process by clicking “create.”

Tweaking the network settings

Right-click on the “Ubuntu Server” VM in VirtualBox. Then, click “Settings” to open up the settings area for the machine.

Once in the settings area, click on “Network.” Then, under “Adapter 1,” change it to “Bridged Adapter.”

Install the Minecraft Server

The VM is working. Now it is time to get the server running. Launch the Ubuntu Server VM (right-click and select “Start”)  and follow the step-by-step instructions below.

Step 1: Log into the VM with the user details below.

username: osboxes

password: osboxes.org

Step 2: Install the Java runtime environment on your Ubuntu server.

sudo apt install openjdk-11-jre openjdk-11-jdk

Step 3: Download the latest release of Minecraft Server (Java Edition) with Wget.

wget https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar -O server.jar
touch eula.txt

echo 'eula=true' > eula.txt

Step 4: Run your Minecraft server with:

sudo ufw disable
java -Xmx1024M -Xms1024M -jar server.jar nogui

Easy Minecraft Server startup

To start up your Minecraft server more easily, set up a script in the VM terminal with the commands below.

touch ~/mc-server-start.sh

sudo chmod +x mc-server-start.sh
echo '#!/bin/bash/' >>  mc-server-start.sh

echo ' ' >> mc-server-start.sh
echo 'java -Xmx1024M -Xms1024M -jar server.jar nogui' >> mc-server-start.sh

Then, run the server at any time with:

./mc-server-start.sh

Connect to your Minecraft server

To connect to your Minecraft server VM, you’ll need to know the IP address of the machine. To figure out the IP, head over to this tutorial on IP addresses and read the terminal instruction section of the post.

When you’ve got the IPv4 IP address, turn on Minecraft, ensure your PC is connected to the same network as the VM, and click “Add server” in the Multiplayer menu.

Comments are closed.