How FreeDOS boots | Opensource.com

How FreeDOS boots

An overview of how your computer boots up and starts a simple operating system like FreeDOS.

Code going into a computer.
Image by : 
Opensource.com
x

Subscribe now

Get the highlights in your inbox every week.

One thing I appreciate from growing up with DOS computers is that the boot process is relatively easy to understand. There aren't a lot of moving parts in DOS. And today, I'd like to share an overview of how your computer boots up and starts a simple operating system like FreeDOS.

Initial bootstrapping

When you turn on the power to your computer, the system performs several self-checks, such as verifying the memory and other components. This is called the Power On Self Test or "POST." After the POST, the computer uses a hard-coded instruction that tells it where to find its instructions to load the operating system. This is the "boot loader," and usually it will try to locate a Master Boot Record or (MBR) on the hard drive. The MBR then loads the primary operating system; in this case, that's FreeDOS.

This process of locating one piece of information so the computer can load the next part of the operating system is called "bootstrapping," from the old expression of "picking yourself up by your bootstraps." It is from this usage that we adopted the term "boot" to mean starting up your computer.

The kernel

When the computer loads the FreeDOS kernel, one of the first things the kernel does is identify any parameters the user has indicated to use. This is stored in a file called FDCONFIG.SYS, stored in the same root directory as the kernel. If FDCONFIG.SYS does not exist, then the FreeDOS kernel looks for an alternate file called CONFIG.SYS.

If you used DOS in the 1980s or 1990s, you may be familiar with the CONFIG.SYS file. Since 1999, FreeDOS looks for FDCONFIG.SYS first in case you have a DOS system that is dual booting FreeDOS with some other DOS, such as MS-DOS. Note that MS-DOS only uses the CONFIG.SYS file. So if you use the same hard drive to boot both FreeDOS and MS-DOS, MS-DOS uses CONFIG.SYS to configure itself, and FreeDOS uses FDCONFIG.SYS instead. That way, each can use its own configuration.

FDCONFIG.SYS can contain a number of configuration settings, one of which is SHELL= or SHELLHIGH=. Either one will instruct the kernel to load this program as the interactive shell for the user.

If neither FDCONFIG.SYS nor CONFIG.SYS exist, then the kernel assumes several default values, including where to find the shell. If you see the message "Bad or missing Command Interpreter" when you boot your FreeDOS system, that means SHELL= or SHELLHIGH= is pointing to a shell program that doesn't exist on your system.

bad-missing-command.png

Bad or missing Command Interpreter

Jim Hall, CC-BY SA 4.0

You might debug this by looking at the SHELL= or SHELLHIGH= lines. Failing that, make sure you have a program called COMMAND.COM in the root directory of your FreeDOS system. This is the shell, which I'll talk about next.

The shell

The term "shell" on a DOS system usually means a command-line interpreter; an interactive program that reads instructions from the user, then executes them. In this way, the FreeDOS shell is similar to the Bash shell on Linux.

Unless you've asked the kernel to load a different shell using SHELL= or SHELLHIGH=, the standard command-line shell on DOS is called COMMAND.COM. And as COMMAND.COM starts up, it also looks for a file to configure itself. By default, COMMAND.COM will look for a file called AUTOEXEC.BAT in the root directory. AUTOEXEC.BAT is a "batch file" that contains a set of instructions that run at startup, and is roughly analogous to the ~/.bashrc "resource file" that Bash reads when it starts up on Linux.

You can change the shell, and the startup file for the shell, in the FDCONFIG.SYS file, with SHELL= or SHELLHIGH=. The FreeDOS 1.3 RC4 installer sets up the system to read FDAUTO.BAT instead of AUTOEXEC.BAT. This is for the same reason that the kernel reads an alternate configuration file; you can dual-boot FreeDOS on a hard drive with another DOS. FreeDOS will use FDAUTO.BAT while MS-DOS will use AUTOEXEC.BAT..

Without a startup file like AUTOEXEC.BAT, the shell will simply prompt the user to enter the date and time.

no-autoexec.png

Without AUTOEXEC.BAT, the shell will prompt for date and time

Jim Hall, CC-BY SA 4.0

And that's it. Once FreeDOS has loaded the kernel, and the kernel has loaded the shell, FreeDOS is ready for the user to type commands.

freedos-boot.png

FreeDOS is ready for you to enter your first command

Jim Hall, CC-BY SA 4.0

Old UNIX computer

It looks like retro computing, but it's a modern OS you can use to get stuff done.
4 different color terminal windows with code

Armed with just two commands DIR and CD, you can navigate your FreeDOS system from the command line.
FreeDOS fish logo and command prompt on computer

If you're already familiar with the Linux command line, try these commands to help ease into FreeDOS.
Looking at a map for career journey

Environment variables are helpful in almost every command-line environment, including FreeDOS.
Tips and gears turning

Here's a helpful guide to batch files under FreeDOS.

Topics

About the author

photo of Jim Hall
Jim Hall - Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder + project coordinator of FreeDOS. At work, Jim is CEO of Hallmentum, an IT executive consulting company that provides hands-on IT Leadership training, workshops, and coaching.