File systems

File systems (Updated on: 07/12/16)


What is a file system?


In computing, a file system is used to control how data is stored and retrieved. Without a file system, information placed in a storage area would be one large body of data with no way to tell where one piece of information stops and the next begins. By separating the data into individual pieces, and giving each piece a name, the information is easily separated and identified. Taking its name from the way paper-based information systems are named, each group of data is called a "file". The structure and logic rules used to manage the groups of information and their names is called a "file system".

So what are the available file systems?


- F2FS
- EXT4
- VFAT
- Fat32
- Exfat
- EXT3 (Uncommon)
- EXT2 (Uncommon)
- NTFS

There may be other file systems that I haven't mentioned, but these are the main ones. 


How to change your file system?


File systems are usually changed by formatting your phone's storage into a different format either via your PC or via custom recovery. Recoveries like TWRP don't allow to change file systems by default, whereas CWM recovery allows the user the chose the file system upfront without additional effort. Available file systems are determined by the kernel  developer. 

Descriptions:


F2FS

Recent mobile devices adopt various flash storages as a primary storage. File system support for those flash storages is a must for flash device performance and lifespan. Samsung developed a new file system called F2FS, designed for mobile flash storages. F2FS is designed considering the characteristics of the underlying flash storage which has flash translation layer (FTL). F2FS outperforms EXT4, which is a popular file system for Android phones, in most of benchmarks.

Benefits: 
- Faster read/write speeds 
- Can increase the life span of your flash storage due to less writes required
- Doesn't suffer file size limitation of 4GB

Disadvantages:
- F2FS formatted SD cards may have trouble mounting and some apps may not be able to work correctly
- Can be unstable
- Not supported on all phones 

EXT4

Ext4 is the evolution of the most used Linux filesystem, Ext3. In many ways, Ext4 is a deeper improvement over Ext3 than Ext3 was over Ext2. Ext3 was mostly about adding journaling to Ext2, but Ext4 modifies important data structures of the filesystem such as the ones destined to store the file data. The result is a filesystem with an improved design, better performance, reliability and features.

Benefits: 
- Faster read/write speeds 
- Increased stability over EXT2/EXT3 
- Doesn't suffer file size limitation of 4GB
- Regarded as a very stable file system
- Contains many features such as encryption (used in adaptive storage)

Disadvantages:
- If journaling is present (enabled by default), it can have a negative effect to the lifespan of your flash storage
- EXT4 formatted SD cards may have trouble mounting and some apps may not be able to work correctly


EXT3

Ext3, or third extended filesystem, is a journaled file system that is commonly used by the Linux kernel. It is the default file system for many popular Linux distributions. Stephen Tweedie first revealed that he was working on extending ext2 in Journaling the Linux ext2fs Filesystem in a 1998 paper, and later in a February 1999 kernel mailing list posting. The filesystem was merged with the mainline Linux kernel in November 2001 from 2.4.15 onward. Its main advantage over ext2 is journaling, which improves reliability and eliminates the need to check the file system after an unclean shutdown. Its successor is ext4.

Benefits: 
- Faster read/write speeds 
- Doesn't suffer file size limitation of 4GB
- Increased stability over EXT2

Disadvantages:


- EXT3 formatted SD cards may have trouble mounting and some apps may not be able to work correctly
- Not supported on all phones 

EXT2

The ext2 or second extended filesystem is a file system for the Linux kernel. It was initially designed by Rémy Card as a replacement for the extended file system (ext). Its metadata structure was inspired by the earlier Unix File System (UFS).

Ext2 was the default filesystem in several Linux distributions, including Debian and Red Hat Linux, until supplanted more recently by ext3, which is almost completely compatible with ext2 and is a journaling file system. ext2 is still the filesystem of choice for flash-based storage media (such as SD cards, and USB flash drives), since its lack of a journal increases performance and minimizes the number of writes, and flash devices have a limited number of write cycles. Recent kernels, however, support a journal-less mode of ext4, which would offer the same benefit, along with a number of ext4-specific benefits.


Benefits: 
- Faster read/write speeds 
- Doesn't have any journaling so it can increase the lifespan of your device due to less writes required (better designed for flash storage)
- Doesn't suffer file size limitation of 4GB

Disadvantages:


- EXT2 formatted SD cards may have trouble mounting and some apps may not be able to work correctly
File corruption is more likely to occur in an unexpected event compared to Ext4
- Can be unstable 
- Not supported on all phones 

FAT32

Developed by Microsoft, "FAT" stands for "File Allocation Table," which keeps track of all your files and helps the computer locate them on the disk. Even if a file gets fragmented (split up into various areas on the disk), the file allocation table still can keep track of it. FAT32 is an improvement to the original FAT system, since it uses more bits to identify each cluster on the the disk. This helps the computer locate files easier and allows for smaller clusters, which improves the efficiency of your hard disk. FAT32 supports up to 2 terabytes of hard disk storage. Unless you are a serious power user, that should be more than enough space for you. 

Benefits: 
- Compatible with all devices
- Can be useful if you switch your SD card between many different devices 

Disadvantages:
- File limitation of 4GB may be counter-productive for people dealing with large files such as UHD Video Recorders, etc. 
- File corruption is more likely to occur in an unexpected event compared to Ext4
- Due to the way the file system works, it can easily introduce file fragmentation 
- Slower transfer speeds compared to other file systems 


exFAT

exFAT was first introduced in late 2006 as part of Windows CE 6.0, an embedded Windows operating system. Most of the vendors signing on for licenses of exFAT are either for embedded systems or device manufacturers that produce media that will be preformatted with exFAT. The entire FAT family, exFAT included, is used for embedded systems because it is lightweight and is better suited for solutions that have low memory and low power requirements, and can be implemented in firmware.

exFAT allows individual files larger than 4 GiB, facilitating long continuous recording of HD video which can exceed the 4 GiB limit in less than an hour. Current digital cameras using FAT32 will break the video files into multiple segments of approximately 2 or 4 GiB. With the increase of capacity and the increase of data being transferred, the write operation needs to be made more efficient. SDXC cards, running at UHS-I have a minimum guaranteed write speed of 10 MBps and exFAT plays a factor in achieving that throughput through the reduction of the file system overhead in cluster allocation. This is achieved through the introduction of a cluster bitmap and elimination (or reduction) of writes to the FAT table. A single bit in the directory record indicates that the file is contiguous, telling the exFAT driver to ignore the FAT table. This optimization is analogous to an extent in other file systems, except that it only applies to whole files, as opposed to contiguous parts of files.


Benefits: 
- Removes file size limitation found in FAT32

Disadvantages:
- Not supported on all phones  
- Like all other FAT filesystems, not as reliable as EXT4

VFAT

This is the default file system used to format your internal storage in CWM and TWRP recoveries. VFAT is an extension of the FAT file system and was introduced with Windows 95. VFAT maintains backward compatibility with FAT but relaxes the rules. For example, VFAT filenames can contain up to 255 characters, spaces, and multiple periods. Although VFAT preserves the case of filenames, it's not considered case sensitive.

The reason is it's becoming more common than FAT, but aside from the differences mentioned above, VFAT has the same limitations. When you tell Windows NT (the Windows Kernel) to format a partition as FAT, it actually formats the partition as VFAT. The only time you'll have a true FAT partition under Windows NT 4.0 is when you use another operating system, such as MS-DOS, to format the partition. 


Benefits: 
- Compatible with all devices
- All applications should be able to work natively 

Disadvantages:
- File limitation of 4GB may be counter-productive for people dealing with large files such as UHD Video Recorders, etc. 
File corruption is more likely to occur in an unexpected event compared to EXT4
- Due to the way the file system works, it can easily introduce file fragmentation 
- Slower transfer speeds compared to other file systems 

NTFS

NTFS is a high-performance and self-healing file system proprietary to Windows XP Vista 2008 2003 2000 NT & Windows 7,Windows 8, which supports file-level security, compression and auditing. It also supports large volumes and powerful storage solution such as RAID. The most important features of NTFS are data integrity (transaction journal) and the ability to encrypt files and folders to protect your sensitive data.

Benefits: 
- Faster read/write speeds 
- Doesn't suffer file size limitation of 4GB
- Regarded as a very stable file system 
- Contains many features such as encryption

