RPI2: Force fsck on boot on usb stick

  • Hi there,

    I took my "Storage" partition on a usb stick ( /dev/sda1)

    Via tune2fs I set the next fsck to 1 day after the last one. When time passed, I did a reboot. In my understanding my partition should have been checked before mounting it to /storage, but that did not happen.

    Why didn't the fsck run before mounting my storage partition?
    How to force fsck to run on each boot for example?

    Any other possibility to run a fsck on my partition? Obviously I cannot do it while mounted and cannot unmount it either because its busy.

    Many thanks,

    Marcus

  • As LE is a R/O system, any command you issue is unlikely to remain after a reboot (I'm surprised that you didn't see an error message) - so that might explain why it didn't work as expected.

    Any reason you believe it didn't work?

    However, AFAIK, LE does do a fsck before mounting, so maybe it's related to the USB. I assume it's formatted as ext4?

    How did you move /storage to the USB device so that RPi mounts it?

  • I assume it's formatted as ext4?

    How did you move /storage to the USB device so that RPi mounts it?

    Yes, it is ext4

    I edited "cmdline.txt" and inserted: "disk=LABEL=Storage" , where my usb stick partition is labeled "Storage"


    When I do a: #tune2fs -l /dev/sda1

    It gives me that:

    Code
    Mount count: 3
    Maximum mount count: 1
    Last checked: Sun Aug 19 18:54:37 2018
    Check interval: 86400 (1 day)
    Next check after: Mon Aug 20 18:54:37 2018

    I did a reboot after Aug 20, but the "last checked" value did not change


    I think fsck is run on every boot before mounting. But if filesystem is marked clean nothing is checked.

    Well even if the fs is marked as clean, in my linux understanding the fs should be checked if I run a fsck on it, or am I wrong?


    Also, in dmesg output I see:

    Code
    EXT4-fs (sda1): warning: maximal mount count reached, running e2fsck is recommended

    For me that means, that fsck did not run at boot, nor even tried to run

  • If you labelled your USB stick 'Storage' did you also change the label for the SD card second partition? (which by default is also Storage). If you end up with 2x 'Storage' I'd guess the SD card will be probed for and mounted first.

    Of course I did this

    Everything is working fine anyways. It's just that I want to check my fs on the usb stick on each boot, as I had some issues in the past which ended up with a read-only usb stick

  • Quote

    Of course I did this

    For someone asking for advise, you're sailing close to the wind.

    --------------------------------------------------------------------------------

    After a bit of playing around, I think everything is working as intended.

    By default (for whatever reason) the fsck at boot is disabled max_mount_count=-1. By changing this (in your case to 1) it means that a fsck will be run after every boot.

    However, and this is where the confusion lays. The fsck is being run but only fsck (Check) not fsck -a (Check and repair) - this is why the e2fsck message is being shown. It's telling YOU to run the command for the reason given.

  • For someone asking for advise, you're sailing close to the wind.

    --------------------------------------------------------------------------------

    Sorry if this came out wrong..

    ---------------------------------------------------------------

    However, and this is where the confusion lays. The fsck is being run but only fsck (Check) not fsck -a (Check and repair) - this is why the e2fsck message is being shown. It's telling YOU to run the command for the reason given.

    Well, I cannot run the command as my partition is mounted and I cannot unmount it, as its used by kodi and probably some other stuff.

    Thats why I wanted it to be checked (and repaired if neccassary) every boot.

    So thats not working by design then?

  • I corrupted Storage partition deliberately when system was running and on next boot I got this message

    meaning partition is checked on boot by default.

    Filesystem was checked and fixed after that and it was in working state after next reboot.

  • I corrupted Storage partition deliberately when system was running and on next boot I got this message

    meaning partition is checked on boot by default.

    Filesystem was checked and fixed after that and it was in working state after next reboot.

    Thanks for your testing

    Does your Storage Partition reside on a usb drive or on sd card?

    I am just curious if maybe the behaviour is different between sd card and usb drive