Track 0 DOS


Copyright (C) 2010 Ton Daas
T0-DOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.

T0-DOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see www.gnu.org/licenses.

1. Introduction

T0-DOS Copyright (C) 2010 Ton Daas (http://daas.info) is a DOS environment created at boot time, utilizing unused space on your fixed disk. It is primairily written to aid a user friendly Multi-Partition Boot manager menu, but thereby also provides access to a real-mode DOS environment to allow for partition management or any other use without the need for a diskette, CD, USB-stick or other boot media.

It uses a slightly modified way to boot your PC from fixed disk to allow for Multi-Boot. An exit to DOS is enabled by using all unused sectors (max. 63) on cylinder 0, head 0, which on most PC's are left free except for the MBR in sector 1 (Normally the first partition starts on head 1 of cylinder 0). It makes use of good old IBM-DOS version 1 (1.0 or 1.1) as this is the only version that is small enough to fit in the limited available space. A handy advantage is that this version does not require a BPB in the bootsector and allows compatibly with a fixed disk MBR. As version 1 did not support fixed disks yet, it consequently does not search nor assign drive-letters to partitions during the boot process. This provides an ideal platform to do partition manipulation.
Note: Linux normally installs LiLo or GRUB in track 0, but is thereby depending on system files in the Linux partition. However, Linux, including its bootloader, can also be installed completely in its own partition and is then self contained, making partitions OS independent.
Windows-NT versions also come with its own boot manager. By default Windows 10 creates even 2 or 3 primary partitions, one for its boot-manager, one for the system and one for recovery. With some creativity the installer can be forced to combine them into one partition.

2. Disk layout

MBR (source listing) (sector 1) contains the partition table and al the necessary code to start any partion that has the bootflag active and will act exactly the same as a standard MBR-code from e.g. MS-Windows XP (Windows 7 to 10 has additional code in it to support encrypted partitions, which I do not support). It supports both CHS-type partitions as LBA-type partitions. In addition it has code for features to divert from the default boot process and start T0-DOS from sectors 2 and 3 instead. These features are:

  1. Absence of any bootflag in the partition table.
  2. Detection of Alt-0 key pressed during boot.
note: Use of /A switch at installation will always force T0-DOS to load.

FAT (sector 2 and 3) contain two 12-bit FAT copies of a standard 160KB floppy. Since the available space is at maximum only 31.5KB (63 sectors of 512 bytes) and is far less than this 160KB, only a small number of FAT-entries are actually used. The remainder of these two sectors contain code for the DOS boot process and support for DOS 1 to function from fixed disk. It also contains code for a prompt like in "Tiny Bootmanager" which is shown at boot when T0-DOS Menu program is not found present, thus allowing the user to start a partition or DOS 1 by choice anyway. When DOS 1 is loaded, the bootsector and the code in the FAT sectors are kept hidden and protected from the DOS user. This code is removed from memory when a partition is started.

DIRECTORY (sectors 4 to 7) is available to the DOS user as on a normal 160KB floppy and has room for 64 entries. Of course 64 entries is quite excessive for only 56 data clusters, but is necessary to be compatible for DOS 1.
Note: DOS 1 does not understand subdirectories, volume labels or long filenames.

DATA (sectors 8 up to 63) with a maximum of 28 KB (56 sector clusters) is available for files, but the amount depends on the track size of the particular fixed disk and the unused status in the partition table. If DOS 1.1 system files (IBMBIO.COM, IBMDOS.COM and COMMAND.COM) are installed, they will require 13.5 KB (27 sectors) of this space. This leaves even enough space for some additional utilities. Unlike the standard DOS 1 boot requirement, the system files don't need to be at front, but can be located anywhere in the directory or cluster locations.

3. Multiboot with T0-DOS

T0-DOS can show at boot, under conditions mentioned above, a simple prompt: Start partition (0-4 or Esc)?:_
If T0DOSMNU.COM is found present in the T0-DOS volume, it will be executed instead of showing this prompt.
Both methods allow the start of a partition by choice at boot time (the number refers to the index in the partition table). T0DOSMNU however has more features and is more user friendly then the simple prompt.
By choosing "0", DOS 1 will be started from the T0-DOS volume if present, to allow you to run utilities from there. Exit from DOS 1 is simply done by reloading T0DOSMNU.COM or by pressing Alt-Ctrl-Del.
When choosing "1"-"4", it will first check if the partition is of hidden type and unhides it, while hiding other conflicting partitions and saves it before loading. If the selected partition is not of a hidden type, then the seach for conflicts does not take place and the partition is started. It is also possible to choose an extended partition. In that case it will start that extended partition and if the proper code is present in it, it will allow to chain boot the first logical volume. T0FORMAT will install this code by default. When changing the partition table with a partition manager however, this code may get lost and booting from a logical volume will fail. You can reïnstall it with T0FORMAT /B.
If you booted with an active boot-flag present without the /A install option, it can be interrupted by pressing "Alt-0". When installed with the /A switch, the prompt or menu will always appear. The boot-flag will then be moved to the new selected partition and saved.
When "Esc" is pressed, control will be returned to ROM-BIOS with an interrupt 18h, which allows most BIOS code at present to attempt to boot from the next device as provided in the BIOS-setup menu. For old IBM PC's this was the method to start ROM-Basic, which was no longer supported in later generation PC's.

4. T0-DOS environment

To the DOS user it appears as if it booted from floppy drive A:. If the PC has physical diskette drives attached, they get drive letters B:, C: etc. You have to bear in mind though that DOS 1 is only able to access 160KB and 320KB floppies (With some tricks even 1.44 MB diskette units might be used for storage). The fixed disk is not recognized at all and therefore gets no drive letters assigned. However, the BIOS interrupt 13h still gives full access to it as usual and can be called with partitioning tools etc.

Int 13h - bios calls are examined and altered to allow DOS 1 to function, but changes are undone again when DOS exits.
Calls are rerouted for drive 1 (B:) to 0, 2 (C:) to 1, etc. Calls for drive 0 (A:) are rerouted and translated to drive 80h, cyl 0, head 0. As DOS 1 does not support fixed disks, calls for drive 80h do not occur, however, such calls will be handled unchanged, thus providing a means for a DOS utility to manipulate disk partitions. The utility should of course conform to DOS 1 function calls.
Int 13 calls for drive 0 (A:) are only honoured with (AH)= 0, 1, 2, 3 and 4. An attempt to write to the bootsector will return with write protect error. A call to format any track will also return with a write protect error. A read of the bootsector however is allowed, but returns with zeros in the buffer. Reading FATs will reflect all clusters above the available number as unusable. An attempt to alter these entries in the FAT have no effect on their contents. Use of the following DOS utilities targetting A: is obviously not recommended: FORMAT A: | DISKCOPY @: A: | SYS A:

5. Hardware requirements

T0-DOS and it's installation program is written using only Intel 8086 instructions and uses BIOS calls which were already supported in the old 5150 PC. I have tested it on a IBM PC 5150 emulator and an old 80286 PC with 4 MB RAM, grayscale VGA video and 30 MB ESDI disk, but also on recent multi-core PC's with 4 GB RAM and a 2 TB SATA disk. Fixed Disks greater than 2TB require the new GPT type MBR, which is not supported.

6. T0Format installation program

T0FORMAT.COM is the program to format sectors on cylinder 0, head 0 of the fixed disk with T0-DOS. The program examines current partions to make sure that none will occupy track 0. It replaces MBR bootcode while preserving your current partition table and NT signature. It further creates 2 FAT tables and a directory in sectors 2 to 7, emulating a 160 KB floppy. The program must be executed in real mode DOS, but will run on any version including DOS 1. (So do not attempt to run the program from Windows! Also MS DOS 6.22 seems to have a fault in handling FCB's and switches. Older and FREEDOS versions work OK.)

Syntax: T0FORMAT [@:][filename] [/#] [/A] [/B]
[@:][filename] - specifies a backup file (RAW 160KB floppy image truncated to max. 31.5KB). Path names are not allowed. If no filename is provided, drive @: is searched for system files to transfer (must be an IBM-DOS 1 system floppy). If no drive nor filename is specified, only an empty volume is formatted.
/# - specifies the disk number to format track 0 on. # defaults to "1".
/A - installs a modified version. In this version a partition will always be marked active on disk. It removes the active flag for the prompt or menu, but places it back on the choosen partition. Consequently the prompt or menu can not be disabled. I do not recomment the use of this option if not absolutely necessary. (it prevents misbehaviour of MS Windows 10)
/B - specifies that only the boot code is to be refreshed (usefull to regain access after installation of e.g. Windows, which replaces the code in the MBR by default. It will however leave the remainder of the track unchanged). This switch must be used taking the /A switch option into account, as the /A switch has only effect on the MBR code.

7. T0-DOS-menu multi-boot selection program

T0DOSMNU.COM (source listing) is the program searched for in the T0-DOS volume and run on a multi-boot request. It contains 4 rows with partition descriptions corresponding with the 4 partition table entries in the MBR and a row to load DOS 1. When it shows at boot, the default partition is highlighted. If it is a partition with the boot-flag set active, this is indicated by a flashing highlight. In this case the time-out option is disabled. If no partition has the boot-flag set active, a time-out delay may have been specified to start the default partition when it expires. Pressing keys "0"-"4", first description letter, "Space" or "Enter" will also start the selected partition. With the "↑" and "↓" key the selection can be changed. Pressing "Esc" will return control back to ROM-BIOS with interrupt 18h. Pressing the "Tab" key will allow you to enter menu-edit mode.
In edit mode the partition descriptions can be modified, menu colors changed, timeout adjusted, a password protection enabled and a default selection be set. Changes are saved when "F10" or discarded when "Esc" is pressed on exit.
When a description row starts with "!" or "Space", it is regarded a comment and the corresponding partition row is not selectable.
The row that is highlighted on exit from edit mode with "F10" is the new default selection.
The time-out delay can be adjusted between 1-99 seconds or set infinite with "+" and "-" keys. Pressing key "0" will force its value to 0, which means that the boot-flag will be set active on the next selected partition start. If the time-out value is not 0, the boot-flag will be removed on the next selected partition start. (With /A option this mechanism is not functioning)
A password may be specified to force controlled access to edit-mode and DOS. Installation of the program is not needed as it can simply be copied in the T0-DOS volume.

Syntax: T0DOSMNU
no parameters

8. Recommended utilities

DOSVER.COM (source listing) is an included utility to show the current DOS version. It is intended for DOS 1, but will work on other versions as well. When started as "DOSVER SETDATE" it also sets the date from CMOS (if present on your PC).

PTTE.COM - "Partition Table Tiny Editor" (not included, but present on my site) is a very small but powefull and modern DOS utility that easily fits on T0DOS and is also DOS 1 compatible.

9. T0-Drive

T0DRIVE.SYS (source listing) is a DOS device driver which can be used on DOS version 2 and above to give access to the T0-DOS volume. (It has been tested with IBM DOS 3.3, IBM DOS 7.0, MS DOS 6.22, MS DOS 8.0 (Win-ME) and FreeDos 7.1) It can be installed from CONFIG.SYS as follows:

DEVICE[HIGH]=[PATH]T0DRIVE.SYS [#]

[HIGH] - is used to load driver in upper memory if possible.
[PATH] - specifies the path where the file is located.
# - specifies the fixed disk number. # defaults to "1".

The drive will be installed as a virtual FAT-12 device of present size. The boot record will provide to DOS a standard BPB to allow upward compatability. This boot record is R/O and the hidden code in both FAT sectors is not shown and can not be changed. The available space can be used normally. To stay compatibel with DOS 1 you should not create a volume-label or subdirectories.

After formatting T0-DOS, this is the easiest way to get access to this area to copy the DOS 1.1 system files, T0DOSMNU.COM and other utilities into it.

If you have problems, questions, bugs or suggestions regarding this software, please feel free to contact me at ton@­daas.info