Update initramfs to respect the rootflags option and prevent fsck for non-ext based filesystem

Fairly old thread, but I think I found a way to implement the feature. My objective was to enable native btrfs support, but I think I also achieved the objectives of the OP.

The good thing is that the current kernel already supports btrfs, so we don’t need to tinker with the kernel. Also, from what I understand, chck.btrfs is very different from chck.extN and it is very dangerous to try and fix a btrfs, it is better if no checks are run at all, therefore no need to add btrfs-progs in the initramfs (although of course it can be done). End result: all that is needed are a couple of mods in the init file.

So all I did was:

  • ensure that if rootfs is btrfs then fsck is disabled, even if force-check is enabled
  • read mount options from rootflags

That’s all. And it works (tested on RPi2 with rootfs on a btrfs subvolume). I think the mods are so small and unrelated to ext4 installations, that it is safe to implement.

The additions to the init file are as follows (init taken straight from git):

sim909@playpi:~> diff init.original init.patched
90a91,94
>               if [ "$OPTION_FILESYSTEM" =  "btrfs" ] ; then OPTION_DO_FSCK="0" ; fi
>               ;;
>         rootflags=*)
>               OPTION_MOUNT_OPTIONS=",${option#*=}${OPTION_MOUNT_OPTIONS}"
108a113
>               if [ "$OPTION_FILESYSTEM" = "btrfs" ] ; then OPTION_FORCE_FSCK="0" ; fi

I’d really appreciate it if the osmc developers would implement this solution… btrfs support could still be classified as experimental, but I am sure it would appeal to many users.