Skip to main content

Why Linux Mint? Why VirtualBox?

While Windows has always been able to do the things I need, my first experiences of using a MacBook Pro introduced me to the world of command line tooling; from using Vim to grep, this was all new stuff, and it was stuff that I hadn't done on Windows before.

I wanted a similar macOS command line experience while using Windows, so I decided to set up my Windows machine up with a Linux OS to both learn Linux and create a self-contained development environment without having to mess around in Windows.

This post serves as a reference and guide for how I achieved this. For reference, my environment consisted of:

Setting up a Linux Mint virtual machine

Enable hardware virtualisation

If you want to run a 64-bit guest OS on your host OS (even if the host OS is 32-bit) you will need to ensure that your motherboard has hardware virtualisation enabled.

This is necessary to allow for a 64-bit instance of Linux to be installed through VirtualBox, as described in the VirtualBox documentation.

For Intel motherboards, this option is referred to as Intel Virtualisation Technology (Intel VT-x). For AMD motherboards, this is known as AMD Secure Virtual Machine (AMD SVM).

If your motherboard does not support hardware virtualisation, you will only be able to install the 32-bit instance of your chosen guest OS.

Install VirtualBox and download Linux Mint

Download and install VirtualBox, and then downloading the latest Linux Mint ISO. The 64-bit version should be fine.

Create a new virtual machine

To create a virtual machine in VirtualBox, perform the following steps:

  1. Select Machine > New... in the VirtualBox menu and use the following settings:
  1. Set the allocated memory to 2048MB, i.e. 2GB;
  2. Select the Create a virtual hard disk now option and:
    1. Select VDI (VirtualBox Disk Image) and proceed;
    2. Select Fixed Size and proceed; and
    3. Specify the location of the hard disk file and set the file size to 20GB. At the time of writing Linux Mint requires at least 10.7GB.

Install Linux Mint

With a virtual machine set up, Linux Mint can be installed onto it. Select the Linux Mint virtual machine and open the settings via Machine > Settings in the VirtualBox menu.

In the dialog that displays, select Storage. There should be two storage devices available by default, listed under a Controller: IDE item:

  1. the virtual disk image (with a *.vdi extension); and
  2. an optical drive, which should currently be labelled Empty.

Select the optical drive and, under the attributes, load the Linux Mint ISO downloaded in the earlier step.

Now start the virtual machine and wait for Linux to load.

The desktop will be displayed, and there should be an Install Linux Mint icon. Run it and select the following options as they appear, modifying to suit your needs:

  1. Select English as the language;
  2. Select English (US) as the keyboard layout;
  3. Leave the Install third-party software&ellip; unchecked;
  4. Select Erase disk and install Linux Mint as the installation method;
  5. Set the timezone location; and
  6. Set the computer details, including username and password.

Now wait for Linux Mint to install and then restart the virtual machine by shutting it down via the Linux Mint taskbar.

Resolve the "Running in software rendering mode" notification

A message may display every time Linux Mint is loaded that says the following:

Running in software rendering mode

Cinnamon is currently running without video hardware acceleration and, as a result, you may observe much higher than normal CPU usage.

There could be a problem with your drivers or some other issue. For the best experience, it is recommended that you only use this mode for troubleshooting purpose.

To correct this, open the virtual machine's settings and, under Display, check the Enable 3D Acceleration option.

Install VirtualBox guest additions

VirtualBox provides useful host to guest OS integrations such as a bidirectional clipboard, shared folders and dynamic window resizing.

With the virtual machine running, select Devices > Insert Guest Additions CD image&ellip; from the menu of the virtual machine's window.

Click Run on the box that pops up (or double click the CD icon that appears on the desktop) and enter your password. A terminal should display, which will log the installation progress.

Once done, restart again. VirtualBox will keep this drive inserted so if you wish to remove it you can do so by opening the settings of the virtual machine, going to Storage, selecting the VBoxGuestAdditions.iso item and selecting Remove Disk from Virtual Drive on the dropdown that displays when clicking the blue CD icon.