Disadvantages:
- Not designed for flash storage, therefore can reduce the life of your flash storage
- Not supported on all phones 


Sources: wikipedia, techterms.com, cnx-software.com, NTFS.com


Benchmark


This is a direct copy (with my own additions) of the guide here: http://forum.xda-developers.com/showthread.php?t=2697069 , credits go to Androguide.fr and others too!

EXT4 vs F2FS


In order to see what this file system really brings to the table I decided to run some benchmarks, in a controlled environment, trying to eliminate as many fluctuation factors as possible.
The methodology is described below.

For this first round, only the /data & /cache partitions were formatted as f2fs, in order to see what kind of improvement we would be able to get out of formatting /system as f2fs too later on.


Benchmarks Used


Methodology
  • Fully wiped and fresh install of the 26/03 CM nightly
  • PA Gapps installed (pa_gapps-modular-full-4.4.2-20140301-signed) & updated
  • Additionnal apps installed:
    • Pimp My Z1
    • Disk Info
    • Benchmark apps
  • No other app active in the background during benchmarks
  • Fresh reboot before running the batch of benchmarks
  • Airplane mode enabled (except for quadrant which requires an internet connection to show the results)
  • Order of the benchmarks:
    • RL Bench
    • Androbench
    • CF Bench
    • 5 minutes pause with powersave governor to cool down the device
    • 0xBenchmark
    • AnTuTu
    • Quadrant
  • Pimp My Z1 Settings:
    • CPU Governor: performance (in order to eliminate differences due to frequency scaling, as this governor just stays at max freq all the time).
    • GPU Governor: performance
    • GPU Max Freq: 600MHz
    • Intelliplug: disabled
    • Dynamic Fsync: enabled
    • I/O Scheduler: FIOPS for both emmc & sdcard
    • Readahead: 1024kb for both emmc & sdcard
    • Entropy contribution: disabled for both emmc & sdcard
    • PowerSuspend: disabled
    • KSM: enabled, 512 pages-to-scan, 500ms timer
    • Thermal throttling: disabled


Disk Usage
One thing I noted is that F2FS has a much higher usage of the /cache partition than ext4, which is to be expected coming from a log-based file system such as F2FS.
As you can see in the screenshots below (ext4 on the left & f2fs on the right), only 4mb out of the 192mb /cache partition is used by ext4, while f2fs uses 68% of that same partition with 114mb used.
Another thing to note is that under f2fs, the reported size of the /cache partition is apparently 2mb larger than on ext4, with 198mb.

EXT4 / F2FS
Disk Usage Graph Ext4 Disk Usage Graph F2FS



1. RL Bench
RL Bench is an SQLite benchmark, it only tests database read/writes with various SQL commands in various amounts.
As we can see in the results below, f2fs trumps ext4 with an overall time of only 14.417 seconds versus the 21.403 seconds of the latter.

EXT4
RL Bench EXT4 Graph 1 RL Bench EXT4 Graph 2 RL Bench EXT4 Graph 3

F2FS
RL Bench F2FS Graph 1 RL Bench F2FS Graph 2 RL Bench F2FS Graph 3



2. Androbench
Androbench is supposedly an all-around I/O benchmark.
On this one, the results were so incredibly appart that I think we can safely assume a big part of these results are due to poor coding on the benchmark side.
Still, if we believe the results, f2fs provides slightly slower reads (51mbps vs 66mbps) but over 120x faster sequential writes & 300x faster random write speeds!
I had to reboot and run it a second time to make sure this wasn't an error, but the second run results were even a bit better, as you can see in the screenshots below.

EXT4
Androbench Benchmark EXT4 Graph 1 Androbench Benchmark EXT4 Graph 2

F2FS
1st Run
Androbench Benchmark F2FS Graph 1 Androbench Benchmark F2FS Graph 2

2nd Run
Androbench Benchmark F2FS Graph 3 Androbench Benchmark F2FS Graph 4



3. CF-Bench
CF-Bench is an overall benchmark by Chainfire which measure everything except graphics.
Here again, f2fs is the winner with a better overall score.
That being said, the native writes are a little inferior to the ext4 native write score with 529 vs 535, but has a higher native read score with 996 vs 913.

EXT4
CF-Bench Benchmark EXT4 Graph 1 CF-Bench Benchmark EXT4 Graph 1

F2FS
CF-Bench Benchmark F2FS Graph 1 CF-Bench Benchmark F2FS Graph 2



4. 0xBenchmark
This reliable open-source benchmark by 0xlab is an overall benchmark used by the Linaro android team during their famous toolchain demonstration.
It has the advantage to output the results in text, xml and json, which you can download below.

On the SunSpider javascript benchmark run, f2fs gets a better score with 744.5ms vs 792.0ms for ext4.
Strangely, on Linpack, ext4 gets a better score with 156mflops/s vs 122mflops/s for f2fs.
On the other hand, Scimark2 reports better mflops/s scores for f2fs in all 6 of its tests, as seen below:



EXT4 Scimark2
Results in Mflops/s



Code:



Scimark2
 ------------------------------------------------------------ 
Composite: 
 191.7992650532917
Fast Fourier Transform:
 121.33004358991259 
Jacobi Successive Over-relaxation:
 431.85904395507 
Monte Carlo integration:
 10.79962368351458 
Sparse matrix multiply:
 132.34248411160723 
dense LU matrix factorization:
 262.6651299263541


F2FS Scimark2
Results in Mflops/s


Code:

Scimark2
 ------------------------------------------------------------ 
Composite:
 195.01022812596952 
Fast Fourier Transform:
 125.55719947408143 
Jacobi Successive Over-relaxation:
 436.3575761486842 
Monte Carlo integration:
 11.192272530363814 
Sparse matrix multiply:
 138.67117163604067 
dense LU matrix factorization:
 263.27292084067756

EXT4 full resultshttp://d-h.st/iER
F2FS full resultshttp://d-h.st/iOf



5. AnTuTu Benchmark
No need for an introduction, it's probably the most popular benchmark these days.
On this one again, f2fs is the clear winner with a difference of over 1200 points.

EXT4
Antutu Benchmark EXT4 Graph 1 Antutu Benchmark EXT4 Graph 2

F2FS
Antutu Benchmark F2FS Graph 1 Antutu Benchmark F2FS Graph 2



6. Quadrant Benchmark
Another overall mainstream type of benchmark.
F2FS wins on this one too, with an advantage of 1100+ points.

EXT4 / F2FS
Quadrant Benchmark EXT4 Graph Quadrant Benchmark F2FS Graph



Graphs for other file systems 


This is a really nice diagram comparing Ext4 with other commonly used linux filesystems:



Here is another good graph: 





These graphs are comparing the performance differences in commonly used Windows file systems: 









In Conclusion, F2FS actually is an improvement over Ext4 for flash devices, and considering its very young age it will most likely be improved over time. NTFS and and EXFAT should theoretically perform better than EXT4, but not enough test show that F2FS is the best. 

Comparison: 

Speed: 

Best------------------------------------------------------------------------------------------------------->Worst
F2FS > NTFS > EXT2 > EXT4 EXFAT > FAT32 >  VFAT > EXT3

Stability:

Best------------------------------------------------------------------------------------------------------->Worst

NTFS > VFAT > FAT32   > EXT4 > EXT3  > EXFAT > EXT2 > F2FS


Recommendations:


Use the following when determining what you want:


For stability:
- VFAT
- FAT32
- EXT4

For compatibility:
- VFAT
- FAT32

For speed: 
- F2FS
- EXT4

For real world performance:  
- EXT4
- F2FS

My conclusion:


F2FS is still a relatively new file system and its implementation to android isn't perfect yet. So if you value your data to be stable and safe, stay away from F2FS. Ext4 is still the best and most popular file system today (being reliable, fast enough for everyday usage) and it will be used for a long time until someone finally fixes the issues with F2FS. However, it comes with it's fair share of disadvantages. Some devices are not able to properly handle EXT4 due to kernel driver issues, and so the only option to use is VFAT or FAT32. 


Credits to androguide.fr as well as the websites for their images! :)

6 comments:

Please respect the admin of the website and don't post spam! Spam will be removed through moderation so you will be wasting time if you do so! Post something meaningful that will help the developer or others :) If spam becomes a problem, I will remove the ability to create comments once again.

Total Pageviews