First, I am not good at bash scripting. I have managed to scratch a personal itch using the ideas outlined in this post. I am posting this as it may help someone resolve their own problems, but there is no guarantee that this will work on your set-up. You have been warned. Infinitely brighter minds than mine have had a go at this problem and not resolved it. Let that fact be your guiding light. Again, I am not good at scripting ,and for all I know, my additions are utterly horrible. You may find your system unbootable if you simply try my ideas without understanding and making your own decisions.

I prefer to run the jfs filesystem on my Raspberry Pis that use USB disks rather than the SD card for data or the main file system. The problem with choosing anything other than ext4 or nfs is that nothing else is supported by the standard kernel and boot arrangement of any of the Raspberry Pis. So if you want to experiment with ZFS, or learn more about BTRFS, or, as in my case, be ultra cautious about the data on my disks, and so choose the one filesystem with which I have never lost data, you need to create an initrd file or initram file.

The problem with using an initramfs on Raspbian/Raspberry Pi OS is that the /boot directory, on which the initramfs should reside, is formatted as VFAT.  The initramfs file MUST be generated for the specific kernel version you are running, and on other systems, this is usually done by automatic generation of the initramfs, then symlinking the correct one under /boot.  Symlinking is not possible under VFAT.

I'll not go into the creation of an initrd are it is well covered elsewhere.  I will also not go in to the full details of how the initramfs works, as if you need it, you will no doubt know all about it. Suffice to say that, in my case, the following is necessary:

  • Install initramfs-tools package (should already be there)
  • Add "jfs" to /etc/initramfs-tools/modules
  • Add a script that includes jfs fsck binary files to /etc/initramfs-tools/hooks (example below)
  • Edit /etc/default/raspberrypi-kernel to say "INITRD=YES"
  • Add "initramfs initramfs.gz followkernel" to /boot/config.txt (or whatever you wish to call your initramfs)
  • Generate the initramfs in the standard way.
The script to add the correct hooks, in my case and for jfs, looks like this, and must be chmod'ed executable:
. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions

copy_exec /sbin/fsck.jfs /sbin
copy_exec /sbin/jfs_debugfs /sbin
copy_exec /sbin/jfs_fsck /sbin
copy_exec /sbin/jfs_fscklog /sbin
copy_exec /sbin/jfs_logdump /sbin
copy_exec /sbin/jfs_mkfs /sbin
copy_exec /sbin/jfs_tune /sbin
The trouble comes when a new kernel comes along.  The initramfs-tools will merrily create a series of initrd-* files suitable for all the Raspberry Pi architectures. But because of that symlink problem, it is then necessary to make sure you manually copy the correct version to /boot/initramfs.gz (if using the example above) or altering the /boot/config.txt file with the initram of choice.
There have been attempts to automate this but they have never worked satisfactorily for me, and from time to time, I have found myself with an unbootable Pi. These attempts usually take tje form of an additional script in the /etc/kernel/postinst.d directory, which are executed after the new kernel is installed. One option by-passed the standard initramfs-tools utilities and hard-created a /boot/initramfs.gz file, but I found this rather hit and miss. Another option tries to modify the /boot/config.txt file, but that seems risky to me, as it could do other damage to the file as well as edit out and replace the entries you need.
So I have been working on some additions to the standard script in /etc/kernel/postinst.d/initramfs-tools script. This script is called several times when installing a new kernel (or re-installing an existing one).  On each occasion it is called, the kernel version for which it needs to create an initramfs file is given as an argument.  These additions "simply" identify the currently running Raspbian/Raspberry Pi OS architecture after the creation of the initrd<KERNEL_VERSION-<ARCHITECTURE> file, then copies the existing initramfs.gz file, then copies the correct (hopefully) file to /boot/initramfs.gz. It provides some feedback so that you know what it has done and allows you to inspect the results. It keeps all the original files intact. The script addition also provides feedback for architectures that do not apply, to be sure, to be sure.
If you can improve on this, and I am sure that would be trivial, do drop me an email. Similarly, if you can see glaring use-cases where this will fail, let me know.

My additions are to  the /etc/kernel/initramfs-tools script and come after the last line, which should be:

INITRAMFS_TOOLS_KERNEL_HOOK=1 update-initramfs -c -k "${version}" ${bootopt} >&2

Add the following:
########### Stevan Hack to install create initramfs version ###################
echo " "
echo "======================================================================="
echo "Selecting /boot/initramfs.gz for appropriate Pi architecture"

CURRENT_KERNEL_TYPE=`uname -r |perl -pe 's/\d+\.\d+\.\d+//'` WORKINGON=`echo ${version}| perl -pe 's/\d+\.\d+\.\d+//'` CHOSEN_INITRD=`ls -C1 /boot | grep $CURRENT_KERNEL_TYPE`
if [ "$WORKINGON" == "$CURRENT_KERNEL_TYPE" ]; then     echo "uname architecture is " `uname -m`     echo "Currently processing "$CHOSEN_INITRD     echo "Selected initrd to copy as initramfs.gz is" $CHOSEN_INITRD #    echo ""     echo "First moving current initramsfs to safety"     cp -v /boot/initramfs.gz /boot/initramfs.gz-`date +"%d%m%Y_%H%M"`     echo "Now creating correct initramfs.gz....."     cp -v /boot/$CHOSEN_INITRD /boot/initramfs.gz     echo "Compare. File size should be indentical...."     ls -al /boot/$CHOSEN_INITRD /boot/initramfs.gz     echo " " else     echo "      NOTE: This is not the correct initramsfs for this Pi architecture "${version}     echo "      initramfs.gz not copied for this version"     fi     echo "initramfstools completed for kernel version "$CHOSEN_INITRD echo "=======================================================================" echo "" ########## end of Stevan Hack ###########################