How do I run btrfs check on i) the root FS, ii) USB-attached NAS/srv disk on boot? What I get is it has to be run before mounting the disks, so I tried adding the check commands to various places in /lib/preinit (definitely before
80_mount_root). I store the script’s output to /tmp to be able to see what was going on, but it seems it never actually runs successfully.
The script I’m running:
btrfs check --repair /dev/mmcblk0p1 2>&1 1>/tmp/fsck.root echo $? >>/tmp/fsck.root if [[ ! -f /dev/sda1 ]]; then sleep 5; fi btrfs check --repair /dev/sda1 2>&1 1>/tmp/fsck.nas echo $? >>/tmp/fsck.nas
The content of both files is just this:
enabling repair mode Opening filesystem to check... 1