For quite some time, I’ve been wanting to play around with the source code of MINIX, partly because I like to understand how operating systems, well, operate, and partly because I am a firm believer in the design philosophy of a modular micro-kernel OS architecture (vs the traditional monolithic approach) and wanted to see how one was implemented. I was trying to set up a MINIX installation on VirtualBox but could not get the networking to function properly inside of my MINIX guest OS which I needed. This post is basically a detailed (b)log (expanding on the MINIX guideline) of how I switched to QEMU/KVM and got a working MINIX 3 installation complete with networking, to experiment with (when I mention “networking”, I am referring to accessing the Internet from the MINIX guest OS).
First off, I need to mention my host OS is Ubuntu 16.04 (32bit) running on a core 2 duo machine with 1GB of RAM. I also enabled the virtualization extensions in my BIOS (required by KVM, else there will be an error during the MINIX installation), which is quite trivial to configure in your machines.
A word about QEMU and KVM: QEMU (short for Quick Emulator) is an open source machine and peripheral emulator, focusing primarily on portability. KVM (Kernel based virtual machine) was originally a fork of QEMU, is a Linux kernel module that handles virtualization, and is now part of the main Linux source by default. To make a long story short, QEMU is a stand alone software, but will use KVM if it is available. There are many online resources on these two technologies which can be referred for a further understanding of emulation vs virtualization.
In order to install QEMU in Ubuntu, we need to type the following in the terminal:
sudo apt-get install qemu qemu-kvm libvirt-bin
Once this has run, QEMU will be installed in your host system.
Next, we will create a folder which will hold our QEMU VM image. In my system, I created a folder named “qemuVMs” in my Home folder. Also, we need the MINIX 3 ISO file that will be used to install the MINIX system, which can be downloaded from the MINIX download page. At the time of this writing, there were two versions available for download, and I selected version 3.3.0. Once the file is downloaded, you can extract the contents to get the ISO file, which needs to be copied into the folder we created earlier (in my case /Home/qemuVMs/).
Once the ISO file is in our folder, we can fire up a terminal, navigate to the folder containing the MINIX ISO file, and type the following command to create the VM image:
qemu-img create minix.img 2G
The above command will create a VM image named ‘minix’ with 2Gb space to hold our MINIX system (you can change the image name and size as you see fit). Now the contents in the folder should be something like the following:
Once the VM image is ready, we can boot the ISO file by running the following command at the terminal:
qemu-system-x86_64 -localtime -net user -net nic -m 128
-cdrom minix_R3.3.0-588a35b.iso -hda minix.img -boot d
This command basically tells QEMU to use the minix_R3.3.0-588a35b.iso file in the minix.img VM, and to allocate 128Mb of RAM for the VM. Please note to replace minix_R3.3.0-588a35b.iso with the name of the ISO file you downloaded, when running the above command.
If everything goes as planned, you should be taken through the normal MINIX 3 installation routine, which you can follow based on the guidelines given in the MINIX site. There are two important points to note during the MINIX setup:
- When the option to select a network interface is given, select the “Virtio network device” option.
- When asked whether to configure network using DHCP or manually, select “Automatically using DHCP”.
(We can always change the above network configuration in MINIX by typing “netconf
” at the MINIX command prompt, but setting them during the initial setup will save us a step when we reboot into the new system.)
Once MINIX 3 is installed in the VM, we need to change some configurations in the newly installed MINIX system, in order to utilize the virtualized disk and network drives and have internet access from the MINIX system. So boot into the new MINIX system by typing the following at the (Host OS) terminal:
qemu-system-x86_64 -rtc base=utc -net user -net nic -m 128 -hda minix.img
Once we are logged into the MINIX system, we need to go up one directory from the default file location, and navigate into the etc/ folder to modify the boot.cfg.default file. The following image shows how I have navigated from the point I was logged into the MINIX system till where I am going to edit the configuration file using the (ported) vi editor already available in the MINIX system:
When I open the file with vi, I need to add a new menu line with the following contents:
menu=Start MINIX 3 latest serial virtio:load_mods /boot/minix_latest/mod*;multiboot
/boot/minix_latest/kernel rootdevname=$rootdevname $args cttyline=0 virtio_blk=yes
(basic editing commands in vi can be found in numerous sites online. Generally, you will type shift + i to edit text, escape key to finish the edits, then shift + ‘:’ to get the vi prompt, and type “wq” at the vi prompt to write changes to disk and exit the editor).
You can see the last three lines in the below screenshot, where I have added this new line of text in the boot.cfg.default file:
Once the above changes are made, we can exit the editor. We are still in the /etc/ folder, so we need to go back up one step in the file hierarchy, and then navigate into the /bin folder for the next step. Inside the /bin folder, we just need to run the update_bootcfg
(just type “update_bootcfg
” at the MINIX command prompt and press enter) command to make the changes we did in the boot configuration file come into effect. The below screenshot shows this (from the point we exit the vi editor):
After the step above is completed, we can shutdown the system by typing “poweroff
” at the MINIX prompt, and reboot into the system using the following new command:
kvm -net nic,model=virtio -net user -drive file=minix.img,if=virtio -serial stdio -m 128
(It would be easy to have this command in a shell script so that we do not need to type it each time we need to fire up the MINIX guest OS.)
Now when you boot into the MINIX guest OS, you should see a new option named “Start MINIX 3 Latest serial virtio” which is what we configured in the boot configuration file earlier (option 6 in below image):
If we select this boot option and login to the system, you would find that we have full access to the internet via the virtual network interface we have configured. If you do a “pkgin update
” at the MINIX prompt, you should be able to see MINIX retrieving package details over the internet and updating the package database.
If you run into any issues when installing MINIX 3 (with networking) in QEMU following the steps outlined above, please do leave a comment.The MINIX3 Google group is also a great place to check for common issues and support, and a better forum to put your discussions/problems forward, as it will benefit the whole MINIX community.
CodeProject