Flashable Filesystem Check and Repair Tool

Search This thread

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
This flashable script will try to check and fix filesystem errors in your ext and fat32 partitions. The repair on fat32 may not be robust, but at least you will be alerted to any potential issues and can then run a dosfsck/chkdsk to fix issues,

This was created for my SuperNova Rom which uses Data2sd, but can be used for any Rom which uses an ext4 partition.

Potential candidates are phones with new issues of Force closes appearing, which usually signify a partition corruption..

Report on the file system check and repair will be output to /sdcard/repairlog.txt



This could be a "must-have" tool for every sdcard. :)



[*]Version History
  • FixFS 21-Sept-11
  • Initial script
  • FixFS 0.2 22-Sept-11
  • More checkpoints in logic
  • Verbose output
 

Attachments

  • FixFS.zip
    233.4 KB · Views: 2,057
  • FixFSv0.2.zip
    233.6 KB · Views: 3,460
Last edited:

limscap1

Senior Member
Sep 10, 2011
53
8
===================================
DROIDZONE'S FILESYSTEM FIXER SCRIPT
===================================
Script started at Thu Sep 22 00:36:27 GMT 2011
Ext4 file system found...
e2fsck running
One or more errors were found in your ext4 partition
e2fsck has encountered technical errors and cannot continue. Script will ABORT
Sdcard found..
Attempting to unmount sdcard
DosFsck running...
One or more errors were found in your Fat32 partition
dosfsck has encountered technical errors and cannot continue. Script will ABORT
Script has completed operations
-----
Above is my result of your awsome tool(thank you so much), seems some errors occured or found problems on my sd, but not fixed during the patch's on.
Would you give me a tip for the next step?

Sent from my HTC Desire using XDA App
 
Last edited:

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
You will have to do a manual e2fsck from the shell, since that usually means it is waiting for user intervention due to some errors. Though the automatic options I specified should correct minor issues, some seem to still need intervention

Sent from my HTC Desire using Tapatalk
 
  • Like
Reactions: limscap1

beanbean50

Senior Member
Jul 9, 2008
3,490
1,642
London
nice work as per usual matey :)

ran it once through ROM Manager and your screen in recovery was only visible for a split second, so I checked the repairlog and read this:

===================================
DROIDZONE'S FILESYSTEM FIXER SCRIPT
===================================
Script started at Thu Sep 22 00:43:51 GMT 2011
Ext4 file system found...
e2fsck running
One or more errors were found in your ext4 partition
e2fsck has encountered technical errors and cannot continue. Script will ABORT
Sdcard found..
Attempting to unmount sdcard
DosFsck running...
One or more errors were found in your Fat32 partition
dosfsck has encountered technical errors and cannot continue. Script will ABORT
Script has completed operations

===================================

When I got home I checked the SD card through windows (no errors) then your script through Max's 4EXT app and no split second reading this time, it read:


===================================
DROIDZONE'S FILESYSTEM FIXER SCRIPT
===================================
Script started at Thu Sep 22 04:57:43 GMT 2011
Ext4 file system found...
e2fsck running
Your ext4 file system was checked and was clean..No repair was necessary.
Sdcard found..
Attempting to unmount sdcard
DosFsck running...
Your Fat32 file system was checked and was clean..No repair was necessary.
Script has completed operations


So a very big thank you to you and Max :)
 

Ultrakiller

Senior Member
Oct 9, 2010
177
117
Hi Droidzone,
something goes wrong for me, i explain it with log below:


recovery.log
Code:
-- Installing: /sdcard/FixFS.zip
mtd: successfully wrote block at 0
I:Set boot command "boot-recovery"
Finding update package...
I:Update location: /sdcard/FixFS.zip
Opening update package...
Installing update...
 about to run program [/tmp/pre.sh] with 1 args

===================================
DROIDZONE'S FILESYSTEM FIXER SCRIPT
===================================
Script started at Thu Sep 22 10:38:42 GMT 2011
Ext4 file system found...
e2fsck running
/tmp/pre.sh: line 56: /tmp/e2fsck: not found
One or more errors were found in your ext4 partition
e2fsck has encountered technical errors and cannot continue. Script will ABORT
Sdcard found..
Attempting to unmount sdcard
umount: can't umount /sdcard: Device or resource busy
DosFsck running...
/tmp/pre.sh: line 86: /tmp/fsck_msdos: not found
One or more errors were found in your Fat32 partition

dosfsck has encountered technical errors and cannot continue. Script will ABORT
Script has completed operations
The log file has been copied to sdcard_repairlog.txt
script result was [|______________________________________________|]
minzip: Extracted file "/tmp/e2fsck"
minzip: Extracted file "/tmp/fsck_msdos"
minzip: Extracted file "/tmp/pre.sh"

















________________________________________________
|                                              |
|        PARTITION CHECK & REPAIR TOOL         |
|     ==================================       |
|                - DROIDZONE -                 |
|                                              |
| This is an On-Demand Partition Fix tool.     |
| If you find too many force closes or freezes |
| on your phone, it may be the first indication|
| of increasing corruption on your ext4 partit-|
| ion. Running this tool will fix most of them.|
|                                              |
|                                              |
|  [*]Checking and Fixing File system...       |
|  [*]Checking Fat32 File system...            |
|  [*]Checking ext4 File system...             |
|  [*]Done                                     |
|  [*]Repair log in sdcard/repairlog.txt       |
|______________________________________________|

Install from sdcard complete.

So, without reboot i connected my adb shell and i'd try manually (with /sdcard alredy unmounted)


Code:
/tmp # ls -ail
ls -ail
    213 drwxr-xr-x    2 root     root             0 Sep 22 10:38 .
      1 drwxr-xr-x   19 root     root             0 Sep 22 10:03 ..
    722 -rw-rw-rw-    1 root     root            10 Sep 22 10:04 4ext_version
    721 -rw-rw-rw-    1 root     root             3 Sep 22 10:04 batt_level
    756 -rwxrwxrwx    1 root     root        111492 Aug  1  2008 e2fsck
    730 -rw-rw-rw-    1 root     root             5 Sep 22 10:04 free_space
    757 -rwxr-xr-x    1 root     root         22640 Aug  1  2008 fsck_msdos
    758 -rwx------    1 root     root          2490 Aug  1  2008 pre.sh
    692 -rw-rw-rw-    1 root     root          8502 Sep 22 10:49 recovery.log
    715 -rw-rw-rw-    1 root     root            72 Sep 22 10:03 sd_fstypes
    764 -rwxr-xr-x    1 root     root        255904 Sep 22 10:38 update_binary
/tmp # /tmp/e2fsck -af /dev/block/mmcblk0p2
/tmp/e2fsck -af /dev/block/mmcblk0p2
/sbin/sh: /tmp/e2fsck: not found
/tmp # /tmp/fsck_msdos -pf /dev/block/mmcblk0p1
/tmp/fsck_msdos -pf /dev/block/mmcblk0p1
/sbin/sh: /tmp/fsck_msdos: not found
/tmp # pre.sh
pre.sh
/sbin/sh: pre.sh: not found
/tmp # ./pre.sh
./pre.sh

===================================
DROIDZONE'S FILESYSTEM FIXER SCRIPT
===================================
Script started at Thu Sep 22 10:58:36 GMT 2011
Ext4 file system found...
e2fsck running
./pre.sh: line 56: /tmp/e2fsck: not found
One or more errors were found in your ext4 partition
e2fsck has encountered technical errors and cannot continue. Script will ABORT
Sdcard found..
Attempting to unmount sdcard
umount: can't umount /sdcard: Invalid argument
umount: can't forcibly umount /sdcard: Invalid argument
DosFsck running...
./pre.sh: line 86: /tmp/fsck_msdos: not found
One or more errors were found in your Fat32 partition
dosfsck has encountered technical errors and cannot continue. Script will ABORT
Script has completed operations
The log file has been copied to sdcard_repairlog.txt
/tmp # ./tmp/fsck_msdos -pf /dev/block/mmcblk0p1
./tmp/fsck_msdos -pf /dev/block/mmcblk0p1
/sbin/sh: ./tmp/fsck_msdos: not found

i can't understand why ./pre.sh: line 56: /tmp/e2fsck: not found

recovery is kidding me!? :eek:



anyway all seems ok using e2fsck built in recovery 4EXT 2.1.3RC4 (i used verbose option):

Code:
~ # e2fsck -afv /dev/block/mmcblk0p2
e2fsck -afv /dev/block/mmcblk0p2

     730 inodes used (0.56%)
      25 non-contiguous files (3.4%)
       1 non-contiguous directory (0.1%)
         # of inodes with ind/dind/tind blocks: 0/0/0
         Extent depth histogram: 720
  259347 blocks used (49.47%)
       0 bad blocks
       0 large files

     707 regular files
      14 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
       0 symbolic links (0 fast symbolic links)
       0 sockets
--------
     721 files
 
Last edited:

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
Weird indeed that the files in /tmp cant be accessed. Anyway, I'll add code to abort script if the binaries cant be found..it doesnt look good with the script saying everything's working.. :) I didnt add verbose early because of the output (confuses newbies?), but I'll add it too.

Edit: Forgot to mention that I use 4ext too, and no such issues here.
 
Last edited:

limscap1

Senior Member
Sep 10, 2011
53
8
You will have to do a manual e2fsck from the shell, since that usually means it is waiting for user intervention due to some errors. Though the automatic options I specified should correct minor issues, some seem to still need intervention

Sent from my HTC Desire using Tapatalk
Really appreciate for your kind explanation ^^;

Then, could somebody inform me how to to do a manual e2fsck from the shell or any links shows relative information? I've already questioned it at Q & A, but so far nobody has answered...
 

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
Really appreciate for your kind explanation ^^;

Then, could somebody inform me how to to do a manual e2fsck from the shell or any links shows relative information? I've already questioned it at Q & A, but so far nobody has answered...

It was there in Ultrakiller's quote.

Code:
e2fsck -afv /dev/block/mmcblk0p2

The command is found in /system/bin usually..My flasher also copies that file to /tmp. So:

Code:
chmod 755 /tmp/e2fsck
/tmp/e2fsck -afv /dev/block/mmcblk0p2
 
  • Like
Reactions: limscap1

Ultrakiller

Senior Member
Oct 9, 2010
177
117
I would be linked in first post, for all that users who can't use the droidzone's script. ;)

Reboot in Recovery, and connect adb shell.

EXT4 REPAIR/CHECK

Code:
e2fsck -afv /dev/block/mmcblk0p2
e2fsck will check and repair ext4 partition if needed.
an example:
Code:
e2fsck -afv /dev/block/mmcblk0p2

     730 inodes used (0.56%)
      25 non-contiguous files (3.4%)
       1 non-contiguous directory (0.1%)
         # of inodes with ind/dind/tind blocks: 0/0/0
         Extent depth histogram: 720
  259347 blocks used (49.47%)
       0 bad blocks
       0 large files

     707 regular files
      14 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
       0 symbolic links (0 fast symbolic links)
       0 sockets
--------
     721 files

FAT32 REPAIR/CHECK

mount usb partition on pc using recovery menu.
Once connected usb cable and opened cmd on pc type:

Code:
chkdsk /R f:\
in my case fat32 partition is f:
chkdsk can take a while (around 20min)
an example of output here (sorry, italian OS, anyway in my case no errors found)
Code:
Il file system è di tipo FAT32.
Numero di serie del volume: B996-8582
Verifica dei file e delle cartelle in corso...
Verifica dei file e delle cartelle completata.
Verifica dello spazio disponibile in corso...
Verifica dello spazio disponibile completata.
Verifica del file system effettuata.  Nessun problema rilevato.
   13.525.072 KB di spazio totale su disco.
        2.408 KB in 295 cartelle.
    6.963.592 KB in 1.891 file.
    6.559.064 KB disponibili.

        8.192 byte in ogni unità di allocazione.
    1.690.634 unità totali di allocazione su disco.
      819.883 unità di allocazione disponibili su disco.


If i helped someone please hit thanks button! ;)
 
Last edited:

blackhawk_LA

Senior Member
Dec 27, 2010
1,560
657
HTC One (m7)
Sony Xperia XZ1 Compact
First of all, thanks Droidzone for your work ;)

I have run the tool and had this
e2fsck running
One or more errors were found in your ext4 partition
e2fsck has encountered technical errors and cannot continue. Script will ABORT
Sdcard found..
Attempting to unmount sdcard
DosFsck running...
One or more errors were found in your Fat32 partition
dosfsck has encountered technical errors and cannot continue. Script will ABORT
Script has completed operations
-----

When running e2fsck from adb doesn't find anything wrong:

(sorry can't copy/paste, I have attached an image)

And if I run a script (founded in a MIUI rom, a didn't remember what version) from gscript, called check sd it says:
Will be Check your SD Card from kernel message:

===============================================

[ 19.726623] mmcblk0: mmc1:b368 USD 7.46 GiB
[ 19.727478] mmcblk0: p1 p2 p3
[ 20.836303] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue
[ 24.104003] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue
[ 24.484558] EXT4-fs (mmcblk0p3): mounted filesystem without journal. Opts: noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue
[ 26.537750] EXT4-fs (mmcblk0p3): mounted filesystem without journal. Opts: noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue

===============================================

If you found error between two lines, then your SD card is broken.

The commands on that script are:

mkdir /sdcard/gscript/resources>/dev/null
clear
echo "echo Will be Check your SD Card from kernel message:" > /sdcard/gscript/resources/temp.sh
echo "echo ===============================================" >> /sdcard/gscript/resources/temp.sh
echo "dmesg|grep mmcblk0" >> /sdcard/gscript/resources/temp.sh
echo "echo ===============================================" >> /sdcard/gscript/resources/temp.sh
echo "echo If you found error between two lines, then your SD card is broken." >>/sdcard/gscript/resources/temp.sh
su</sdcard/gscript/resources/temp.sh
rm /sdcard/gscript/resources/temp.sh

If someone can help, I'll be really grateful. I have also tried repartitioning the whole SD card with gparted, but the problem still appears. I'm using Alex-V ROM d2ext with default kernel (snq-)

Thanks in advance
 

Attachments

  • e2fsck.JPG
    e2fsck.JPG
    19.6 KB · Views: 347

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
First of all, thanks Droidzone for your work ;)

I have run the tool and had this


When running e2fsck from adb doesn't find anything wrong:

(sorry can't copy/paste, I have attached an image)

And if I run a script (founded in a MIUI rom, a didn't remember what version) from gscript, called check sd it says:


The commands on that script are:



If someone can help, I'll be really grateful. I have also tried repartitioning the whole SD card with gparted, but the problem still appears. I'm using Alex-V ROM d2ext with default kernel (snq-)

Thanks in advance

That check in Miui seems to be at the kernel level..However imho I dont see an error...that line just seems to be the kernel output saying what ext4 options have been used for the mount (should be present for everyone :) ). Do you see any actual issues while using the card?
 
  • Like
Reactions: blackhawk_LA

blackhawk_LA

Senior Member
Dec 27, 2010
1,560
657
HTC One (m7)
Sony Xperia XZ1 Compact
I haven't see any big issues, just noticed that the sdext restore from a nandroid seemed to take too much time (7-8 minutes for just 300mb) and that's why i used your tool and have a look at this post.
But everything is working fine (or it seems so), just wanted to know if my files could be starting to get corrupted or something.
Thanks ;)
 

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
As far as my script is concerned..it depends on error code from e2fsck to report file system state. That particular error code means that a standard error level was not returned, so only a command line manual e2fsck will show exactly what was the system response. See Post #14 for how to do that.
 

ben749

Member
Jun 20, 2012
17
0
Hi, got an error in clockwork recovery : error in fixfsv0.2.zip ( status 0 ) installation aborted ..
any clues ?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    This flashable script will try to check and fix filesystem errors in your ext and fat32 partitions. The repair on fat32 may not be robust, but at least you will be alerted to any potential issues and can then run a dosfsck/chkdsk to fix issues,

    This was created for my SuperNova Rom which uses Data2sd, but can be used for any Rom which uses an ext4 partition.

    Potential candidates are phones with new issues of Force closes appearing, which usually signify a partition corruption..

    Report on the file system check and repair will be output to /sdcard/repairlog.txt



    This could be a "must-have" tool for every sdcard. :)



    [*]Version History
    • FixFS 21-Sept-11
    • Initial script
    • FixFS 0.2 22-Sept-11
    • More checkpoints in logic
    • Verbose output
    2
    I would be linked in first post, for all that users who can't use the droidzone's script. ;)

    Reboot in Recovery, and connect adb shell.

    EXT4 REPAIR/CHECK

    Code:
    e2fsck -afv /dev/block/mmcblk0p2
    e2fsck will check and repair ext4 partition if needed.
    an example:
    Code:
    e2fsck -afv /dev/block/mmcblk0p2
    
         730 inodes used (0.56%)
          25 non-contiguous files (3.4%)
           1 non-contiguous directory (0.1%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 720
      259347 blocks used (49.47%)
           0 bad blocks
           0 large files
    
         707 regular files
          14 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           0 symbolic links (0 fast symbolic links)
           0 sockets
    --------
         721 files

    FAT32 REPAIR/CHECK

    mount usb partition on pc using recovery menu.
    Once connected usb cable and opened cmd on pc type:

    Code:
    chkdsk /R f:\
    in my case fat32 partition is f:
    chkdsk can take a while (around 20min)
    an example of output here (sorry, italian OS, anyway in my case no errors found)
    Code:
    Il file system è di tipo FAT32.
    Numero di serie del volume: B996-8582
    Verifica dei file e delle cartelle in corso...
    Verifica dei file e delle cartelle completata.
    Verifica dello spazio disponibile in corso...
    Verifica dello spazio disponibile completata.
    Verifica del file system effettuata.  Nessun problema rilevato.
       13.525.072 KB di spazio totale su disco.
            2.408 KB in 295 cartelle.
        6.963.592 KB in 1.891 file.
        6.559.064 KB disponibili.
    
            8.192 byte in ogni unità di allocazione.
        1.690.634 unità totali di allocazione su disco.
          819.883 unità di allocazione disponibili su disco.


    If i helped someone please hit thanks button! ;)
    1
    Nice one. If I had a partition to check, I'd definitely use this!

    Ha ha.. :D
    1
    You will have to do a manual e2fsck from the shell, since that usually means it is waiting for user intervention due to some errors. Though the automatic options I specified should correct minor issues, some seem to still need intervention

    Sent from my HTC Desire using Tapatalk
    1
    Really appreciate for your kind explanation ^^;

    Then, could somebody inform me how to to do a manual e2fsck from the shell or any links shows relative information? I've already questioned it at Q & A, but so far nobody has answered...

    It was there in Ultrakiller's quote.

    Code:
    e2fsck -afv /dev/block/mmcblk0p2

    The command is found in /system/bin usually..My flasher also copies that file to /tmp. So:

    Code:
    chmod 755 /tmp/e2fsck
    /tmp/e2fsck -afv /dev/block/mmcblk0p2