1

Android uses ext4 file system for read-only partitions, but in my opinion for flash read-only drives ext2 is more appropriate, because it does not have performance overhead and safe for using without write operation.

Am I right?

Onik
  • 19,396
  • 14
  • 68
  • 91
Gluttton
  • 5,739
  • 3
  • 31
  • 58

2 Answers2

2

I don't have the true answer, but here are some possibilities.

ext4 has improvements over ext2 even in read-only mode, such as using extents rather than block maps. This saves on metadata overhead.

The system partition can be remounted read-write on rooted devices, and during system updates (except on Nougat+ devices using two system partitions for seamless updates). ext4 generally has better allocation behavior than ext2.

The filesystems may be created with -O ^has_journal, which removes the overhead of journaling from ext4. (See the -j option to mkuserimg_mke2fs.sh.)

Also, given that ext4 is already in use for the read-write user partition, I suspect there would be a tendency to avoid ext2 just to reduce the total amount of different code that is being run (and needs to be tested). Some ports unset CONFIG_EXT2_FS to shrink the kernel. (ext2 filesystems can still be mounted using the ext4 driver, although I don't expect this to be done.)

Onik
  • 19,396
  • 14
  • 68
  • 91
ephemient
  • 198,619
  • 38
  • 280
  • 391
1

Why does Android use ext4 file system for read-only partitions?

Not really an expert here and probably won't give a specific answer but, as you surely know, Android heavily leans on Linux and the choice might have been Linux-dictated.

The great work by Jonathan Levin which has lately become free and which I strongly recommend you to get familiar with states the following*:

"Android enforces no constraints as to the filesystem types, but eMMC and MMC devices presently use the Linux Ext4 filesystem (as of Gingerbread, in place of the older YAFFS system), since the storage layer exports a block device. Ext4 has become the default filesystem in Linux as of 2.6.27, and is a well tested filesystem, albeit not a necessarily flash-optimized one."


* Chapter II -> Partitioning Scheme -> File Systems

Also ext4 without using journal has better performance then ext2:

                    ext2      ext4, default  ext4, no journal  
initial writes    13.0 MB/s     15.4 MB/s      15.7 MB/s  
rewrites          13.1 MB/s     15.6 MB/s      15.9 MB/s  
reads             15.2 MB/s     16.9 MB/s      17.2 MB/s  
re-reads          15.3 MB/s     16.9 MB/s      17.2 MB/s  
re-reads          15.3 MB/s     16.9 MB/s      17.2 MB/s
Gluttton
  • 5,739
  • 3
  • 31
  • 58
Onik
  • 19,396
  • 14
  • 68
  • 91