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.
#!/bin/bash
. /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
My additions are to the /etc/kernel/initramfs-tools script and come after the last line, which should be:
Add the following:INITRAMFS_TOOLS_KERNEL_HOOK=1 update-initramfs -c -k "${version}" ${bootopt} >&2
########### 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 ###########################