Alternate OS probe module for BeleniX Installer

From WorkOutWiki2008

Jump to: navigation, search



Moinak Ghosh


This is a project to develop a utility that can scan the entire partition table, identify bootable partitions and generate entries suitable for adding into GRUB's menu.lst file.


Most of the time when we install operating systems including OpenSolaris in a multi-boot configuration, the OS overwrites the MBR with it's own stage1 bootloader, sometimes out of necessity. For eg. OpenSolaris includes a patched GRUB that can understand UFS and ZFS. Since OpenSolaris includes GRUB it can boot other partitions easily like Linux or BSD or Windows. However it needs adding the relevant GRUB entries into menu.lst by hand.

This utility is an effort to automate the process. The utility should be able to identify the partition and try to check the filesystem type on it. If it is of a supported filesystem then it should access that filesystem and attempt to decide if this is a root filesystem, if yes then guess the OS/distro and generate an appropriate GRUB entry.

Though this sounds like a tall order, the entire thing can be done via a userland utility without requiring kernel support for each an every filesystem type. What's more this utility can be made portable such that it works on other OSes apart from OpenSolaris.

The approach is to use the basic filesystem reading support that is present in GRUB itself for a whole bunch of filesystems. GRUB as a whole is not used, just the individual filesystem support code needs to be extracted and utilized. In addition a little bit of logic is needed to scan through primary and extended partitions. Since we will not be using GRUB as a whole some simple emulation of a few API calls provided by GRUB for the filesystems is needed (for eg. devread and rawread). Apart from GRUB future work involves using libntfs to also probe NTFS partitions.

Instead of GRUB code, it is possible to use libraries from individual projects like ext2fsprogs, xfsprogs, reiserfsprogs etc. But it creates dependencies on a whole range of different packages and libs and also needs more work to make all these separate pieces build on OpenSolaris. Some like e2fsprogs are portable and build out of the box, while others like reiserfsprogs are much more difficult. Using GRUB code keeps our utility tiny and simple and portable.

This project is an early work in progress started very recently. So there is no svn repository yet, but will soon be created. The hope is to achieve scanning and detection of a couple of common filesystem types like ext2 and reiserfs by the time FOSS.IN completes. This utility will be used in the BeleniX installer to automatically detect other OSes in a multiboot configuration. This project does not require any specific OpenSolaris knowledge though some basic knowledge of device naming conventions will help. This will also be covered in a short intro at the start of the Workout session.


In addition it is assumed that you will be bringing your own laptops. It will helpful if you also have VirtualBox installed.

Languages, tools to be known

* C, Gcc and Makefiles.

Source code

There is initial code/logic for the utility, available here:

You can download a tarball from here: wget Check out the README and STATUS files.

Links to overall design/architecture

Pre-event planning

Discussions on and IM on #belenix @ freenode if needed. Initial code postings will be announced on these mailing lists before the event.


* Understand the partition table scanning logic
* Write the basic GRUB support API emulation layer
* Build the initial utility and GRUB filesystem support code outside of GRUB 
* Identify filesystem detection heuristics.

At Foss.In/2008 we should be able to at least get the ability to detect Ext2 and possibly either reiser or NTFS.

Getting in touch

* Email:


* Moinak Ghosh
* Sriram Narayanan
Personal tools