Documentation and guides

MirageOS consists of a set of OCaml libraries that link with a runtime to form either a standalone unikernel or a normal UNIX binary. These libraries are managed via the OPAM tool. After describing MirageOS's system requirements, we will introduce the basics of OPAM and setting up for MirageOS.

Requirements

MirageOS has been tested on many modern Linux distributions, MacOS X 10.10+ and FreeBSD 11+.

You will need OPAM 1.2.2 or later and OCaml 4.04.2 or later.

Some backends have specific requirements for the host system:

ukvm: To compile the ukvm backend you must have a Linux host.

virtio: To compile the virtio backend you must have a Linux or FreeBSD host.

xen: To compile the xen backend, you must have a 64-bit Linux host. 32-bit is not supported at this time.

MacOS X-specific notes

10.10: No special requirements beyond Homebrew or MacPorts to get OCaml and OPAM.

10.9 or lower: You will also need the tuntap kernel module if you want to use the MirageOS network stack from userspace. Note that we do not test older versions of OSX beyond 10.10.

If you are using Homebrew, run

brew install opam
opam init
opam install mirage

Linux-specific notes

Ubuntu 16.04 (Xenial) or higher

This has the latest packages required in the base distribution, so just run:

FreeBSD-specific notes

You will need ports or pkg set up. To install OPAM use the ocaml-opam port/package. FreeBSD currently packages OCaml 4.02.3, so you will need to install a newer compiler using OPAM.

MirageOS Package Management with OPAM

We use OPAM to manage OCaml compiler and library installations. It tracks library versions across upgrades and will recompile dependencies automatically if they get out of date. Please refer to OPAM documentation if you want to know more, but we will cover the basics to get you started here. There is a Quick Install Guide if the above instructions don't cover your operating system.

Note that you require OPAM 1.2.2 or greater to use with MirageOS. Some distribution packages provide earlier versions and must be updated; check with

$ opam --version ## response should be at least 1.2.2 viz.
1.2.2

All the OPAM state is held in the .opam directory in your home directory, including compiler installations. You should never need to switch to a root user to install packages. Package listings are obtained through remote sources, which defaults to the contents of github.com/ocaml/opam-repository.

After installation, opam update -u refreshes the package list and recompiles packages to the latest versions. You should run this regularly to get the latest packages.

Next, make sure you have at least OCaml 4.04.2 or higher as your active compiler. This is generally the case on MacOS X, though Debian only has it in the testing distribution at present. But don't worry: if your compiler is out of date, just run opam switch to have it locally install the right version for you.

$ ocaml -version
# if it is not 4.04.2 or higher, then run this
$ opam switch 4.04.2

Once you've got the right version, set up your shell environment to point to the current compiler switch.

This updates the variables in your shell to match the current OPAM installation, mainly by altering your system PATH. You can see the shell fragment by running opam config env at any time. If you add the eval line to your login shell (usually ~/.bash_profile), it will automatically import the correct PATH on every subsequent login.

That's it. You now have everything required to start developing MirageOS unikernels that will run either as POSIX processes or as standalone unikernels. Next, why not try building a MirageOS hello world?