View Issue Details

IDProjectCategoryView StatusLast Update
0000428fileGeneralpublic2023-03-11 17:48
Reporterlu3 Assigned Tochristos  
PrioritynormalSeveritytweakReproducibilityalways
Status assignedResolutionopen 
Product Version5.44 
Summary0000428: extended filesystem: ext2/3/4 (ext4 identified as ext2)
DescriptionIn short: file identifies ext4 file system as ext2.

Long story:
I have this ext4 file system that once was an ext2 file system. The kernel now only supports mounting it as ext4, since I added extra_isize (which is ext4-only). To create such a file system, use "mke2fs -t ext2", then use "tune2fs -O extra_isize" on the file system. The Linux kernel will then only mount it as ext4. (Like it will only mount an ext2 with added journal, e.g. tune2fs -O has_journal, as ext3 or ext4...)

Suggestion: Change "ext2" to either "extended filesystem" (or "extended file system", but the man pages write "filesystem" without space), which includes the original ext, ext2, ext3 and ext4. OR change the text to "ext2/3/4". OR include additional logic to distinguish ext2, ext3 and ext4 more reliably.

I did some testing and created ext2/ext3/ext4 file systems (as sparse files). The results are inconsistent. For example I created an ext4 file system, the default features are: "has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum". I then deactivated most, except extends and flex_bg everything I could bring back to ext2 standards, leaving "ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file uninit_bg". NOTE that this is now STILL an ext4 filesystem due to extends! file now identifies it as ext2...
Steps To Reproduce# dd if=/dev/zero of=sparse_file bs=1 count=0 seek=512M
0+0 records in
0+0 records out
0 bytes copied, 3.8972e-05 s, 0.0 kB/s

# mke2fs -t ext2 sparse_file
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 131072 4k blocks and 32768 inodes
Filesystem UUID: 60ab585c-0cc5-4e1c-b89d-98ee8eab6ef6
Superblock backups stored on blocks:
        32768, 98304

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

# tune2fs -O extra_isize sparse_file
tune2fs 1.46.5 (30-Dec-2021)

# dumpe2fs -h sparse_file | grep features
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem features: ext_attr resize_inode dir_index filetype sparse_super large_file extra_isize

# file sparse_file
sparse_file: Linux rev 1.0 ext2 filesystem data, UUID=60ab585c-0cc5-4e1c-b89d-98ee8eab6ef6 (large files)

# rm sparse_file


# dd if=/dev/zero of=sparse_file bs=1 count=0 seek=512M
0+0 records in
0+0 records out
0 bytes copied, 4.1416e-05 s, 0.0 kB/s

# mke2fs -t ext4 sparse_file
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 131072 4k blocks and 32768 inodes
Filesystem UUID: bf3337cb-bdd0-489c-a161-3d77450c4341
Superblock backups stored on blocks:
        32768, 98304

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

# dumpe2fs -h sparse_file | grep features
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Journal features: (none)

# tune2fs -O ^has_journal,^64bit,^huge_file,^dir_nlink,^extra_isize,^metadata_csum sparse_file
tune2fs 1.46.5 (30-Dec-2021)
Disabling checksums could take some time.
Proceed anyway (or wait 5 seconds to proceed) ? (y,N) y

Please run e2fsck -f on the filesystem.

After running e2fsck, please run `resize2fs -s sparse_file' to disable 64-bit mode.

# e2fsck -f sparse_file
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: +(98304--98368)
Fix<y>? yes to all
Free blocks count wrong for group 0000001 (36799, counted=32703).
Free blocks count wrong for group 0000002 (28672, counted=32768).

sparse_file: ***** FILE SYSTEM WAS MODIFIED *****
sparse_file: 11/32768 files (0.0% non-contiguous), 2257/131072 blocks

# resize2fs -s sparse_file
resize2fs 1.46.5 (30-Dec-2021)
Converting the filesystem to 32-bit.
The filesystem on sparse_file is now 131072 (4k) blocks long.

# dumpe2fs -h sparse_file | grep features
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file uninit_bg

# file sparse_file
sparse_file: Linux rev 1.0 ext2 filesystem data, UUID=bf3337cb-bdd0-489c-a161-3d77450c4341 (extents) (large files)

# rm sparse_file
Additional Information(My ext2+extra_isize=ext4 is on /dev/nvme0n1p5:)

# dumpe2fs -h /dev/nvme0n1p5 | grep features
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem features: ext_attr resize_inode dir_index filetype sparse_super large_file extra_isize

# mount -t ext2 /dev/nvme0n1p5 /boot
mount: /boot: wrong fs type, bad option, bad superblock on /dev/nvme0n1p5, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

# mount -t ext3 /dev/nvme0n1p5 /boot
mount: /boot: wrong fs type, bad option, bad superblock on /dev/nvme0n1p5, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

# dmesg -t | tail
EXT4-fs (nvme0n1p5): couldn't mount as ext2 due to feature incompatibilities
EXT4-fs (nvme0n1p5): couldn't mount as ext3 due to feature incompatibilities

# mount -t ext4 /dev/nvme0n1p5 /boot
# dmesg -t | tail
EXT4-fs (nvme0n1p5): mounted filesystem 01234567-89ab-cdef-fecd-ba9876543210 without journal. Quota mode: disabled.
ext4 filesystem being mounted at /boot supports timestamps until 2038 (0x7fffffff)

# file -s /dev/nvme0n1p5
/dev/nvme0n1p5: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=01234567-89ab-cdef-fecd-ba9876543210, volume name "Linux boot" (large files)
Tagsfile system

Activities

christos

2023-03-05 19:56

manager   ~0003905

The test for ext2 vs 3,4 is if it has a journal. I guess we should make it smarter. Do you know where the flags vs versions documentation lives?

lu3

2023-03-11 17:48

reporter   ~0003911

If not from the Linux kernel sources themselves, I guess maybe the Ext4 (and Ext2/Ext3) Wiki can be informative: https://ext4.wiki.kernel.org/index.php/Main_Page
Especially the https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout should describe what you need.

The man page also lists which features correspond with which extended filesystem version: https://www.man7.org/linux/man-pages/man5/ext4.5.html

I'm not sure what the real differences are, since the ext4 kernel driver can mount ext2/3/4 as well, hence my suggestion to simply call it all "extended filesystem". I guess a logic would simply have to check for the enabled features and decide whether it's an ext2, ext3 or ext4 based on them:
ext2 = filetype | sparse_super | large_file | ext_attr
ext3 = filetype | sparse_super | large_file | has_journal | ext_attr | dir_index | resize_inode
ext4 = (all the rest, currently:) filetype | sparse_super | large_file | has_journal | ext_attr | dir_index | resize_inode | 64bit | dir_nlink | extent | extra_isize | flex_bg | huge_file | meta_bg | uninit_bg | mmp | bigalloc | quota | inline_data | sparse_super2 | metadata_csum | encrypt | metadata_csum_seed | project | ea_inode | large_dir | casefold | verity | stable_inodes

This does, however, leave out the original extended filesystem ("ext1" if you will, or "ext").

Issue History

Date Modified Username Field Change
2023-02-24 15:56 lu3 New Issue
2023-02-24 15:56 lu3 Tag Attached: file system
2023-03-05 19:55 christos Assigned To => christos
2023-03-05 19:55 christos Status new => assigned
2023-03-05 19:56 christos Status assigned => feedback
2023-03-05 19:56 christos Note Added: 0003905
2023-03-11 17:48 lu3 Note Added: 0003911
2023-03-11 17:48 lu3 Status feedback => assigned