run QNX from an Image

i made an image using the following commands

mkifs myImage.ifs
dinit -f myImage.ifs /dev/hd1

NB [hd1 points to the CF disk, hd0 is the harddrive]

Now when i try to run it from the CFDisk it gives me the following message
Hit Esc for .altbootD

However, if i move the image to a floppy disk it seems to load up
dinit -f myImage.ifs /dev/fd0

i would appreciate speedy responses

The device /dev/hd1 is the drive itself, but you need to load the .ifs file onto a partition (which doesn’t exist on the FDD so works then). Try using fdisk to create a partition (say type 79) on the CF card then running

dinit -f myImage.ifs /dev/hd1t79

I had this error two or three weeks ago. the D stands for Disk Read/Write Error


ok … and what do I have to do, when I want to install the qnx os image on a loop device/a disk image file.
The dinit-utility apparently does not work with loop-devices, how can I specify the partition within a disk image file?
I want to boot qnx with bochs on my linux host.

Any help is appreciated!

Ciao, Fabian

Two comments:

  1. be careful: running the qnx dinit from within a linux session might produce weird results

  2. the dinit utility generates a compressed image which is loaded into ram at startup (while the dots are scrolling across the screen) and ends up as a read-only file system. You probably want to have two partitions, one to boot from and the other to mount with the majority of the system on it. We have had trouble with large image files under SP2 on CF cards, but this seems to be fixed by putting only the minimum stuff onto the image in /proc/boot and then everything else onto a secondary partition mounted later and with symlinks like /bin → /bin in the image.

hmmm … how can we do that for a compact flash … i.e. have two partions in the flash; where one partion has the image while the other pasrtion has the other goodies.

It is actually pretty easy. Start by building an image with just sufficient stuff in it to get to the point of mounting the CF card into the filesystem:

/proc/boot you will need (at least):, devb-eide, devc-con,,,,,,, sh, waitfor (and if you need to use a PCI interface) pci-bios, seedres

If you do not use the “autolink” option add symbolic links from → /proc/boot/, → and → to /proc/boot

