User Tools

Site Tools


Cross-compiling MINIX 3


This is for cross-compiling MINIX from another Unix-like system. To build MINIX from within MINIX, check this page instead.

Cross-compilation is the act of building MINIX from another operating system. Since MINIX now uses the framework from NetBSD, cross-compilation should work on most mainstream UNIX-compatible systems. A build compatibility table is available at the end of this document.

Install dependencies

Before attempting to cross-compile MINIX, you need a working C toolchain, Git and some additional software on your host platform.

For Debian-based operating systems, run the following command as super-user:

# apt-get install build-essential curl git zlibc zlib1g zlib1g-dev

Note: Also on Ubuntu, if you get an error stating that “'/lib/cpp' fails sanity check”, you need to install the GNU C++ compiler:

$ sudo apt-get install g++

Note: On FreeBSD and Minix (compiling for ARM on x86, e.g.), if you get a message along the lines of “Skipping image creation: missing tool 'mcopy'”, please install the emulators/mtools package.

Getting the sources

Once the required tools are installed, the next step is to obtain the sources. Run the following commands in a terminal:

$ mkdir minix
$ cd minix
$ git clone git:// src
$ cd src

NOTE: The releasetools script will generate object files and put them outside the source directory; i.e., if you've cloned to ~/minix/src/ and build from there, things will start showing up in ~/minix/ as an artifact of the build process.

Cross-building for x86

It's time to build MINIX itself. There are some wrapper scripts that will build ready-to-boot images from scratch (i.e. just the minix source tree) for either x86 or ARM. These scripts produce a lot of output and will take a while to complete the first time - a cross-toolchain based on LLVM is built from scratch.

$ bash ./releasetools/ 
Writing Minix filesystem images
 - USR
Part     First         Last         Base      Size       Kb
  0      0/000/00     0/000/07         0         8        4
  1      0/000/08    64/000/07         8    131072    65536
  2     64/000/08  1856/000/07    131080   3670016  1835008
  3   1856/000/08  1984/000/07   3801096    262144   131072
To boot this image on kvm:

A command line for running the result in a KVM virtual machine is printed at the end of the process.

Cross-building for ARM

A similar procedure exists for ARM. Please see MinixOnARM for much more information.

Using directly

Please refer to NetBSD's documentation on for details.

From a source directory:

$ sh -mi386 -O ../build tools

Please note that by default, the script will output the built objects to /usr/obj, so make sure it exists. Alternatively, use as above the “-O” option to redirect the output to somewhere else. When this process is completed, you'll have a ../build/tooldir.<something> directory. The <something> is roughly equivalent to

$ echo ''uname -s''-''uname -r''-''uname -m''

Among the tools that are built are gcc, binutils, and gmake. The sources for these tools are not provided by us. Instead, they are downloaded on-the-fly as tarballs from the minix webserver

Building world

The next step is to actually build MINIX:

$ sh -mi386 -O ../build -U distribution

This process will create a ../build/destdir.i386 directory that holds the built distribution of MINIX.

Other useful options for qemu are -monitor telnet::4444,server,nowait (to access some interesting internal state by telnet) and -serial stdio - for convenient debug output over 'serial.'

Compiling things without

To run make in the cross-environment, i.e. to rebuild a tool (host target) or minix item (minix target), without running the full procedure all over again, use nbmake-i386, a make wrapper that sets all the right environment. First expand your $PATH to include it:

$ cd SRCDIR/tools
$ nbmake-i386 clean
$ nbmake-i386

will rebuild all the tools. After that you can e.g.

$ cd zic
$ nbmake-i386 clean
$ nbmake-i386

to just rebuild zic. As you can tell if you set MAKEVERBOSE=2, tools/zic/ will invoke cc (to run on the host platform), whereas nbmake-i386 will invoke i486–netbsdelf-gcc from your tools dir if you run it in usr.sbin/zic/, so a Minix-targeted binary is produced.


The is tailored towards NetBSD and as such not all features make sense for MINIX. For example, we don't have a kernel configuration file. Also, you can't use for native builds on MINIX at the time of this writing. You can consult's documentation by invoking:

$ sh

But know that not all operations and options are supported. For example, we only support the distribution build operation. You can't generate iso images with the script.

Build flags for

It is possible to tweak the build using build flags. Here are some you might find useful.

Option name value example Description
COPTS c flags COPTS=-g c compiler opttions

Build flags for nbmake

It is also possible to tweak when building separate components using nbmake-i386

Option name value example Description
MAKEVERBOSE [1] MAKEVERBOSE=2 Instruct make to be more verbose

Mounting a MINIX disk image on Linux

1. Load the loop kernel module, or adapt kernel command line:

$ modprobe loop max_part=15

or add to your kernel commandline : max_part=15

2. Setup a loopback device to point to your disk image:

$ losetup /dev/loop0 minix.img

3. (Optional) list the available partitions:

$ dmesg | tail

or use

$ ls /dev/loop0*

4. Mount the desired partition somewhere

$ mount /dev/loop0p5 /mnt

Build compatibility

Host platform Version Buildable MINIX architectures Version Updated
Ubuntu x86 32-bit 14.04 x86 32-bit / ARMv7 3.4.0rc 2016-02
Ubuntu x86 64-bit 14.04 x86 32-bit / ARMv7 3.4.0rc 2016-02
Arch Linux x86 32-bit x86 32-bit 3.2.1 2013-08
Arch Linux x86 64-bit x86 32-bit / ARMv7 3.2.1 2013-08
Mac OS X Lion x86 64-bit x86 32-bit / ARMv7 3.2.1 2013-08
Mac OS X Maverick x86 64-bit x86 32-bit / ARMv7 3.3.0 2014-10
FreeBSD x86 32-bit 10-CURR. x86 32-bit / ARMv7 3.2.1 2013-08
FreeBSD x86 64-bit 10-CURR. x86 32-bit / ARMv7 3.2.1 2013-08
Windows Subsystem for Linux 64-bit 10.14393 x86 32-bit / ARMv7 3.4.0rc 2016-08
Debian x86 32-bit 8.8.0 x86 32-bit 3.3.0 2017-05
developersguide/crosscompiling.txt · Last modified: 2017/05/19 09:17 by jeanbaptisteboric