3

I always thought "clean" is a synonym of does not need journal recovery.

However that does not seem to be the case

$ sudo file -s /dev/sdc4
/dev/sdc4: Linux rev 1.0 ext4 filesystem data, UUID=117ce600-a129-446b-8859-1e20ad8fe823, volume name "platform" (needs journal recovery) (extents) (large files) (huge files)
$ sudo fsck -n /dev/sdc4
fsck from util-linux 2.25.1
e2fsck 1.42.12 (29-Aug-2014)
Warning: skipping journal recovery because doing a read-only filesystem check.
platform: clean, 13031/186800 files, 129254/790272 blocks
$ sudo file -s /dev/sdc4
/dev/sdc4: Linux rev 1.0 ext4 filesystem data, UUID=117ce600-a129-446b-8859-1e20ad8fe823, volume name "platform" (needs journal recovery) (extents) (large files) (huge files)
$ sudo fsck -n /dev/sdc4
fsck from util-linux 2.25.1
e2fsck 1.42.12 (29-Aug-2014)
Warning: skipping journal recovery because doing a read-only filesystem check.
platform: clean, 13031/186800 files, 129254/790272 blocks

Both file and fsck agree that journal recovery is needed. Still fsck says the filesystem is clean. And the -n flag obviously did what I wanted, the filesystem remained unchanged, so the clean cannot refer to having successfully cleaned (applied the journal).

Edit: The filesystem is not mounted.

  • I suspect it means that the filesystem is in a consistent state, but an operation which occured close to shutdown was never applied (in any part, since partial application would result in an inconsistent state) to the filesystem proper. – Random832 Jun 1 '15 at 19:15
  • @don_crissti I have read that before posting, but I don't think it helps. It says that journal recovery is needed if the filesystem has not been unmounted cleanly. But my filesystem is reported to be clean. So combining both together it would mean that my filesystem has not been unmounted cleanly but it is clean. And there we are back at my original question. – Uwe Geuder Jun 1 '15 at 19:42
  • @don_crissti But my filesystem is not mounted, sorry forgot to mention that. – Uwe Geuder Jun 1 '15 at 19:46
  • Am I missing something, I am not good at spot the difference. You seem to have posted the same two commands/output twice. – ctrl-alt-delor Jun 1 '15 at 21:07
  • @richard: yes, by intention I wanted to show that fsck -n has not cleaned the filesystem. That part is expected, but after that it is reported as clean again. As explained in the answer and my further comment, the "clean" output by fsck cannot be relied upon. It says "clean" also for dirty filesystems. – Uwe Geuder Jun 2 '15 at 10:28
2

The filesystem was unmounted incorrectly.

The "clean" at the end of the output of "fsck -n" is misleading. It does not mean recovery is not needed. It just means that if you would have reached that point, without -n, the filesystem would have been clean.

How to reproduce:

sh-4.3# dd if=/dev/zero of=/tmp/test.fs bs=1M count=5
5+0 records in
5+0 records out
5242880 bytes (5.2 MB) copied, 0.00333063 s, 1.6 GB/s
sh-4.3# mkfs.ext4 /tmp/test.fs
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 5120 1k blocks and 1280 inodes

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
sh-4.3# mkdir /tmp/t
sh-4.3# mount -o loop /tmp/test.fs /tmp/t
sh-4.3# ls / > /tmp/t/file
sh-4.3# umount /tmp/test.fs 
sh-4.3# fsck -n /tmp/test.fs
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/tmp/test.fs: clean, 12/1280 files, 1224/5120 blocks
sh-4.3# mount -o loop /tmp/test.fs /tmp/t
sh-4.3# ls / > /tmp/file2
sh-4.3# cp /tmp/test.fs /tmp/test-unclean.fs
sh-4.3# fsck.ext4 -n /tmp/test-unclean.fs 
e2fsck 1.42.12 (29-Aug-2014)
Warning: skipping journal recovery because doing a read-only filesystem check.
/tmp/test-unclean.fs: clean, 12/1280 files, 1224/5120 blocks
sh-4.3# mkdir /tmp/t2
sh-4.3# mount -o loop /tmp/test-unclean.fs /tmp/t2
sh-4.3# dmesg | tail
...
[66569.074538] EXT4-fs (loop1): recovery complete
[66569.074554] EXT4-fs (loop1): mounted filesystem with ordered data mode. Opts: (null)
sh-4.3# umount /tmp/test-unclean.fs 
sh-4.3# fsck -n /tmp/test-unclean.fs 
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/tmp/test-unclean.fs: clean, 12/1280 files, 1224/5120 blocks
  • So what does the clean stand for? Can it sometimes read "not clean" or unclean? – Uwe Geuder Jun 1 '15 at 19:49
  • I guess fsck has just reached the end of its "routine" at which point the filesystem should be clean (apart from the fact that you've specified the -n option) – Zabuzzman Jun 1 '15 at 19:51
  • 1
    I checked the source. The "clean" is hard-coded, it cannot read dirty or anything else. So indeed a misleading output. The comment says /* Print the summary message when we're skipping a full check */ If the comment is correct (I did not check) in my case the message was printed because I had the -n flag. In reality the fs was and is not clean. The same message is printed if the journal is applied, but no full check is done. In that case the fs was dirty but is clean now. Same message. – Uwe Geuder Jun 1 '15 at 20:10
  • I'm not clear what your answer is doing. If you are trying to create a filesystem that requires recovery, where are you doing that? Some commenting would be helpful. – Faheem Mitha Jun 2 '15 at 1:02
  • # cp /tmp/test.fs /tmp/test-unclean.fs (here I copy the mounted file - as filesystem - test.fs, hence creating the unclean filesystem test-unclean.fs). Try to reproduce the commands, they're harmless – Zabuzzman Jun 6 '15 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.