With it installed, it's a good idea to enable the bidirectional clipboard. This is found in the settings, under General in the Advanced tab. Set Shared Clipboard to Bidrectional. Now both the host OS (Windows 10) and guest OS (Linux Mint) can access the same clipboard.

Now is also a good time to install Vim if you want. Run the following in terminal:

$ sudo apt-get update
$ sudo apt-get install vim

Add folder sharing between the host and guest OS

It is useful to have a point where both the host and guest OS file systems are connected, as this makes moving documents back and forth possible.

With the virtual machine running, open the settings for the virtual machine and, under Shared Folders, click the Add shared folder icon. Use the following settings in the dialog box that appears:

After confirming the settings, the shared folder can be mounted using the following commands:

$ mkdir /home/<username>/<folder-name>
$ sudo mount -t vboxsf -o rw,uid=<username>,gid=<username> <folder-name>/home/<username>/<folder-name>/

The above commands will:

  1. make the directory on the guest before mounting or else it will error; then
  2. mount the directory to create a link between the host and guest OS.

To automatically mount the shared folder on start up, edit /etc/group and add your username to the end of the vboxsf line:

vboxsf:x:999:<username>

Then add the following line to /etc/fstab:

<folder-name> /home/<username>/<path> vboxsf rw,uid=<username>,gid=<username> 0 0

Enable port forwarding to access localhost from guest to host

Because I would use my Linux environment primarily for web development, I wanted a way to share a local development server running on the guest (Linux) to the host (Windows). This is fortunately easy to do in VirtualBox.

With the virtual machine off, open the settings and go to Network. On the Adapter 2 tab, check Enable Network Adapter and set Attached to: as Host-only Adapter.

Save the changes and start the virtual machine. All that is left is to set up a port forwarding rule. To do this, the IP address of the Host-only adapter is needed.

In Linux, open a terminal and run ifconfig. There should be three results from ifconfig. The Host-only adapter IP address will typically look like 192.*.*.*.

Copy this IP address and, back in the virtual machine network settings, select the Adapter 1 tab (which should be set as Attached to: NAT) and expand the Advanced options toggle to reveal the Port forwarding button.

Open the port forwarding dialog and add a new rule with the following details:

This rule will tell the virtual machine that any server running on Linux Mint bound to the IP and port of 192.*.*.*:1313 will be port forwarded and accessible on Windows at localhost:1313.

Confirming that port forwarding works

The best way to confirm that the port forwarding works is to install the npm package http-server, which requires Node.js to be installed. This is beyond the scope of this tutorial, but the installation can be streamlined by using Snapcraft packages, which are compatible with Linux Mint.

With Node.js installed, npm's npx command can be used to download and run the http-server package as a one-off action without having to install it locally:

$ npx http-server -a 192.*.*.*

…where 192.*.*.* is the host-only adapter address retrieved from ifconfig.

The -a flag is specifying the address to bind the HTTP server to; any HTTP servers running on the guest OS will need to be bound to the 192.*.*.* address for the localhost port forwarding to work.

With http-server running, open localhost:8080 in Windows. The content will be port forwarded from the guest to host OS and served accordingly.


Works cited

"How to Install Linux Mint in VirtualBox (Step by Step with Images)." Stugon, Stugon, 16 June 2017, https://www.stugon.com/linux-mint-virtualbox/. Accessed 6 June 2019.

Venkatesh, Nitin. "Accessing your Virtualbox Guest from your Host OS." 2buntu, 8 November 2014, https://2buntu.com/articles/1513/accessing-your-virtualbox-guest-from-your-host-os/. Accessed 6 June 2019.

duDE. "Why does virtualbox only have 32-bit option, no 64-bit option on Windows 7?" Super User, Stack Exchange, https://superuser.com/questions/866962/why-does-virtualbox-only-have-32-bit-option-no-64-bit-option-on-windows-7/866963#866963. Accessed 6 June 2019.