In my previously article about Inferno, I mentioned that I was planning to write some notes about installing and using Inferno in a Wiki attached to a fork/clone of the official Mercurial repository for Inferno. I got a bit distracted by other projects and felt that I couldn't write about this until I'd managed to get those projects out of the way. Now I've found the time to tidy up the scripts I wrote and write one or two things about them. The aim has been to create a hard disk image containing a suitable kernel that will boot up successfully and set up a user environment, ideally graphical but a shell is enough to begin with.
I began with Brian Stuart's How to Build a Native Inferno Kernel for the PC, which describes how to build a kernel for booting from a floppy disk image. Really, I wanted to build a hard disk image, but this was a good place to start. I wrote some instructions based on the above guide, but using some helper scripts of my own that I put in the tools directory of the Wiki repository.
Building a kernel is quite straightforward once you realise that the process is done from within the os/pc subdirectory of the inferno-os distribution. Since Inferno comes from the branch of the Unix family tree where it is customary to build your own compilers as part of building your operating system, actually compiling a kernel is a fairly smooth process. Of course, we are relying on the GCC toolchain to bootstrap this process, which also works smoothly.
Brian Stuart wrote another guide, Installing Native Inferno on a PC, which describes how to install a pre-built disk image from a CD-based installer. I considered building a bootable CD like this but that looked like a long diversion involving tools I had no experience with. I wondered why an installer like this was needed — my plan was to try and do everything that it would do in the hosted environment that you can run under GNU/Linux. At least, I wanted to be able to create a disk image with partitions, format the file systems and copy a pre-built kernel into it. However, I found that the disk formatting and partitioning tools behave differently in the hosted environment with disk image files to the way they behave on a real system (or one running in qemu) with real disks to manipulate.
One potential solution seemed to be to partition and format a disk image under Linux and try and mount the partitions in the hosted environment but I failed to find a way to mount a file as a disk image using an offset into the file – the equivalent to mount with the offset option under Linux. In addition, while I could create a FAT partition under Linux and copy the kernel into it, a difference in the format mkfs.vfat generates and the one expected by the bootloader used for Plan 9 and Inferno meant that the kernel was never loaded. So, it seemed easiest to build the kernel under Linux, handle the disk partitioning and formatting under Inferno running in qemu, and somehow copy the files into the ready-made partitions.
I briefly experimented with creating a second hard disk image so that Inferno in qemu could just copy files from there into the installation image but that didn't go as planned – the supported file systems either couldn't handle large partitions (FAT16) or had other issues.
In the end, given the problems with mounting sections of disk images in hosted Inferno, the installation scripts do some chopping up and stitching together of disk images. I'm not very satisfied with this solution but it seems to work. The installation process now looks roughly like this:
I've put some basic instructions for creating a fairly simple disk image in the Wiki mentioned above. In theory, it should build a 256 MB disk image containing an 32-bit x86 kernel and user space, ready to boot in qemu. I dug around in the configuration files and enabled support for the rtl8139 network card so that the installation can potentially do something useful, but couldn't get VGA support working. That's something that will have to wait for a future revision of the tools.
I wandered away from Inferno for a while and came back to publish these scripts. I'm interested in seeing if it's possible to bring up a natively-running desktop environment if I can get some hints about how to initialise VGA support properly. Since Plan 9's desktop can be run on native hardware, it would be a shame if Inferno couldn't do the same. In the meantime there are always other projects to look into.
Category: Free Software
Copyright © 2016 David Boddie
Published: 2016-10-16 21:14:48 UTC
Last updated: 2016-10-16 21:14:48 UTC