Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,742,782 Members 38,239 Now Online
XDA Developers Android and Mobile Development Forum

[MOD] ext2 file system for /system - Feb. 17 UPDATED

Tip us?
 
cun7
Old
(Last edited by cun7; 17th February 2014 at 10:18 PM.)
#1  
Account currently disabled - OP
Thanks Meter 288
Posts: 99
Join Date: Feb 2014
Default [MOD] ext2 file system for /system - Feb. 17 UPDATED

In short, what I will be doing here is mounting the /system partition as file system EXT2. Default is EXT4. The reason for doing this is simple. The /system partition is more of an access database where information is read and never written. The goal here is to remove journaling and not only journaling but the redundancy of the code tree of EXT4 by simply killing the EXT4 journal and leaving it mounted and formatted as EXT4.

EXT4 – The file system uses a function called journaling. Journaling, in short, is a file system log. What this provides to you as the user is a quick method of recovery if there is ever a system failure: unclean shutdown, file corruption, etc. If there is ever a problem, the journal is called and the data is restored with no issues. The cost of this journaling feature, however, is CPU time/usage. CPU cycles are used to write the journal to the disk.

EXT2 – This file system does not use journal. No recovery method, etc. So if something is corrupted, there is no way to recover corrupted files/blocks/data.


What does all of this mean? – Simple. What it means is those of us who are rooted, running a stable ROM/Kernel combo, and using a backup method such as TWRP or CWM, can safely use EXT2 for /system without any worry because all we need to do is make a backup of our /system partition via recovery, tuck it away on our internal SD card and save it for a rainy day - restore it if there is every an unclean shutdown (battery pull, reboot caused by an unstable kernel, etc.).

What benefits will you see/feel?
Honestly, I have no idea at this point. I know for a fact that the device will boot faster and read operations on the /system partition will be absolutely insanely fast. As fast as they can possibly be on the Note 3. As far as “end of the day” battery savings, well, this is kind of the point of me doing this and sharing. I am going to find out, and post my results here so other people can decide if they do or don’t want to do this as well. If all goes well, I’ll edit this post tomorrow with some quick instruction on how to convert the file system. It should be a quick and easy process.

Other benefits of using EXT2 instead of EXT4:
EXT2 is backward compatible with EXT4. What this means is you can have a file system formatted to EXT2, and it can be mounted as EXT4 and it will only utilize the newer useful features found in EXT4 that were not originally present when EXT2 was introduced. When mounted as EXT4, EXT2 will not use journaling, but will use EXT4’s superior block allocation and “tagging” feature. EXT4 has the ability to mark unused blocks on the disk so it knows to not look there for data – this saves precious time in read operations. EXT2 does not have this feature… except when it is mounted as EXT4

The biggest advantage, here, is to get rid of that useless EXT4 journaling feature used on our RO /system and save CPU cycles. We use backups.We are a different breed of users, right? We demand performance and push our devices to the limits and somehow manage to maintain a stable and usable system, correct?

YES! So, we’re gonna go ahead and take advantage of this super awesome backward compatibility of EXT2 on the /system partition and get some positive performance index out of it



INSTRUCTIONS - convert /system to EXT2

1. Unzip the .zip folder of your ROM of choice.
2. Find /META-INF/com/google/android/updater script.
3. Open the updater-script file in a text editor.

Any lines where you see "EXT4" and "system" in the same line, you need to change that 4 to a 2. Only do this for lines with system and EXT4 in the same line.

4. Save the changes, then zip the ROM back up.
5. Place ROM on your internal SD card, then boot into recovery - YOU MUST BE USING TWRP FOR THIS
6. Once you get into recovery, you will see your TWRP options (there are 8 tiles in recovery) - select the one that says "Advanced"
7. You will now see 6 tiles. On the left side, select the one that says "Terminal Command"
8. At the top you should see a / symbol - this is the directory you are going to begin your session in. You want it to be /
9. On the bottom right of the screen, hit "Select"

This next part is very important. Do not mess up.

When you get to the terminal screen, type this command:

Code:
Select Code
mke2fs /dev/block/mmcblk0p23

DO NOT continue until you have double checked that the number you punched in is 23! I cannot stress this enough. 23.... 23..... 23..... again that last part is "...mmcblk0p23"
After you have verified the correct partition number 23, hit the GO button on the keyboard to execute the command. It will run for a couple seconds and finish up.

After it finishes reformatting, flash your ROM of choice (the one where you edited any lines). When you are done, boot up.

You are now running an EXT2 file system for your /system partition. Welcome to the thunder dome
The Following 9 Users Say Thank You to cun7 For This Useful Post: [ Click to Expand ]
 
JT man
Old
#2  
Senior Member
Thanks Meter 71
Posts: 504
Join Date: Sep 2007

 
DONATE TO ME
Cool, can't wait to try, thanks for this finding

Sent from my SM-N900T using Tapatalk
The Following User Says Thank You to JT man For This Useful Post: [ Click to Expand ]
 
muqali
Old
#3  
muqali's Avatar
Senior Member
Thanks Meter 95
Posts: 620
Join Date: Nov 2007
Location: Unfortunately, Mexico
Why not just create and mount an ext4 filesystem with no journal? There is a reason they made the ext4 driver able to mount ext2,3 filesystems. Aside from journaling, which can be disabled, ext4 and it's driver are generally better.

edit - Didn't mean to quote.
Android FOSS Repository - http://f-droid.org/
The Following User Says Thank You to muqali For This Useful Post: [ Click to Expand ]
 
cun7
Old
#4  
Account currently disabled - OP
Thanks Meter 288
Posts: 99
Join Date: Feb 2014
Quote:
Originally Posted by muqali View Post
Why not just create and mount an ext4 filesystem with no journal? There is a reason they made the ext4 driver able to mount ext2,3 filesystems. Aside from journaling, which can be disabled, ext4 and it's driver are generally better.

edit - Didn't mean to quote.
The reason is because the op paths in the file system tree (speaking of EXT4) are optimized for the journal. Without the journal the code path is redundant and the journal-optimized block has empty overhead. EXT2's strength is it's simplicity in structure.

Basically what this translates to is EXT4 formatted disk, mounted as EXT4 and with no journal, is not as fast or efficient as EXT2 formatted disk mounted as EXT4.

I am running this set up right now. This thread will be updated soon with instruction on how to convert it.
The Following 3 Users Say Thank You to cun7 For This Useful Post: [ Click to Expand ]
 
LancerV
Old
#5  
LancerV's Avatar
Senior Member
Thanks Meter 227
Posts: 1,205
Join Date: Nov 2007
Ext4 has quicker read times than Ext2 which too me is going to the biggest perofmance increase.
Free Host for XDA-Devs PM me for username/password
The Following User Says Thank You to LancerV For This Useful Post: [ Click to Expand ]
 
Morningstar
Old
#6  
Morningstar's Avatar
Senior Member
Thanks Meter 102
Posts: 261
Join Date: Apr 2006
This sounds interesting, but I think I'll wait to see others' experiences before giving it a go myself. Will be keeping an eye on this thread though.

Sent from my SM-N9005 using XDA Premium 4 mobile app
~astra petas~
The Following User Says Thank You to Morningstar For This Useful Post: [ Click to Expand ]
 
cun7
Old
#7  
Account currently disabled - OP
Thanks Meter 288
Posts: 99
Join Date: Feb 2014
The only reason EXT4 has faster read times is because of what I just explained - ext4 uses a method of marking unused blocks on a disk, so it doesn't scan them looking for something. EXT2 does not have this feature. However, when an EXT2 formatted disk is mounted as EXT4, it does utilize this feature of EXT4.
The Following 2 Users Say Thank You to cun7 For This Useful Post: [ Click to Expand ]
 
muqali
Old
#8  
muqali's Avatar
Senior Member
Thanks Meter 95
Posts: 620
Join Date: Nov 2007
Location: Unfortunately, Mexico
Do you have any data, your own or third party to back this up? Do you plan on using an ext2 system with the ext4 driver? Or the old ext2 fs driver? As I understand it, the ext4 driver was given the ability to mount 2/3 filesystems for simplicity sake as well as the newer driver being better but I could be mistaken.

edit - The way you explained it in your last post seems to sound like you'll use ext4 driver on an ext2 fs, I was just asking because I wasn't 100% sure.
Android FOSS Repository - http://f-droid.org/
The Following User Says Thank You to muqali For This Useful Post: [ Click to Expand ]
 
cun7
Old
(Last edited by cun7; 18th February 2014 at 10:36 AM.)
#9  
Account currently disabled - OP
Thanks Meter 288
Posts: 99
Join Date: Feb 2014
Quote:
Originally Posted by muqali View Post
Do you have any data, your own or third party to back this up? Do you plan on using an ext2 system with the ext4 driver? Or the old ext2 fs driver? As I understand it, the ext4 driver was given the ability to mount 2/3 filesystems for simplicity sake as well as the newer driver being better but I could be mistaken.

edit - The way you explained it in your last post seems to sound like you'll use ext4 driver on an ext2 fs, I was just asking because I wasn't 100% sure.
That was the intention, correct. Using EXT2 formatted /system but mount it as EXT4 - for the reasons I outlined. To effectively remove journaling and not only that, but the redundant overhead of journaling in the fs tree which would still remain if I were to, say, run this command...

Code:
Select Code
tune2fs -O ^has_journal /dev/block/mmcblk0p23

EDIT** and so far, yes the difference has been noticeable in boot up time - which is a clear indicator of a performance increase. It loads the /system much faster during boot. Battery life has been slightly better as well.
The Following User Says Thank You to cun7 For This Useful Post: [ Click to Expand ]
 
LancerV
Old
#10  
LancerV's Avatar
Senior Member
Thanks Meter 227
Posts: 1,205
Join Date: Nov 2007
Do you have a video or benchmark showing the differnce?
Free Host for XDA-Devs PM me for username/password

THREAD CLOSED
Subscribe
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes