ext4: 클린 파일 시스템에는 로그 복구가 필요합니까?

ext4: 클린 파일 시스템에는 로그 복구가 필요합니까?

나는 항상 "클린"을 로그 복구가 필요하지 않은 것과 동의어로 생각했습니다.

그러나 이것은 사실이 아닌 것 같습니다.

$ 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

file과 fsck 모두 로그 복구가 필요하다는 데 동의합니다. fsck는 여전히 파일 시스템이 깨끗하다고 ​​말합니다. -n 플래그는 분명히 내가 원하는 작업을 수행하며 파일 시스템은 변경되지 않은 상태로 유지되므로 clean은 성공적인 정리(응용 프로그램 로그)를 참조할 수 없습니다.

편집: 파일 시스템이 마운트되지 않았습니다.

답변1

파일 시스템이 제대로 마운트 해제되지 않았습니다.

"fsck -n" 출력 끝에 있는 "clean"은 오해의 소지가 있습니다. 이는 복구가 필요하지 않다는 의미는 아닙니다. 이는 -n 없이 이 지점에 도달하면 파일 시스템이 깨끗해짐을 의미합니다.

재현 방법:

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

관련 정보