ELKS FAQ

This a list of answers to Frequently Asked Questions about ELKS, also known as Linux-8086.

This FAQ is maintained by Brian Candler; please send all updates to B.Candler@pobox.com. The latest version of this document is available at http://pobox.com/~b.candler/elks/elks-faq.html. Note that ELKS is in the very early stages of development and this information is likely to become out of date rapidly.

Additional information can be found at the ELKS home page at http://www.uk.linux.org/Linux8086.html.

There is a mailing list. To subscribe, send a message to majordomo@vger.rutgers.edu containing the words subscribe linux-8086 in the body. Archives of the mailing list can be found at http://epocha.pd.mcs.net/Linux8086/

Note that ELKS is not Linux, and the mailing list is not a suitable place for posting questions about Linux (despite its name). These would be better sent to one of the Linux-specific newsgroups such as comp.os.linux.answers

Section 1 - General

Section 2 - Compiling and installing

Section 3 - Using ELKS

Section 4 - Unanswered questions


Section 1 - General

Q1.1. What is ELKS?

ELKS is the Embeddable Linux Kernel Subset, a project to build a small kernel subset Linux (which will provide more or less UNIX V7 functionality within the kernel) that can run on machines with limited processor and memory resources. The initial proposed targets are the Intel 8086 and eventually the 286's 16-bit protected mode. A kernel that can run on this kind of hardware is useful for embedded systems projects, for third world deployment where 80x86 x>0 machines are not easily available, and for use on various palmtops.

More information on the background, goals and current status of the project can be found at the ELKS home page.

Q1.2. How does ELKS compare with standard Linux?

ELKS is intended as a subset of true Linux, and ought to be small enough to be understood by one person, so it should be invaluable as a learning tool. It is in the very early stages of development, and big chunks are missing, such as working multitasking, swapping, shared libraries, parallel and serial I/O, and networking. Having said that, it is already able to boot, provide virtual consoles, mount a root minix filesystems floppy, and start a small program.

Q1.3. Are there any ready-to-run distributions of ELKS?

Not yet. You need to use a standard Linux machine, download the sources, and cross-compile to generate the 8086 target code. A rootdisk will probably be provided along with ELKS 0.1.0, the first ALPHA-quality release. At some point after that there will probably be a distribution of some sort.

Q1.4. Can ELKS run on an 8088?

The 8088 is identical to the 8086, except it has an 8-bit external data bus instead of 16-bit (and thus is slower). So yes, ELKS will run on it.

Section 2 - Compiling and Installing

Q2.1. Where can I find the source?

At ftp://linux.mit.edu/pub/ELKS

Q2.2. How do I make an ELKS kernel?

Download dev86/Dev86-0.0.7.tar.gz and kernel/elks-0.0.44snap.tar.gz (or the latest versions) from linux.mit.edu. Unpack them into /usr/src (or any other convenient directory)
    tar -xvzf Dev86-0.0.7.tar.gz -C /usr/src
    tar -xvzf elks-0.0.44snap.tar.gz -C /usr/src
The development environment will be created in /usr/src/linux-86, and the kernel source in /usr/src/linuxmt. Next you have to build the development tools, which include the bcc compiler:
    cd /usr/src/linux-86
    make install
Next, if you have got hold of any patches which apply to this version, apply them to your source directory; then compile the kernel.
    # Apply patches (optional)
    cd /usr/src/linuxmt
    patch -p1 <patchfile   # -p1 strips off initial 'linuxmt/' from names
    # Build kernel
    make dep
    make
(If you're used to building Linux kernels with gcc, you'll be amazed at how quick this is! :-) The result is a floppy disk image called "Image", which you can copy to a formatted floppy and boot from.
    dd if=Image of=/dev/fd0
You should now be able to boot with this disk, but you won't get much further without a root floppy disk for it to mount. You'll need to use bcc to compile an 'init' program and make a root minix filesystem. This is explained further down.

Q2.3. I get an error saying that /usr/include/linux/vm86.h does not exist

Edit /usr/include/sys/vm86.h, and change #include <linux/vm86.h> to #include <asm/vm86.h>

Q2.4. How do I make an 'init' for ELKS?

After the ELKS kernel has booted it will run /sbin/init. Since important things like exit() and signal() are not yet implemented, this program can't be very sophisticated. But you can compile a simple "hello world" program using printf(...) or write(STDOUT_FILENO,...), and it should run.

Compile your program like this:

    bcc -0 -O -ansi -s init.c -o init
