Boot Image Creation Tool

by Phil 3. May 2009 06:24

configFor the MOSA project, we needed a tool to create image files for various Virtual machine software, such as for Microsoft Virtual PC and Microsoft Virtual Server, VMware, and VirtualBox, including simulators such as QEMU, and Bochs.

The use of virtualization software would help us facilitate the building and testing of the MOSA AOT/JIT compiler, the reference Operating System, and CIL based runtime libraries.

So we need an virtual disk image tool that could:

1. Create disk images in various virtual disk formats: IMG, VHD and VDI.

2. Create Master Boot Block (MBR) and partition to the disk image.

3. Create FAT12 or FAT16 partitions (or EXT partitions).

4. Incorporate a multi-stage boot loader with support for the Multiboot Specification.

5. Add files to the file system.

6. Execute on Windows or Linux platforms.

After an exhaustive search across various open source operating systems, I was unable to find a single tool that could do all of this. Most projects use a tool set of utilities, such as GRUB, LILO, mkfatfs, fdisk, and Syslinux, and custom scripts to create the single boot image. Unfortunately those tools and their related scripts were always platform specific to either Linux or Windows.

So I decided to roll my boot image creation tool in C# that incorporated all these features. One of the good things about having written parts of the device drivers, driver system, and file system support for MOSA is already having code for creating, reading and writing MBR, partitions, and FAT12/16. Implementing basic support for the virtual disk formats was relatively straightforward after reading the specifications and understanding the Cluster-Head-Sector (CHS) address legacy. The most difficult part was incorporating the Syslinux boot record and boot loader binaries. Those binary executables required very specific in-place modifications based on the virtual disk geometry and file system.

The result is a tool simply called “CreateBootImage.exe”. It run on both Windows and Linux (with Mono), and is now available as part of the MOSA project.

Here’s how to use the tool:

The tool accepts two command line arguments:

CreateBootImage.exe <configuration file> <image file>

The configuration file contains a list of options, one per line, with arguments separated by a tab. The following options are supported:

option Arguments Description
-volume Volume Name Set the volume name for the first partition
-blocks # of Blocks Set the number of 512-byte blocks
-fat12   Use FAT12 file system
-fat16   Use FAT16 file system
-fat32   Use FAT32 file system (untested)
-vhd   Create image in VHD (Virtual PC/Virtual Server) format
-vdi   Create image in VDI (VirtualBox) format
-img   Create image in IMG format
-syslinux   Patch disk image for Syslinux
-mbr Filename Use file for Master Boot Record
-boot Filename Use file for Boot Record
-file Filename, Destination Include file in file system (destination optional)


The tool can create disk images for the following emulators:

Emulator File Format
Virtual PC 2004/2007 .VHD
Virtual Server .VHD
VMware .VHD
VirtualBox .VDI
QEMU .IMG
Raw Image .IMG

Tags: , ,

Virtualization | MOSA

Virtual PC Is Now Free!

by Phil 16. July 2006 18:00

You can now download Microsoft Virtual PC 2004 Service Pack 1 software for free! Microsoft will also be offering Virtual PC 2007 for free.

For those unfamiliar with the technology, virtualization allows multiple operating systems at the same time on the same physical computer. This has numerous benefits, for example, it can be use to test software on multiple versions of an operating system prior to distribution, or to run a legacy application that only runs on an older operating system.

Tags:

Virtualization

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant

Projects

Software Stack

Recent Comments

Comment RSS

Badges

Enhanced with Snapshots