Check if fsck will be necessary

23 views
Skip to first unread message

Andrew Chambers

unread,
Jul 10, 2018, 12:57:43 AM7/10/18
to s3ql

The problem I am trying to solve is to automatically fsck from a systemd unit if it would be needed to minimize human interaction.

Is this a simple and reliable way to test from a shell script before I mount whether or not an fsck will be necessary? I can see the .params file has 'needs_fsck', though I don't know if this is reliable.


Thanks for any help, and thanks for this software.

Andrew Chambers

unread,
Jul 10, 2018, 1:07:13 AM7/10/18
to s3ql
To clarify even further, I tried an unconditional fsck and am hitting this assertion:

assert not os.path.exists(cachepath + '-cache') or param['needs_fsck']

at line 1227 of fsck.py

I think the reason might be running fsck before a successful mount has ever happened.

Nikolaus Rath

unread,
Jul 10, 2018, 3:43:09 AM7/10/18
to s3...@googlegroups.com
On Jul 09 2018, Andrew Chambers <andrewc...@gmail.com> wrote:
> The problem I am trying to solve is to automatically fsck from a systemd
> unit if it would be needed to minimize human interaction.
>
> Is this a simple and reliable way to test from a shell script before I
> mount whether or not an fsck will be necessary?

Just run fsck.s3ql unconditionally. If no fsck is necessary, it will
exit without doing anything.

Best,
-Nikolaus

--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

»Time flies like an arrow, fruit flies like a Banana.«

Nikolaus Rath

unread,
Jul 10, 2018, 3:44:30 AM7/10/18
to s3...@googlegroups.com
On Jul 09 2018, Andrew Chambers <andrewc...@gmail.com> wrote:
Please provide more details. For me it seems to work just fine:

$ mkfs.s3ql --plain --quiet local://bucket

[0] nikratio@vostro:~/tmp
$ fsck.s3ql local://bucket
Starting fsck of local:///home/nikratio/tmp/bucket/
Using cached metadata.
File system is marked as clean. Use --force to force checking.

[0] nikratio@vostro:~/tmp
$ fsck.s3ql --version
S3QL 2.28

Daniel Jagszent

unread,
Jul 10, 2018, 8:45:02 AM7/10/18
to s3ql

Hi Andrew,



The problem I am trying to solve is to automatically fsck from a systemd unit if it would be needed to minimize human interaction.

Is this a simple and reliable way to test from a shell script before I mount whether or not an fsck will be necessary? I can see the .params file has 'needs_fsck', though I don't know if this is reliable.

I use this shell script as a ExecStartPre script:

#!/bin/bash

MOUNTPOINT="/mount/point"
STORAGE_URI="local://bucket"

# Check for a crashed S3QL
if ls "$MOUNTPOINT" 2>&1 | grep -Fq 'Transport endpoint is not connected'; then
  fusermount -u "$MOUNTPOINT"
fi

# Check and mount file system
/usr/bin/fsck.s3ql --batch "$STORAGE_URI"
FSCK_RESULT=$?
if [[ $FSCK_RESULT != 0 && $FSCK_RESULT != 128 ]]; then
  echo "fsck.s3ql reported errors! exit code $FSCK_RESULT"
  exit $FSCK_RESULT
fi
exit 0




Andrew Chambers

unread,
Jul 10, 2018, 6:05:14 PM7/10/18
to s3ql

Please provide more details. For me it seems to work just fine:

Hi Nikolaus,

The problem happened with the google storage backend with my patched changes (the ones with a pull request open) version 2.28.

I have a feeling it was caused by systemd timing out while an authentication error happened. I will let you know if I can reproduce it, but for now it seems to be my fault, rare and recoverable nonetheless.

Thank you for taking the time to test it out, even if it may have been my fault.

@Daniel Jagszent

Thanks for sharing your script, it is similar to what I came up with but has some useful ideas I did not.

Regards,
Andrew Chambers
Reply all
Reply to author
Forward
0 new messages