Create a Free Linux VM on Your Computer – Built In

In this day and age, cloud computing power is prevalent and cheap. You don’t need to look hard to find free or affordable hosting options for app development, databases or data science projects. Regardless of online availability, there are many reasons to set up custom environments on your own hardware; chief among them: security.

What’s a Virtual Machine (VM)?

A virtual machine is like having a computer inside your computer. Through hardware virtualization, another operating system shares your host computer’s resources. Each VM has its own operating system (OS) that works separately from the host OS.

Using Oracle’s free VirtualBox software, setting up a virtual machine (VM) on your own PC is super easy, safe and allows you to run multiple operating systems at the same time!

 

What Is a Virtual Machine?

A virtual machine is like having a computer inside your computer. Through hardware virtualization, another operating system shares your host computer’s resources. Each VM has its own operating system (OS) that works separately from the host OS. Likewise, each VM has its own processors, RAM, disk, and so on. Through virtualization, you essentially create two different machines. 

In this article, I’ll explain how to load the free Linux OS, Ubuntu Server, onto a VM using Windows as my host machine operating system. Like a virtual machine in the cloud, it’s even possible to set up secure shell (SSH) making it easy to remote in safely.

 

Download and Install VirtualBox

VirtualBox is not only free, but also a feature-rich application that’s fairly easy to set up. It has a large and helpful community that keeps updating and enhancing the functionality. Additionally, it supports a variety of host operating systems (Windows, Linux, Macintosh, Solaris) and is available under the terms of the GNU General Public License (GPL).

Go to the downloads page and select the version you need for your host OS. For example, I’m using Windows so I download the Windows option.

Also be sure to download the Oracle VM VirtualBox Extension Pack further down the page.

linux vm

Note: When you’re installing VirtualBox, the system warns you about a hiccup in the network connectivity, so make sure you aren’t doing anything that can’t be interrupted. 

Going through the process to install it is fairly simple; I used the defaults. Refer to the documentation for issues with the installation. I’ll walk through actually creating the VM after downloading Ubuntu.

More From Built In Data Science ExpertsA Guide to Data Clustering Methods in Python

 

Download Ubuntu

Ubuntu is a free and easy to install flavor of the Linux operating system, and it’s for desktops and servers. A lot of technologies used for the web, data science and software development are designed for Linux. You can run them using command-line. I’ve used Ubuntu when creating and hosting web pages, setting up SQL databases and Elasticsearch clusters, and managing containers with Docker.

Download Ubuntu Server on the downloads page.

Note: An .iso file downloads. When the VM loads, you’ll select the image to install the Ubuntu OS.

Data Science Deep DivesHow to Use Environment Variables in Docker Compose

 

Managing Virtual Machines

Take note of your host machine’s specs before setting up virtual machines. If you afford the VM too much RAM or CPU, the VM can impact the performance of your host machine dramatically. 

I set up a VM to use 14 of my 16 gigs of RAM and then ran machine learning models on large data sets. My host machine functioned as well as a clogged pipe while the model transformed the data! Always pay attention to the resources you assign to the virtual machine.

After installing VirtualBox and downloading Ubuntu, it’s time to create a virtual machine and install Ubuntu. When starting VirtualBox, you’ll see a screen like this:

linux vm

Notice I already have two VMs created:

The Oracle VM VirtualBox Manager is the graphical user interface (GUI) through which one creates and manages virtual machines.

 

Create a Virtual Machine

There are only a few steps to get the VM running. Keep in mind, it’s  possible to change most of these settings if, for example, you need to adjust the number of processors or RAM. Click the settings button to adjust anything after you’ve created the VM.

Click new to create the Ubuntu VM.

linux vm

  • Enter a name
  • Select Linux as the type.
  • Select Ubuntu (64-bit) as the version.
  • Set the memory size. I’m allocating two gigs of memory, but you should allocate memory according to what’s available in your system.

Select create a virtual hard disk now as the hard disk option so the VM has dedicated storage space.

Click create once the options have been configured. The Create Virtual Hard Disk editor displays if you selected that hard disk option.

linux vm

Select a file location. Consider how much space you need to allocate. For example, I have two drives in my computer and always use the larger one for my VM disk space.

Set a file size. The default size is 10 gigs, but I recommend 20. Consider how large the operating system is and make sure to select a disk that has enough space on it! For example, Windows can take 10 gigs or more.

Select one of the Storage on physical hard disk options:

  • A dynamically allocated file grows as needed and will approach the maximum file size over time.

  • A fixed-size file immediately reserves the total space allocated for file size.  If you’re using the default settings, this option creates a 10 gig file. 

I prefer to use a fixed-size file since it tends to perform a little better because it uses less overhead than the dynamically allocated file.

Select the default hard disk file type. This option determines the type of container used when creating the storage. Some options are more compatible with other virtual machine programs.

Click create and the VM will start generating.

linux vm

The virtual machine will appear in the VirtualBox Manager once you’ve created it:

linux vm

Looking for Data Science Jobs? We Got You.Apply for Data Science Roles on Built In

Install Ubuntu on the VM

Once you’ve created the VM, it has all the resources it needs to install an operating system and act like a regular computer. Make sure to remember where the Ubuntu .iso file downloaded since you’ll need it in these next steps.

Click start to start the new VM.

linux vm

When the VM first starts, it will prompt you to select a disk image. Select the Ubuntu iso file.

linux vm

Click start after selecting the iso file.

It’s possible to change the selected image or re-select the image by following device > optical drives > choose disk image.

linux vm

From there, select your language and follow the prompts to install Ubuntu. The system will prompt you to set up a username and password; once you do that, it will install the OS!

linux vm

Looking for More Data Science Tutorials?Need to Automate Your Data Analysis? Here’s How.

Ready, Set, Code!

Now that the VM has an operating system installed, it’s ready for your projects! Install the desired tech and start coding. There are tons of tutorials online to get Docker, Git, Python, Elasticsearch, Mysql, FTP, and much more installed on Linux

Using Oracle’s VirtualBox software, it’s easy to create and manage virtual machines using your own hardware and different operating systems. Since Linux is free and supports the tech stacks I need, it pairs perfectly with VirtualBox.

This article was originally published on Towards Data Science.

Spread the love

Leave a Reply

Your email address will not be published.