Is there any Flag or some byte in SuperBlock from which I can distinguish if it is an ext4 or ext3 File System? I have already googled it and found some internal structures of ext3 & ext4, but can't find my answer.
First, let's create two small disk image files
my-ext4 and format them in
ext4 respectively, so that we can test and see the differences:
truncate -s 10M my-ext3 mkfs.ext3 my-ext3 truncate -s 10M my-ext4 mkfs.ext4 my-ext4
Now the easiest way to check what they are is the
$ file my-ext* my-ext3: Linux rev 1.0 ext3 filesystem data, UUID=7ba99eb3-57c0-4d81-a2e7-529fdee64cbb (large files) my-ext4: Linux rev 1.0 ext4 filesystem data, UUID=2308e0f8-443e-4164-b5ee-4810e9def008 (extents) (large files) (huge files)
As you can see, it correctly identifies each file system type. You can also examine the file systems with
fsck, by mounting them or using some partitioning tools.
However, as @Rinzwind pointed out in his comment, all
ext4 file systems are basically the same, except that the higher revisions support more file system features. Those do not directly tell you whether it is
ext4, but you can check since which file system version each feature is available. If you find any
ext4-only features, it must be
ext4. Let's have a look at them.
The command to examine the file system is
dumpe2fs. We are only interested in the superblock data, so we add the
-h option, otherwise it will flood the console with tons of inode information as well. For us, only their "Filesystem features" are interesting, so let's use
grep to filter that out:
$ dumpe2fs -h my-ext3 |& grep "^Filesystem features:" Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file $ dumpe2fs -h my-ext4 |& grep "^Filesystem features:" Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Now we have two lists of file system features and can check each of them to find out which is the lowest
ext? file system revision that supports each feature. We can have a look at
man ext4 for that, it contains a list with all
ext4 file system features, their description and since when they are supported.
I made a little list for you and ordered the features by the first
ext? revision that supports them. All features from older revisions are supported in newer revisions as well:
There are more features described in
man ext4, but without information about which file system revisions support them:
Probably they are all present since
ext2, but I'm not 100% sure. Please leave a comment if you know more about hem.