You will also need all the contents of /usr/lib which are required in the final image (procnto or something else running the bsh script seems to have hardcoded the lib /usr/lib/ into that location and it is needed for the runtime linking of dlls… ie. for everything. Include at least: (symlink to /proc/boot/, (symlink to /usr/lib/ and Also add the necessary contents of /usr/lib/terminfo (including subdirs) if you want the terminals to work properly (ie. if you only wish to use vt100 terminal include /usr/lib/terminfo/terminfo.src and /usr/lib/terminfo/v/vt100).

In your boot script also add the following sym links to /
/bin → //bin
/sbin → //sbin
/etc → //etc
/lib → //lib
/opt → //opt (for ssh services etc.)
/tmp → //tmp

and in /usr
/usr/bin → //usr/bin
/usr/sbin → //usr/sbin

where is the mountpoint of the cf card partition which you load in the bsh script using a command like:
devb-eide blk automount=hd0t77:/cf &

if the secondary partition was created as a type 77 partition and is to be mounted at /cf in the filesystem. WIth an appropriate boot script (see attached file for a snippet of one of my bsh scripts) you can then load the filesystem during bootup and set the system environment variables to point to the mounted systems. NOTE: the procnto PATH and LD_LIBRARY_PATH variables should both be set to /proc/boot (you might add the `normal’ path too if you desire running everything from the bsh file) and /proc/boot can be left out of the system paths. We try to run as much of the initialisation from shell scripts residing in /etc so that we can reconfigure the image wihtout having to rebuild it (eg. changing IP address, etc.)

Now for the fun parts - on a QNX host machine:
load the cf card with a command like:

devb-eide eide ioport=0x300,irq=3,noslave

(if you have a PCMCIA adapter and the irq and ioport come from the info provided by the pin utility)

Initialise the disk using

fdisk /dev/hd

IMPORTANT: MAKE SURE YOU SPECIFY THE CORRECT DRIVE NUMBER HERE (yes, we had someone delete another person’s partition table by getting this wrong… took a few hours to rebuild it from scratch, but he got his mostly-written thesis back eventually)

We use a small (ie. smallest possible) type 79 partition for the boot image and the rest of the card as type 77 for the mounted filesystem. Make the first one (t79) bootable.

Slay and restart the devb-eide manager (for that card only, ie. don’t kill the low pid instance as that is busy managing your HDD). If unsure about this, reboot the machine.

Initialise the two partitions (here assume CF card is hd1)

dinit -h /dev/hd1t77

  • Initialises (~formats) the secondary partition specifying that it is a HDD

dinit -h -f /dev/hd1t79

  • Initialise the image partition and loads the image onto it.

Mount the secondary partition

mount /dev/hd1t77

Copy all the things you want from /bin, /sbin, /lib, /usr/bin, /usr/sbin, /opt, /etc and anything else you so desire. Don’t forget to create the empty directory /tmp so that the link in the image points to something valid (or programs like vi will complain) into the appropriate locations on the card.

Boot the target machine and fix the bugs associated with getting the right drivers etc. running for your hardware. Once that is done, things should be hunky-dory.

I use a 3G harddisk as my target
fdisk /dev/hd0 add -c 0,30 t 79
fdisk /dev/hd0 add -c 31,100 t 78
so there are two partitions on hd0
My host system is on hd1.
I used dinit to init my partition /dev/hd0t79,the command is
dinit -f embd.ifs -h /dev/hd0t79
but I cannot boot from this partition.

when there no partition on hd0,and i use this command
dinit -f embd.ifs -h /dev/hd0 -v
it told me this is a ‘raw’ disk and i choose to continue
now i can boot from this disk

what’s wrong with it?

thank you very much

My platform is x86,intel 1.7G,PC.
I have build an .ifs file successfully with embeded photon.
So as you can see , the .ifs file is very large and now all i wanna do is to make it small and boot faster.
I really apreciate it if anybody can figure out what’s wrong with the partition or the command.

Is it necessary that i set the bootable image as activated?
Then how to set that if it is ?

thank you


If I do
dinit -f my.ifs /dev/fd0
and then reboot the computer I am able to sucessfully boot from the floppy.

If I do
dinit -f my.ifs /dev/hd1t79
and then reboot the computer I am not able to boot :frowning:

Do I need to cofigure the CF Disk in some way ? If so how could I do that ?


harddrive: 5GB
CF: 128MB
Floppy: 1.4MB

/dev/hd0 my harddrive
/dev/hd0t79 my harddrive
/dev/hd1 my CF Disk
/dev/hd1t79 my CF Disk
/dev/fd0 my floppy disk

Make sure that the partition you wish to boot from is marked bootable by fdisk when you create the partitions. That partition should also be the first (or only) bootable partition on the disk. You have the disk itself (but not the partition) workign OK when the startup says:

Hit Esc for .altboot…D

The D indicates that there is a disk error but the stuff leading up to that indicates that the stage 1 boot loader is running properly on the disk. The Stage 2 bootloader is placed on the partition itself when you dinit it. If you cannot get the primary loader to start, you may need to use dloader to initialise the disk (/dev/hd0) before applying dinit to the partition /dev/hd0t79 (say).

Now its worked.
The problem is that I didn’t use the dloader. Since I have used dloader, the partition is bootable now.

Thank you very much , Wretched

hello … im not too aware with the “dloader” command.
is this what I am suposed to do -

dloader /dev/hd1 pc1
dloader /dev/hd1t79 pc2
dinit -f my.ifs /dev/hd1t79

I would really appreciate a step by step approach as I am new to this.


The QNX disk loader operates in two stages:
Stage 1 - Resides in the MBR and enables the disk (as a whole) to be booted from.
Stage 2 - Resides on the bootable partition of that disk and enables that partition to load

The dloader command is used to add the first stage:

dloader /dev/hd1 pc1

  • This command tells the computer to use the pc1 (pc first stage) loader on the MBR of /dev/hd0

There is no need to use the dloader command on the partition, as dinit does that for you.

The dinit prepares a drive for booting and/or copies an ifs image to it.

dinit -h -f my.ifs /dev/hd1t79

Tells the computer to initialise the partition /dev/hd1t79 with the image my.ifs. the -h option tells dinit that the partition is a HDD.

In addition to these commands you need to make sure that fdisk marks the bootable partition when you create it.

There is no need to use the dloader on the hard disk, as fdisk does that for you :slight_smile:
Actually, dloader is very useful utility which works with primary and secondary loaders. But in this discussion guys were missing -h option for dinit, I think.

THANKS “-h option” was the thing :slight_smile:

Now another question … as soon as the QNX gets booted from the CF DIsk … i want it to automatically run a program writteb in C/C++ called my.o [from my.cpp]

How would i go about doing that.