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): cam-disk.so, devb-eide, devc-con, fs-dos.so, fs-qnx4.so, io-blk.so, libc.so.2, libcam.so.2, libcpp.so.2, 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 libc.so → /proc/boot/libc.so.2, libcam.so → libcam.so.2 and libcpp.so → libcpp.so.2 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/ldqnx.so.2 into that location and it is needed for the runtime linking of dlls… ie. for everything. Include at least: ldqnx.so.2 (symlink to /proc/boot/libc.so.2), libz.so (symlink to /usr/lib/libz.so.2) and libz.so.2. 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.