« Previous 1 2 3
Operating systems for the cloud and containers
Young Heroes
Camel Master
If you want to use MirageOS as your cloud operating system, you need to master the OCaml [33] functional programming language. Because the kernel does not need to perform many tasks handled by a traditional kernel, C or C++ are not necessarily the first choice. For kernels acting as a single-application kernel – also known as a unikernel [34] – the tendency is to use languages that are higher level, which offers a few advantages.
In the case of OCaml, the developers cite automatic memory management, type checking at build time, and a modular structure [34]. Also, the generated machine code is reputed to be fast and efficient. For hard-core C programmers, OCaml probably represents a big hurdle when switching over to MirageOS. One important tool is the OPAM [35] package manager, which the cloud operating system uses to install the required libraries when generating the unikernel (Listing 1).
Listing 1
Building MirageOS with OPAM Support
$ mirage configure --unix Mirage Using scanned config file: config.ml Mirage Processing: /home/user/mirage-skeleton/console/config.ml Mirage => rm -rf /home/user/mirage-skeleton/console/_build/config.* Mirage => cd /home/user/mirage-skeleton/console && ocamlbuild -use-ocamlfind -tags annot,bin_annot -pkg mirage config.cmxs console Using configuration: /home/user/mirage-skeleton/console/config.ml console 1 job [Unikernel.Main] console Installing OPAM packages. console => opam install --yes mirage-console mirage-unix The following actions will be performed: - install mirage-unix.2.0.1 - install mirage-console.2.0.0 === 2 to install === =-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= =-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Building mirage-unix.2.0.1: make unix-build make unix-install PREFIX=/home/user/.opam/4.01.0 Installing mirage-unix.2.0.1. Building mirage-console.2.0.0: make make install Installing mirage-console.2.0.0. console Generating: main.ml $
If OCaml and OPAM are already running in your development system, you can get started without delay. If not, you should refer to the installation guide [36].
Of course, a "Hello World" example is obligatory [37], as well as very educational, because it explains how essential aspects of MirageOS work. The operating system is so different. To begin, the guide explains how the application handles output to a console. Because the application is the kernel, managing devices for your own use can be difficult to outsource. The application thus needs to handle these tasks. The second lesson relates to basic disk access; these are the popular block devices in the cloud environment. The tricky stuff then starts with the network stack, including a simple web server (Figure 4).
MirageOS allows the user to generate the application binary in two different formats. The mirage configure --unix
command produces a compiled file that traditional Linux environments run as a normal process (Listing 2). With mirage configure --xen
, the application is booted as a Xen kernel, in which case, you end up with a configuration file that you can process with the familiar xl
commands. The MirageOS machine also produces the corresponding file in XML format.
Listing 2
Building the MirageOS Unikernel
01 $ mirage configure --unix 02 [...] 03 $ 04 $ make depend 05 [...] 06 $ 07 $ make 08 ocamlbuild -classic-display -use-ocamlfind -pkgs lwt.syntax,mirage-console.unix,mirage-types.lwt -tags "syntax(camlp4o),annot,bin_annot,strict_sequence,principal" -cflag -g -lflags -g,-linkpkg main.native 09 [...] 10 ln -nfs _build/main.native mir-console 11 $ 12 $ file _build/main.native 13 _build/main.native: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=734e3fc7a56cd83bc5ac13d124e4a994ce39084f, not stripped
The examples on the MirageOS project website are smart and work well. Installing an existing application on this cloud operating system always requires a new implementation. In addition to writing the actual application, developers also have to worry about accessing block devices and the network, which – combined with a new programming language – is not a small price to pay.
This and That
The MirageOS approach is quite dramatic and may go somewhat beyond what many cloud operators are prepared to do. However, there is a less painful alternative: OSv [38] is another well-known representative of the unikernel camp, which includes other candidates [39].
The new lean systems (including CirrOS and Container Linux) are attracting interest among security experts. The stripped-down userspace reduces the number of potential vectors for attackers. Lean software management reduces the risk of a security hole from procedural red tape or simple technical problems during an upgrade.
Anything that works in userspace can be transferred easily to the operating system core. The easiest way would be to create a customized kernel that contains only the necessary software and configuration.
However, unikernels take it one step further by questioning even the ingredients and the recipe for building a kernel. Some people point out that exotic systems are less vulnerable because they have fewer tools and because people lack the necessary knowledge to wreak havoc, but it's a double-edged sword: With fewer users and experts, the risk of an undiscovered vulnerability is also greater. The relevant points are the reduced attack surface, fewer active functions, and simplified software management.
Conclusions
Clouds and containers have given rise to demand for more new open source operating systems. Some are quite close to the classic Linux, whereas others started life in a green field and openly ignore any historical ballast. CirrOS and Container Linux are two candidates from the first camp. MirageOS (and OSv) are representatives of the green field, "start from scratch" generation.
No general recommendations can be made for IT environments, but the more recent operating systems clearly show that the playing field has changed. Studying implementations of CirrOS, Container Linux, or MirageOS can deliver ideas and new approaches.
Infos
- CirrOS: http://launchpad.net/cirros
- Alpine Linux: http://alpinelinux.org
- JeOS: https://www.suse.com/products/server/jeos//
- CoreOS (Container Linux): http://coreos.com/os/docs/latest
- Buildroot: http://buildroot.uclibc.org
- Scott Moser: http://launchpad.net/~smoser/+related-projects
- No 64-bit support: http://bugs.launchpad.net/cirros/+bug/1321935
- OpenStack test systems: https://docs.openstack.org/image-guide/obtain-images.html
- cloud-init: http://launchpad.net/cloud-init
- Local launch: http://cloudinit.readthedocs.org/en/latest/topics/datasources.html
- BusyBox: http://www.busybox.net
- Dropbear: http://matt.ucc.asn.au/dropbear/dropbear.html
- Project Atomic: http://www.projectatomic.io
- Red Hat Atomic Host: http://www.redhat.com/en/resources/red-hat-enterprise-linux-atomic-host
- Snappy Ubuntu Core: http://www.ubuntu.com/core
- SUSE CaaS: http://www.suse.com/communities/blog/rise-caas-platform/
- SLE MicroOS: http://www.suse.com/communities/blog/introducing-suse-containers-service-platform/
- Container Linux: http://coreos.com/blog/tectonic-self-driving.html
- Chrome OS: http://www.chromium.org/chromium-os
- Docker: http://docs.docker.com/engine/
- Rkt: http://coreos.com/rkt/
- etcd: http://github.com/coreos/etcd
- Kubernetes: http://kubernetes.io
- Farewell to Fleet: https://coreos.com/blog/migrating-from-fleet-to-kubernetes.html
- Versioning of Container Linux: http://github.com/coreos/manifest/releases/tag/v94.0.0
- MirageOS: http://www.openmirage.org
- Engler, D. R., M. F. Kaashoek, and J. O'Toole, Jr., "Exokernel: an operating system architecture for application-level resource management." In : M. B. Jones, ed. Proceedings of 15th ACM Symposium on Operating Systems Principles (SOSP) (ACM, 1995), pp. 251-266, https://pdos.csail.mit.edu/6.828/2011/readings/engler95exokernel.pdf
- Leslie, I. M., D. McAuley, R. Black, T. Roscoe, P. T. Barham, D. Evers, R. Fairbairns, and E. Hyden, The design and implementation of an operating system to support distributed multimedia applications. IEEE Journal of Selected Areas in Communications , 1996; 14(7):1280-1297
- Xen: http://www.xenproject.org
- KVM: http://www.linux-kvm.org
- ISC license: https://opensource.org/licenses/ISC
- Xen association: http://wiki.xen.org/wiki/Mirage_Incubation_Project_Proposal
- OCaml: http://ocaml.org
- MirageOS unikernel: http://www.openmirage.org/wiki/technical-background
- OPAM: http://opam.ocaml.org
- MirageOS installation: http://openmirage.org/wiki/install
- "Hello World" in OCaml: http://www.openmirage.org/wiki/hello-world
- OSv: http://osv.io
- Unikernel systems: http://unikernel.org/projects/
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.