[Samsung Galaxy S Blaze 4G] thomas.raines:
Ok, lately we have had a rash of errors and undesired performance. In my opinion, this is unacceptable... So I am trying to fix it. Now, I can't fix every issue, but boy can I sure help most of them...lol

So let's get started. We will call this:

The File System Cleaner

Linux has a few tools for us to see if we have a "Dirty" or "Clean" filesystem.

They are tune2fs, e2fsck, and fsck_msdos.

Now, you can't use all of them for every file system or partition (we will refer to them all as partitions from here on out). Each one works on certain filesystems. For example, e2fsck works on ext type partitions where fsck_msdos works on vfat type partitions, and tune2fs only works on large partitions.

While tune2fs is a tool that gives detailed information about a partition, it can still give us an idea on where we stand on those larger partitions as well as change certain options/features on that partition such as journaling, mount point, mount as rw or ro, etc. But the biggest thing we are going to focus on is 1 line:

Filesystem state

If you run tune2fs and the filesystem state is anything other than clean, you have some sort of gremlin floating about it and it needs to be fixed. Now what about those partitions in which we get these errors:

t

tune2fs 1.41.11 (14-Mar-2010)
tune2fs: Attempt to read block from filesystem resulted in short read while trying to open /dev/block/mmcblk0p4
Couldn't find valid filesystem superblock.
1|root@android:/ # tune2fs -l /dev/block/mmcblk0p28
tune2fs 1.41.11 (14-Mar-2010)
tune2fs: Bad magic number in super-block while trying to open /dev/block/mmcblk0p28
Couldn't find valid filesystem superblock

It doesn't mean that they are corrupt. It means they are either not in a format that tune2fs can read or they are not a large partition.

So for those partitions that are not compatible with tune2fs, we can use fsck.

The fsck works much like scan disk and defrag in windows. It scans the partition for several different things like bad blocks, missing/corrupt information, etc. Although you can run tune2fs on any large partition whether it is mounted or not, you DO NOT want to fsck ANY partition that is mounted or it WILL result in TOTAL data LOSS! You have been warn!

Keep in mind all this information is at your own risk, but know that I have been using this for quite some time and it hasn't failed me yet. But then again, I follow my instructions to a TEE, as you should as well...

So, here's how we use all this.

First make sure you have adb installed on your computer

To be safe, boot into recovery, plug your phone into your computer and start adb shell

Now type:

mount /system
cp /system/bin/tune2fs /tmp
cp /system/bin/e2fsck /tmp
cp /system/bin/fsck_msdos /tmp
chmod -R 777 /tmp
cd tmp

Now that our tools are set, we can now begin cleaning house.

First and most important, make sure you umount ALL partitions.

I personally unmount them manually via mounts and storage in CWM.

In terminal (with adb running) type:

./tune2fs -l <partition>
./e2fsck <partition>
./fsck_msdos <partition>

**NOTE**If you have an error "/sbin/sh: <command>: not found" when executing one of these commands simply mount /system and copy to tmp, and chmod 777 again.**

For more information on the commands, run <command> -h. here you will see additional options for that command.

Now, I didn't break down which partitions work with tune2fs, but /system, /data, and /cache can be scanned with tune2fs.

However, I did break as to what partitions need which fsck command to be cleaned.

e2fsck
|mount point| |Filesystem type|
/dev/block/mmcblk0p21 /efs
/dev/block/mmcblk0p24 /system
/dev/block/mmcblk0p25 /data
/dev/block/mmcblk0p26 /cache
/dev/block/mmcblk0p27 /tombstones
/dev/block/mmcblk1p2 unknown

fsck_msdos
|mount point| |Filesystem type|
/dev/block/mmcblk0p4 fsinfo
/dev/block/mmcblk0p13 /system/etc/firmware/misc
/dev/block/mmcblk0p17 /system/etc/firmware/misc_mdm
/dev/block/mmcblk0p28 emmc
/dev/block/mmcblk1p1 /sdcard

Example:

/tmp # e2fsck /dev/block/mmcblk0p24
e2fsck 1.41.12 (17-May-2010)
/dev/block/mmcblk0p24: clean, 4220/38320 files, 93625/153088 blocks

This should resolve many of your laggy performance and random reboot issues. As well as the issue of freezes after a reboot.

If you are a flash addict, tuning your partitions between flashes my be a GREAT idea...

If you do not have those binaries in your ROM, let me know and I will upload them here...

Now, there is a little more destructive way to clean a partition, and that is to reformat it. Most of us format /system /cache and dalvik in CWM before flashing, but sometimes that isn't enough. All CWM does is erase the files/folders contained in one of those partitions.

Here's how we do a complete reformat:

Reboot to recovery, plug phone in and start adb shell

Type:

mount /system
cp /system/bin/make_ext4fs /tmp
chmod 777 /tmp/make_ext4fs
mount <system, data or cache partition>
./make_ext4fs <partition>

This only works with ext4 partitions, so use it ONLY on these:

/dev/block/mmcblk0p24 /system
/dev/block/mmcblk0p25 /data
/dev/block/mmcblk0p26 /cache

I know there are other ext partitions, like tombstone and efs, but DO NOT use this command on them. You may BRICK or damage your device. I will say this again, ONLY DO THIS on data, cache, system!

**NOTE** If you format system partition, you WILL have to flash your ROM and Gapps again...