This articles is a note on running Linux in a VirtualBox and miscellaneous subjects.
In 2012, I wrote a note on running Linux in a VirtualBox. There have been a lot of changes since then.
- We have a new president. Donald Trump replaced Barack Obama as the president of the USA.
- I bought a house in a nice neighborhood. When I tried to recommend the one-bed-room apartment where I wrote my first note on Linux to one of my young colleagues, I was shocked that the rent price went to $1030/month from $680/month in five years, which is effectively more expensive than my mortgage payment now.
But a lot of things still remain the same.
- The Newton's laws remain the same. Even the people who are so interested in re-factoring other people's already functional programs do not have the incentive to make any changes to Newton's sentences.
- I am still using one of the computers that I owned by the year 2012. It is a SONY VAIO with an Intel Pentium B940 2.00GHz x 2 CPU and 4GB of memory. I replaced the hard drive with a 100GB SSD which cost me about $30. I also replaced the Windows operating system with Linux. For normal activities, I have confidence that it can outperform a lot of much more expensive new computers that use Windows operating systems.
I am not a rich guy, but I have five computers. Four of them are bought refurbished through Amazon. All of them are running in Linux with three of them being dual-boot systems between Linux and Windows. My wife and I use Linux exclusively on a daily basis. Although Linux is my preference, I use Windows at work to bring money back to buy refurbished computers and to buy carrots to feed my stomach. I am not an expert on Linux, but I think that I have practically learned enough to take another note on running Linux in a VirtualBox in 2017.
Why Run Linux in A VirtualBox?
The performance of a Linux system running in a VirtualBox has no match to a natively installed system, but you may still want to run Linux in a VirtualBox in many cases.
- The VirtualBox is a perfect environment for beginners. If you make a mistake, you can delete the VM (virtual machine) and its associated files. You can restart the whole process without any impact on your host computer.
- It is not always trivial to set a dual-boot system. The GRUB is how Linux achieves co-existence with other operating systems. But Microsoft made the effort in some Windows versions with some computer manufacturers to make the GRUB difficult. In some cases, you will have to make a choice between Windows and Linux, but not both.
- The VirtualBox is a perfect test environment. You can test the communications between the VM and the host computer without the effort to setup a network. If you have a powerful computer, you can setup multiple VMs to test the communications among them.
What Do You Need?
To run Linux in a VirtualBox, the computer does not have to be powerful. In 2012, I experimented VirtualBox with a 32-bit Pentium(R) Dual-Core T4200 @ 2.00GHz laptop with 3GB of memory.
- You need a VirtualBox installer that you can download from the VirtualBox website.
- You need to choose a Linux distribution. The popular ones are Ubuntu and Mint. I have played with both. I think that Mint is more visually pleasant. I use Linux as a desktop operating system, so look and feel is important to me. In this note, I will use Mint. But you are free to try Ubuntu, it is a great system and it works perfectly.
I will recommend you to try the most updated stable versions for both VirtualBox and Mint. If your host computer is 64-bit, I will recommend you to use a 64-bit version Linux. I personally prefer the "cinnamon" flavor Mint, so I chose the "linuxmint-18.2-cinnamon-64bit.iso". The VirtualBox runs on multiple operating systems. Because you are reading this note, I would assume that your host computer runs on Windows. VirtualBox is very easy to install. You can double click the installer and follow the instructions to install it.
Although VirtualBox is a powerful VM hosting environment, You can access the most commonly used functionalities through just the three buttons:
- The "New" button allows you to create a VM.
- The "Settings" button allows you to manage the settings of the VM.
- If you want to start the VM, you can click the "Start" button.
Create a VM And Install Linux
Create an Empty VM
Click the "New" button and choose "Expert Mode", we can start to create a VM.
By default, VirtualBox will allocate 1GB of memory to the VM. If you want better performance, you can add more memory to it.
When you create the VHD (Virtual Hard Drive), I would recommend to choose "Fix size" and set the size to at least 20GB.
After the VM is created, we can make changes to its default settings by clicking on the "Settings" button. In order to have better graphical experience later, I would recommend you to check the "Enable 3D Acceleration".
Run Linux in Evaluation Mode from The ISO File
Linux supports a evaluation mode, which allows us to boot the VM directly from the "ISO" file. In order that the VM knows about the "ISO", we can create a virtual optical drive and associate the "ISO" file to it.
In order that the VM boots from the ISO file, we need to change the boot order of the VM and move "Optical" to the top of the list.
Now you can boot the VM in evaluation mode by clicking the "Start" button on the VirtualBox. You may see some messages due to misunderstanding between Mint and VirtualBox, but you should see that Linux boots successfully from the ISO file.
Install Linux to The VHD
Running Linux directly from the ISO file can give you some feeling about the Linux, but it has very limited capabilities. You need to install Linux to the virtual hard drive to have its full capability.
- You need to make sure the computer is plugged to a power supply.
- You need to make sure your VM has internet access through the host computer. By default, you have access to Firefox in the evaluation mode. You can open the browser and try to access some of the well known websites like "www.google.com" to check if your VM has internet access.
You can then double click the "Install Linux Mint" virtual optical dive to install Linux to your VHD. The installation process is pretty simple and I would recommend you just take the default options suggested by the installer.
You will need to provide a user name and a password during the installation. You need this UN/PWD pair to login to the Linux. By default, this user is a system administrator of the Linux system. After the installation, you can re-start the VM to let Linux to boot from your VHD. Depending on the version of the VirtualBox, you may need to change the boot order of the VM to put your VHD to the top of the list. Otherwise, it may keep booting from your ISO file in the evaluation mode.
Install VirtualBox Guest Additions
In order that you can switch smoothly between your guest VM and your host computer, you need to install VirtualBox Guest Additions to the VM. After you start and login to Linux , click the "Device" menu of the VirtualBox and choose "Insert Guest Additions CD image".
After you choose the "Insert Guest Additions ...." option, you will be asked if want to run it.
Click the Run button and follow the instructions to install it. During the installation process, you will be asked for a password. It is part of the typical Linux program installation process, you can give the password and proceed with the installation.
Now you have a fully functional Linux VM running in your VirtualBox. Just a quick tip, you can switch your VM to full screen mode back and forth by typing "Right CTL + F".
Manually Install Guest Addition
For some versions of the Linux, the guest addition does not automatically start. In such case, you need to manually install it - https://www.linuxbabe.com/linux-mint/install-virtualbox-guest-additions-in-linux-mint.
sudo apt update
sudo apt upgrade
sudo apt install build-essential module-assistant
sudo m-a prepare
You need to find the mounting location of the guest addition ISO, and issue the following command.
Remove the VM from The VirtualBox
Regardless if you make a mistake or if you simply do not want the VM anymore, you can right click the VM in the VirtualBox Manager to remove the VM from the VirtualBox.
When you remove the VM, you have two options. You can choose to remove it from VirtualBox but keep all the files so you can add it back later. You can also choose to remove it and also delete the VM and all the associated files.
From the VirtualBox menu -> File -> Preferences, you can find the location of all the VM files and you can make change to it if you want to.
The Clipboard and Drag & Drop and Shared Folders
It is convenient that we can share the clipboard and use drag & drop between the guest and the host computers. But these capabilities are disabled by default. You can enable them through Settings -> General -> and make changes to the drop-down boxes.
You can transfer small files by dragging & dropping. But I noticed that it does not work well for larger files. For larger files, you need to enable a shared folder.
You can go through Settings -> Shared Folders -> and add a shared folder. You can browse to any folder in your host computer and add it as a shared folder. By default, you do not automatically have access to the shared folder in the Linux guest. You need to issue the following command to add yourself to the "
vboxsf" group to gain access to the shared folder.
sudo usermod -aG vboxsf $(whoami)
sudo" command requires you to give your password. After the success run of the command and restart your VM, you should be able transfer files between the guest and the host computers through the shared folder.
The Linux Version Installed
After some time, you may forget the version of the Linux installed. You can find it out by the following command to look at the "/etc/lsb-release" file.
For Linux Mint, if you want to find the corresponding Ubuntu version, you can issue the following command:
On the computer that I am using, it shows me the following information.
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
Native Linux Installation
It is a nice and pleasant experience to run Linux in a VirtualBox. But sooner or later, you will want to install Linux natively to see how fast Linux is compared with its Windows counterpart. The first step to install Linux natively is to create a bootable USB drive based on the Linux ISO file that you downloaded earlier.
Create a Bootable USB Drive In Linux
If you already have a Linux machine, you can click on "Menu" -> and search for "USB Image". You will find that the "USB Image Writer" is installed in your Linux machine by default.
You can browse to the ISO file and select the USB drive that you want to use and click "Write" button to create the bootable drive.
Create a Bootable USB Drive in Windows
The "USB Image Writer" is not available in Windows. Typically, people download the "UNetbootin" to create the bootable USB drive in Windows. I actually created my first Linux bootable USB by "UNetbootin". But I noticed that the "UNetbootin" currently does not support the most updated Mint version, so I tried to use the Linux running in the VirtualBox to create the bootable drive in a Windows computer.
In order to use the USB Image Writer in a VirtualBox, you need to make the VM to gain access to the USB drive on the host computer. You can plug the USB drive to the host computer and make sure the VM is shutdown. From "Settings" -> USB -> click the "+" button to add the USB to the VM.
After clicking the "+" button, you will be presented the options and you should see the USB drive that you want to use.
After selecting the USB drive and starting your VM, the USB drive should be visible in the VM. You can then use the "USB Image Writer" in your Linux VM to create the bootable drive.
Stand–alone Linux Installation
It is an easy and pleasant experience to create a stand-alone Linux computer. You can first boot your computer from the bootable USB drive in the evaluation mode and then install Linux to your hard drive.
Boot From The USB In Evaluation Mode
You can plug the bootable USB drive to your computer and restart it. Before the computer is fully started, you can change the boot order to boot from your USB drive. You can constantly press your boot key to bring up the boot menu and change the boot order. Depending on the Manufacturer and the brand of your computer, the boot key may be different. On my Dell computer, it is F12. This link has an almost complete list of the key strokes for most of the computer manufacturers.
Intall Linux to Your Hard Drive
After your computer boots from the USB in the evaluation mode, you can see the "Install Linux Mint" virtual optical drive. You can double click it to install Linux to your hard drive.
- You need to make sure that the computer has internet access.
- You need to make sure that the computer is plugged to a power supply.
If your computer already has an operating system, the Linux installer may detect it. It will ask if you want to wipe off the existing operating system or if you want to create a dual-boot system. If you want a stand-alone Linux installation, you can choose to wipe off your existing operating system and follow the rest of the instructions to install Linux to your hard drive.
If your computer already has an operating system, you can create a dual-boot system. But the difficulty level varies significantly on a case by case base. It is difficult for me to give any valuable instructions. I have three dual-boot computers, each of them takes me totally different amount effort to create.
- Easy Case - My Dell laptop running Windows 7. During the Linux installation, the installer detected the Windows OS and offered the help to create a dual-boot system. I followed the instructions and the installation completed smoothly.
- Moderately Easy Case - My Dell laptop running Windows 10. During the Linux installation, the installer detected the Windows OS and offered the help to create a dual-boot system. I followed the instructions but the installation failed. I had to manually delete one of the Windows partition and repeat the process to complete the installation.
- Difficult Case - My Toshiba Satellite running Windows 8. During the Linux installation, the installer could not detect the Windows OS, so I had to manually shrink Windows partitions and create the Linux Partitions. After Linux is installed on the Linux partitions, I have to change the BIOS settings every time I want to switch the operating system.
It is fun to spend some time to create a dual-boot system. If you spend enough time and be patient and if you enjoy playing with the computers, you should be able to make it. If I have time later, I may write a note dedicated on this subject.
You should be able to install Linux on most of the computers. But for some models from some manufacturers, it may be a headache. If you want to reduce the headache, you can take a look at the Ubuntu Certified Hardware List.
Multiple Language Input Support
Being able to type multiple languages is not important for many people. But I am bilingual, I want to be able to type Chinese in Linux. If you use other languages, you should be able to enable them in a similar way. Linux Mint supports virtually all the major languages. I noticed that different versions of Linux have some small differences in the way to enable the multiple language input support. The steps list in this note is for Linux Mint 18.2.
Add Chinese Support to the Input Method
From Menu -> search for "Input method", you can launch the input method configuration tool.
Because Chinese is such a important language in the world simply by the democratic principle with over one billion speakers, Linux gives it a special treatment that you can directly install it from the "Input method" tab. If your language is not listed here, you should be able to find it in the "Language" tab.
After installing the "Simplified Chinese" support, you can choose the Input method to "IBus". You may be able to try other options, but I have only tried
Configure IBus Preferences
From Menu -> search for "IBus", you can launch the
IBus Preferences configuration tool. If you have never started the
IBus, it will start automatically when you launch the
IBus Preferences configuration tool.
In the "Input Method" tab, you can click the "Add" button to add your desired Chinese input method to the
In the "General" tab, you can choose the options how you want to use the input methods. In my case, I choose to use the keyboard shortcut "CTL + space" to change my input methods.
Type Chinese In Linux
With the input method enabled, I can use the keyboard shortcut "CTL + space" to switch to Chinese input and start to type Chinese in Linux.
Myths About Linux
There have been many myths about Linux. This link summarized five of them and I totally agree with him. In addition, I want to add a few more from my own experience.
Linux Is Difficult to Use
I have been using Linux for many years, I feel that it is very user friendly. I have a computer science degree and Unix is not an alien to me, but my wife has no computer education at all. She has been using Linux for as many years as I have. I made the effort to give her a dual-boot system, but she virtually never switches to Windows over the last couple of years because Linux is faster and easier to use.
You need to know commands to use Linux
Using commands is convenient for certain tasks in Linux and it is a conventional method by Unix tradition. But you can virtually perform all the tasks without typing any command. My wife never learned Linux command, but she has enjoyed Linux happily for many years. By the way, I never become a command line fan myself. If I can find a GUI tool to replace the commands, I will use the GUI tool. In Linux, we have so many nice GUI tools for almost all the tasks.
Linux does not have enough applications
Once you make a Linux installation, it comes with virtually all the applications that you want to use for free. The office application totally compatible with Microsoft office. I wrote my resume in Linux and no one complains that he/she cannot open it in Windows. My wife used the Linux version Excel and send the document to her friend and it is opened nicely without any problem.
Linux is not for gamers
I do not play games myself, so I do not have much experience on it. My wife uses Linux to play games and she like it because Linux is visibly faster. In fact, playing games is the major reason why she started to use Linux. If you play games, you may have more to say on this subject.
Linux is for servers, not for regular desktop usage
Linux is a good server operating system, because it is faster and performs multi-threading extremely well. It is also a good desktop operating system because it is faster and visually pleasant. I have been using it as a desktop operating system for many years.
I have never used a Linux system
You may not know it, but you may have already been an experienced Linux user. If you have a smart phone, you are very likely a Linux user, because Android is in fact a version of the Linux system. Although Apple computers are not directly derived from Linux, they have a strong historical link to Linux.
Linux computers do not have virus
You may have heard that Linux computers do not have virus. But it is a Myth and Linux does have virus. If you think that viruses are programs that can do damages to your computer, I can easily write such a program. If you run it on your computer, it will do the damage. Because of malware's lack of root access, Linux is safer than Windows. But you still need to be cautious. You should only get software updates from the Linux repository and only download programs from the trusted sources.
If you are a programmer or a tester, the VirtualBox is a nice tool for you to simulate a computer network. You can test how programs communicate with other computers through IP connections in a VirtualBox environment. I hope that I can write something on how to enable IP connections between the host and the VMs, but it will make this note too lengthy. When I get some time, I will write a dedicated note on enabling IP connections in a VirtualBox.
Points of Interest
- This is a note on running Linux in a VirtualBox and miscellaneous subjects.
- I hope you like my postings and I hope this note can help you one way or the other.
- 22nd July, 2017: First revision
I have been working in the IT industry for some time. It is still exciting and I am still learning. I am a happy and honest person, and I want to be your friend.