3

I read somewhere that an operating system which knows nothing about ext3 and ext4 (i.e. antique Linux version) is able to read/write to ext4, and it detects any ext4 file system as ext2.
I am not quite sure, whether the same is possible to Tux2 to tux3 or with FAT12. (FAT64 is exFAT)

How exactly is that possible?
How exactly can ext4 be treated like ext2? Is there no risk for file or metadata corruption?

  • 1
    The ext3/4 driver will regenerate the missing data when the filesystem is mounted. – Ignacio Vazquez-Abrams Mar 17 '18 at 11:31
  • 1
    It would mount ext4 with ext2 subsystem – Timothy Frew Mar 19 '18 at 21:13
  • Thanks. I just wondered how a clueless antique OS with only ext2 can make use of ext4. – neverMind9 Mar 20 '18 at 18:46
3

This depends heavily on how the ext4 filesystem was formatted. Some newer ext4 features (e.g. extents or 64bit) cannot be understood by older ext2 drivers, and the kernel would refuse to mount the filesystem (see, for example this post). In general, any filesystem formatted with a modern mke2fs with the default -t ext4 options will not be mountable by an old ext2 driver, but if the filesystem was originally formatted a long time ago, then upgraded to ext4, it may still be mountable by ext2 if none of the newer ext4-specific features were enabled.

The ext2/3/4 filesystems track which features are in use by compat, rocompat, and incompat feature flags. These features are normally set at mke2fs time, but can sometimes be changed by tune2fs. If an unknown compat feature is found, the kernel will mount it, but e2fsck will refuse to check it because it might do something wrong. If an unknown rocompat feature is found, the kernel can mount the filesystem read-only, and any unknown incompat feature will prevent the filesystem from being mounted at all (a message will be printed to /var/log/messages in this case).

You can use debugfs -c -R features <device> to dump the features enabled on a filesystem, for example:

# debugfs -c -R features /dev/sdb1
debugfs 1.42.13.wc5 (15-Apr-2016)
/dev/sdb1: catastrophic mode - not reading inode or group bitmaps
Filesystem features: has_journal ext_attr resize_inode dir_index filetype
needs_recovery dirdata sparse_super large_file huge_file uninit_bg dir_nlink

Though this doesn't tell you which ones are compat, rocompat, or incompat. If your version of debugfs doesn't understand some newer feature, it will print it like I0400 or similar.

  • 1
    Yea, in general, older systems can read-only mount ext3 since it is safe to ignore the journal for read-only access, but not ext4, since several of the features that make it ext4 are incompat. – psusi Apr 6 '18 at 12:57

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.