-0 selects 8086 code generation, -O enables optimisation, -ansi enables ansi-style function prototypes (only), and -s strips symbols out of the binary.

A real version of 'init' is being prepared for inclusion in the tiny-utils package, also on linux.mit.edu.

Q2.5. How do I make a root filesystem disk?

You need to create a minix floppy containing the appropriate bits and pieces. At present you need only two files - /dev/tty (4,0) and /sbin/init, which is your "hello world" program (see above). Don't expect more out of elks for the time being... there's a lot more work to be done.
Note: /dev/tty is different to normal Linux which uses (5,0)
    mkdir /usr/src/root86
    cd /usr/src/root86
    mkdir dev
    cd dev
    mknod tty c 4 0
    cd ..
    mkdir sbin
    cd sbin
    cp <your-program> init
    cd ..
    fdformat /dev/fd0H1440      # if floppy not yet formatted
    mkfs -t minix /dev/fd0 1440
    mount -t minix /dev/fd0 /a  # need a mount point "/a"
    cp -pR /usr/src/root86/* /a
    umount /a
Alternatively, if you have a 2.0.x kernel and mount-2.5k, you can use the loopback filesystem to create a disk image on your hard disk, and then dump it to floppy
    dd if=/dev/zero of=root.image bs=18k count=80
    losetup /dev/loop0 root.image
    mkfs -t minix /dev/loop0 1440
    mount -t minix /dev/loop0 /a
    ...
    umount /a
    dd if=root.image of=/dev/fd0

Q2.6. What if I have an XT with a 360K disk drive?

Preparing boot and root images to run on a different machine requires a little care, especially if the target machine has a 360K drive. 360K drives (5.25" DD) have 40-track heads, and 1.2MB (5.25" HD) have 80-track heads. A 1.2MB drive can read 360K disks but not reliably write them, since it will write magnetic tracks which are half the width expected by a 360K drive.

One solution is to fit a 360K drive as the second drive in your Linux PC - you can then format 360K disks with fdformat /dev/fd1d360 and create filesystems as usual.

Otherwise, you will need to create a floppy disk image file, transfer it to the PC which has the 360K drive (e.g. using a serial cable), then use "rawrite" under DOS to recreate the disk from the image file.

Boot disks

The 'Image' file can be written to any type of floppy disk and will boot successfully, so all you need to do is transfer the file and use 'rawrite' to make the target disk.

However at the moment (version 0.0.44), the type of root disk to expect is hard-coded into the kernel. So before compiling, if you are going to run on a machine which does not have a 1.44MB drive, you need to edit drivers/block/doshd.c, search for "hack hack" and change the floppy geometry parameters. This should be fixed soon.

Root disks

You can prepare a 360K root image on a larger drive - when you enter the mkfs command substitute '360' for the size of the filesystem. Once you have copied the files to this disk, unmount it, then you can create a disk image file from it:
        dd if=/dev/fd0 of=root.image bs=1k count=360
This image can then be transferred to the target and written out using 'rawrite' as before. If you use the loopback filesystem this step is not necessary.

RAM limitations

0.0.44 expects there to be 640K RAM available. If not, you will need to change the constants DEF_INITSEG and DEF_SETUPSEG in include/linuxmt/config.h (should also be fixed soon)

Section 3 - Using ELKS

Q3.1. Can I run bcc binaries under Linux?

Yes - by loading a kernel module you can run ELKS binaries directly. This makes development of programs to run under ELKS much less painful, since you can test them on your normal Linux system (although they might not work under ELKS, if your program uses a kernel facility which is not yet implemented)
    cd /usr/src/linux-86/elksemu
    make module
    insmod binfmt_elks.o
Note that you will need to rerun the 'insmod' each time you reboot. There are some sample bcc programs you can try in /usr/src/linux-86/tests (such as a version of 'wc')

If when making the module you get an error saying "modversions.h: no such file or directory" then you need to edit the Makefile to remove the reference to this file, i.e.:

MODCFLAGS=-D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
          -fno-strength-reduce -pipe -m486 -DCPU=486 -DMODULE -DMODVERSIONS

Q3.2. Can I boot ELKS under DOSEMU?

Yes. ELKS can boot inside dosemu 0.63.1.36 running under Linux 2.0.7, and probably other combinations as well. Make sure your floppy drive is configured in /etc/dosemu.conf, and use the -A flag to dos or xdos if necessary to force a floppy boot.
    floppy { device /dev/fd0 threeinch }  

Section 4 - Unanswered questions

Answers to these questions would be appreciated!


Brian Candler / last updated 2 November 1996