I know, fsck.ext4 -p /dev/whatever, right? That seemed to be the answer, but then I read that journaling covers a multitude of sins, and the result from fsck will just tell you that there isn't a problem with that file system, but won't tell you that you did something dangerous, like shutdown/turning off the system with a file system mounted.

If a log could confirm it, that would be enough. I thought that might be found by looking in journalctl or grep'ing /var/log/*log, but I was expecting to see strings like "home" or "sda3" to confirm successful unmountings, but nothing came up to indicate that.

I'm running Ubuntu 22.04.3.

1 Answer 1


For extN filesystems you can check the superblock. For example,

tune2fs -fl /dev/sda1 | grep '^Filesystem features:'

In my case, a mounted filesystem includes the word needs_recovery whereas a cleanly unmounted filesystem does not.

if tune2fs -fl "$fs" | awk -F: 'BEGIN { ss=0 } $1 == "Filesystem features" && $2 ~ /needs_recovery/ { ss=1 } END { exit ss }'
    echo "$fs: seems ok"
    echo "$fs: needs recovery (fsck)"
  • What's -fl? My man pages doesn't recognize it.
    – Opux
    Commented Aug 27, 2023 at 20:45
  • @Opux it's two options crashed together. (This is a standard UNIX feature.) Look up -f and -l as separate items and you'll find their meanings (-f = force, -l = list). Try tune2fs -l /dev/sda1 or equivalent, i.e. without the -f, to see what happens when the filesystem is and is not mounted. Then repeat with the -f Commented Aug 27, 2023 at 21:43
  • Gotcha. I didn't realize l was a letter. So why the -f option? That means "force" according to the man pages. I'm used to using that word in connection w/write operations.
    – Opux
    Commented Sep 4, 2023 at 20:57
  • @Opux try it and you'll see why the -f is required. It surprised me too Commented Sep 4, 2023 at 21:19
  • I did. And now I've done it w/out the -f and I see no difference. I imagine the difference comes later
    – Opux
    Commented Sep 4, 2023 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .