dloader

Updated: May 06, 2022

Write a boot loader to a disk on an x86 system

Syntax:

dloader [-v] [-d drive_number] [-F|H] device loader [device loader]...

Runs on:

QNX Neutrino

Options:

-d drive_number
Set the BIOS drive number for booting the second-stage loader (*pc2). This lets you set up the loader to boot when the drive is configured as either a primary or secondary drive. Common values for drive_number are 80 for the first hard drive, and 81 for the second one.
If you don't specify this option or any of the other override options (-F, -H), a heuristic based on disk size and removability determines whether the drive is for a fixed or removable disk. The order of precedence used to determine the drive number to be patched into the loader code is:
  1. -d
  2. -F
  3. -H
  4. heuristic
-F
Use the removable-disk loader (originally for floppies, hence the “F”).
-H
Use the hard-disk loader.
-v
Be verbose.
device
The name of the disk partition mountpoint, or the raw device name if no partition table is required.
loader
The full path of the loader. You must specify a loader for each device argument.

Description:

The dloader utility writes boot loaders to disks on x86 systems. We provide loaders in $QNX_TARGET/x86_64/boot/sys on a development host, but you can provide your own custom loaders. In either case, you need to include the loaders in your OS image.

You must specify at least one device and loader. Specifying multiple pairs lets you write stage 1 and stage 2 loaders to disk using a single dloader invocation.

Currently, the QNX Neutrino RTOS supports the following forms for loader names:
prefixpc1*
This is the standard first-stage (partition) loader on a PC. This loader has to fit in less than one block (block 0—the first block—of the physical disk); the BIOS itself will have jumped to this block content when the hardware board was first powered on. The first-stage loader's job is basic; it just identifies a bootable OS partition, reads one block from the start of that partition into memory, then jumps into (begins executing) it. The BIOS expects to find this boot loader on the first system disk. The fdisk utility can also write this loader.
prefixpc2*
This is the standard second-stage (OS-specific) loader on a PC. This loader's job is more complicated because it needs to understand the particular filesystem format and boot the OS. For this reason, there are more variants for this loader type, often based on the filesystem. Depending on the variation, this loader can be a single or multiple blocks but its first block is always written to the first block of the OS partition.
The second-stage bootloader is always written to the first few sectors of the filesystem (normally the start of the partition). Filesystems each reserve space for the loader.

More details about these two loader types and what exactly they do during system startup are given in the x86 disk boot IPLs section of Building Embedded Systems. Because the two loaders get written to different physical locations, you have to be careful to match the drive name given in the device option (e.g., /dev/hd0 or /dev/hd0t179) with the loader code that you are writing to that device.

The device names for our shipped loaders are prefixed with ipl-disk. On a development host, $QNX_TARGET/x86_64/boot/sys includes at least the following loaders:
  • ipl-diskpc1
  • ipl-diskpc1-nomsg
  • ipl-diskpc2-fsq6 — for use with the Power-Safe (fs-qnx6.so) filesystem. You can't write this file with dloader; you must use mkqnx6fs with the -B option (which puts it in place by default).

If you wish to write and use your own loaders, you must include this ipl-disk naming prefix but you can provide your own unique variant names. You have to specify the exact path, including the prefix.

Assuming you specified a device and loader correctly, dloader opens the device in the specified path and, if you selected the verbose option, displays the device's disk and partition information. The specified loader data are then put together and written to the disk.

Note: The removable disk (-F) option forces dloader to treat a fixed device (e.g., a hard disk) as if it were a removable device, and the hard disk (-H) option does the opposite.

Examples:

Write a PC partition loader to a hard disk:
dloader /dev/hd0 /home/joe/ipl-diskpc1
Write a custom partition loader to the second hard disk:
dloader -d 81 /dev/hd1 /home/joe/ipl-diskpc1-tst
Write a QNX loader to a “removable” disk:
dloader -F /dev/dsk1 /home/joe/ipl-diskpc1

Exit status:

0
The loader was written to the disk.
Any other value
An error occurred. In these cases, dloader sends a description of the error to stderr.