Table of Contents

MBR partitioning week

2025-08-10

This week was all about working on MBR partitioning.

bootimg

The bootimg.asm script gained a companion, partdisk.asm. This script allows to create a hard disk image, either raw or with a dosemu image header. (The dosemu image header makes the CHS geometry explicit, avoiding misdetection by the application to access it.)

The script's use of its _PAYLOAD define is described in a documentation comment at the top of the source text file. There are a number of example commands, all of which can be run by copying them and pasting into a bash shell.

A number of alignment choices are currently hardcoded into the script: Logical and primary partitions start on a head boundary (ie CHS sector = 1) while extended partitions start on a cylinder boundary (ie CHS head = 0 and CHS sector = 1). All partitions end on a cylinder boundary (ie CHS head = maximum and CHS sector = maximum).

The only absolutely needed alignment is extended partitions of type 5 accessible by MS-DOS (both v5 and v7) must start on a cylinder boundary. This includes nested extended partitions. As described once in the blog post introducing the chstool.eld, the LBA start sector of a logical partition is based on the innermost extended partition in which it is found. MS-DOS adds the extended partition base as a cylinder number, after calculating a CHS tuple, requiring the EPBR be aligned on a cylinder boundary. (Of course, I changed lMS-DOS to not need that even when using CHS to access a disk.)

The specific changesets:

scanptab

The scanptab and chstool.eld changes mostly concern adding modes to the partition table scan code. This is intended to eventually replace the partition table scan in lMS-DOS's msbio/msinit.nas, including the Do Mini and Find Mini Partition handlers.

The following are the individual changes to scanptab. Note that each of the changes may require a matching revision of the chstool.eld be used.

Multi pass scanner

Instead of the single scan_partitions entry, four entries are used for the multi-pass scanner: scan_priority_primary (only takes effect if active primary first mode is on), scan_early_primary, scan_logical, and scan_subsequent_primary. These four entries correspond to the non-DLA-sort modes of FreeDOS, MS-DOS, or Enhanced DR-DOS. (DLA stands for "Drive Letter Assignment". DLA sort is a FreeDOS term; if enabled then all drives from one unit are processed together (like the single-pass scanner).)

If DLA sort is not used, then the first pass should be used to process all HDD units first. Then the unit variable must be reset, and the second pass be used to process all HDD units again. Likewise for the third and fourth pass. The result is that different types of partitions are processed in stages. This mimics the traditional MS-DOS and DR-DOS orders of processing HDD partitions.

lDebug chstool.eld

These changes include the application-side support for scanptab modes and multi-pass non-DLA-sort operation.

Added later: