File systems

File systems (Updated on: 20/10/17)


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: 
- Theoretically faster read/write speeds 
- Can prolong 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
- Stability is heavily reliant on kernel maintainer
- 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:
- 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)
- Supported in all modern smartphones (well supported)

Disadvantages:
- If journaling is present (enabled by default), it can have a negative effect to the lifespan of your flash storage
- EXT4 formatted external 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:
- Doesn't suffer file size limitation of 4GB
- Increased stability over EXT2

Disadvantages:
- Uncommon on smartphones
- Unsupported


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:
- Doesn't have any journaling so it can prolong the lifespan of your device due to less writes required (better designed for flash storage)
- Doesn't suffer file size limitation of 4GB

Disadvantages:
File corruption is more likely to occur in an unexpected event compared to Ext4

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
- Known to be inefficient in storage space usage  


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
- Performs slightly better in real-world transfers than FAT32/VFAT
- Almost all modern smartphones have native support

Disadvantages:
- Most likely not supported on older devices 
- Has same inefficient usage of space like FAT32
- 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
- Known to be inefficient in storage space usage

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:
- 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 natively on Linux and therefore smartphones (requires kernel modification)


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


Benchmark

I highly recommend reading the linked guide for benchmarks on Android. http://forum.xda-developers.com/showthread.php?t=2697069 , credits go to Androguide.fr and others too!

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:
- EXT4
- NTFS
For compatibility:
- FAT32/VFAT
- Exfat

For speed: 
- F2FS

For real world performance:  
- EXT4
- F2FS

My conclusion:


All filesystems has their fair share of bugs and issues, but there are many variables that can cause problems to occur when using a filesystem. Overall, F2FS performs quite well in benchmarks and in real-world tests. But performance isn't the only metric everyone should be looking at. EXT4 has been the de-facto filesystem for Android for a while and Google has no plans to switch to F2FS any time soon.

All in all, select the filesystem that best suits you. Do you want reliability? Go with EXT4. Do you want better speed? Use F2FS. What about compatibility? Use FAT32 or Exfat.


Credits go to their respectful authors. I have no ownership over this information!

Comments

  1. Hats off to u bro
    U did damn great research

    ReplyDelete
  2. this info very useful for me..thank you

    ReplyDelete
  3. is there a way to mount f2fs formatted sd card in windows?

    ReplyDelete
  4. This was very useful when deciding which file system I wanted to use. Thank you very much!

    ReplyDelete
  5. Solid work man. Thanks a lot!

    ReplyDelete
  6. Your posts are always incredible. You de best bro. keep it up. Great info.

    ReplyDelete
  7. Hi All graphs you've provided give reference to speed. How do you say F2FS is unstable???

    ReplyDelete
    Replies
    1. I said that F2FS can be unstable. As this site was targeted towards android users, not all android devices are up-to-date with the mainline F2FS tree (reliant on the kernel maintainer). It simply isn't as mature as other filesystems like EXT4.

      Delete
    2. Thanks for reply and also updating the article. Present day even in Experienced Android devs are starting to fade F2FS away despite being actively supported. UFS upgrades instead eMMC storage simply makes performance difference so narrow. Also in my OnePlus3 I have tried being in F2FS and after 1 year, it started giving Kernel panics for no reason and occasionally my /userdata files got corrupted. Hence EXT4 stays strong...! My only worry is some devices like OnePlus 3T and Moto G devices came pre-installed with F2FS.., I wonder whether they will also face such instability issues...

      Delete

Post a Comment

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.