[HOW TO] Check your filesystem (a la 'fsck')

ViperGeek

Senior Member
Sep 12, 2008
133
36
0
Merrimack, NH
I've been having lots of trouble with my SD and local filesystems getting corrupted, which in turn has been causing the flush-179 process to go ballistic (100% CPU loop, reboot hangs, etc.). If only there was a way to run a quick FSCK(8) on my Android's unmounted filesystems to check for problems. Well, there is!

This may be old, old news to some of the more seasoned OS hackers, so please be kind with any negative feedback about it being intuitively obvious. It wasn't to me, but after some research and testing, I've come up with these simple steps:

  1. Boot into Recovery
  2. Connect via USB to ADB shell
    Code:
       C:\Scratch\Android> [B]adb devices[/B]
       C:\Scratch\Android> [B]adb shell[/B]
  3. Mount /system and /data to determine the /dev/block names, then umount each
    Code:
       ~ # [B]mount /system[/B]
       ~ # [B]mount /data[/B]
       ~ # [B]df[/B]
    Filesystem           1K-blocks      Used Available Use% Mounted on
    tmpfs                   308620        64    308556   0% /dev
    /dev/block/mmcblk0p27
                            295509    121021    159231  43% /cache
    /dev/block/mmcblk0p26
                           1184268    848052    276060  75% /data
    /dev/block/mmcblk0p25
                            562384    461416     72400  86% /system
       ~ # [B]umount /system[/B]
       ~ # [B]umount /data[/B]
  4. Run e2fsck against each /dev/block filesystem
    Code:
       ~ # [B]e2fsck -n /dev/block/mmcblk0p25[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p25: clean, 4168/35760 files, 117605/142847 blocks
       ~ # [B]e2fsck -n /dev/block/mmcblk0p26[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p26: clean, 7173/75200 files, 216745/300799 blocks
       ~ #
The 'e2fsck' command takes the same command-line switches as UNIX FSCK(8), so you can be as creative and daring as you need.

- Dave
 

robcop19

Senior Member
Mar 22, 2013
178
11
48
Atlanta
some help

I've been having lots of trouble with my SD and local filesystems getting corrupted, which in turn has been causing the flush-179 process to go ballistic (100% CPU loop, reboot hangs, etc.). If only there was a way to run a quick on my Android's unmounted filesystems to check for problems. Well, there is!

This may be old, old news to some of the more seasoned OS hackers, so please be kind with any negative feedback about it being intuitively obvious. It wasn't to me, but after some research and testing, I've come up with these simple steps:

  1. Boot into Recovery
  2. Connect via USB to ADB shell
    Code:
       C:\Scratch\Android> [B]adb devices[/B]
       C:\Scratch\Android> [B]adb shell[/B]
  3. Mount /system and /data to determine the /dev/block names, then umount each
    Code:
       ~ # [B]mount /system[/B]
       ~ # [B]mount /data[/B]
       ~ # [B]df[/B]
    Filesystem           1K-blocks      Used Available Use% Mounted on
    tmpfs                   308620        64    308556   0% /dev
    /dev/block/mmcblk0p27
                            295509    121021    159231  43% /cache
    /dev/block/mmcblk0p26
                           1184268    848052    276060  75% /data
    /dev/block/mmcblk0p25
                            562384    461416     72400  86% /system
       ~ # [B]umount /system[/B]
       ~ # [B]umount /data[/B]
  4. Run e2fsck against each /dev/block filesystem
    Code:
       ~ # [B]e2fsck -n /dev/block/mmcblk0p25[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p25: clean, 4168/35760 files, 117605/142847 blocks
       ~ # [B]e2fsck -n /dev/block/mmcblk0p26[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p26: clean, 7173/75200 files, 216745/300799 blocks
       ~ #
The 'e2fsck' command takes the same command-line switches as UNIX FSCK(8), so you can be as creative and daring as you need.

- Dave
on my phone i have a fiel called fsck.exfat and fsck_msod i think and im trying to run one (though not sure what the difference is) to fix some corrupted files in data internally. im trying to see if the file can be run through recovery without putting it through adb to unmount the data. im not too sure how to figure out what the data block is called because when i rum the mount i get a ton of different blocks (about 32 of them).
im trying to clean up the lost+found files i have and i have 3 of from a corrupted nandroid
 

ViperGeek

Senior Member
Sep 12, 2008
133
36
0
Merrimack, NH
on my phone i have a fiel called fsck.exfat and fsck_msod i think and im trying to run one (though not sure what the difference is) to fix some corrupted files in data internally. im trying to see if the file can be run through recovery without putting it through adb to unmount the data. im not too sure how to figure out what the data block is called because when i rum the mount i get a ton of different blocks (about 32 of them).
im trying to clean up the lost+found files i have and i have 3 of from a corrupted nandroid
Hi Rob.

I'm not sure if I can be of any specific assistance. exFAT is a type of filesystem format, like UNIX/Android ext3 and ext4, but beyond that, I couldn't tell you what those programs do. I do know that on some operating systems, the only way to fix the file chains and blocks is to make sure it's unmounted in single user mode. ADB is the closest we Android guys can get to UNIX single user mode without some clever Recovery Mode ZIP file programming.

– Dave
 
Last edited:
  • Like
Reactions: robcop19

robcop19

Senior Member
Mar 22, 2013
178
11
48
Atlanta
alrighty

Hi Rob.

I'm not sure if I can be of any specific assistance. , but beyond that, I couldn't tell you what those programs do. I do know that on some operating systems, the only way to fix the file chains and blocks is to make sure it's unmounted in single user mode. ADB is the closest we Android guys can get to UNIX single user mode without some clever Recovery Mode ZIP file programming.

– Dave
well thank you for at least writing back on it. im not sure how to run adb let alone run the progrma to try and fix this but i will be learning up on it
 

ViperGeek

Senior Member
Sep 12, 2008
133
36
0
Merrimack, NH
well thank you for at least writing back on it. im not sure how to run adb let alone run the progrma to try and fix this but i will be learning up on it
ADB isn't all that difficult to use. Here's a good primer on it:

http://droidlessons.com/how-to-install-adb-on-a-windows-7-pc/

Once installed, just boot your phone into Recovery (power off completely, then power on with the Vol Down key held, then select RECOVERY). Once it's sitting there, connect your phone to the PC via USB, wait for Windows to find the right drivers, and you're connected. 'adb devices' should list your phone in the "List of devices attached", after which you're good to go.

– Dave

ps. I've not tried it personally, but there's supposedly a "universal USB driver" available here:

https://plus.google.com/103583939320326217147/posts/BQ5iYJEaaEH
 

robcop19

Senior Member
Mar 22, 2013
178
11
48
Atlanta
wow

ADB isn't all that difficult to use. Here's a good primer on it:


Once installed, just boot your phone into Recovery (power off completely, then power on with the Vol Down key held, then select RECOVERY). Once it's sitting there, connect your phone to the PC via USB, wait for Windows to find the right drivers, and you're connected. 'adb devices' should list your phone in the "List of devices attached", after which you're good to go.

– Dave

ps. I've not tried it personally, but there's supposedly a "universal USB driver" available here:

Wow thank you very much for the help youre giving me I will see if i can go and start finding a solution
 
  • Like
Reactions: X-zone

irishpanther

Member
Jun 2, 2013
17
2
0
The 'e2fsck' command takes the same command-line switches as UNIX FSCK(8), so you can be as creative and daring as you need.

- Dave
I figured this out about a week ago now I guess and did indeed find that there were corrupted partitions. My phone had been acting up for several weeks before and it pretty much unusable now. I do manage to clean system and data up, and was even able to flash a new ROM which I hadn't been able to, they'd always abort.

I have a question though, is this only good for ext2 partitions? I have the same version as shown in the tutorial and if you run 'e2fsck -V' the output makes me think that maybe it's not happy checking ext3 and ext4 partitions and that's why i was popping up errors, or at least that's why even when i fixed errors it maybe wasn't really fixing the issue.

Thanks.

I've got a different phone, but a search brought me here to this thread. I think my issues though are more corrupted memory rather than device specific so hope you don't mind my post here.
 

ViperGeek

Senior Member
Sep 12, 2008
133
36
0
Merrimack, NH
One more helpful tidbit.

Even if you run 'e2fsck -n' and find a "clean" file system, it may be useful to force a scan via 'e2fsck -f'. This just happened to me. I had something funny going on, and so rebooted into recovery and checked my file systems. Everything was cool like Fonzie, which I didn't believe, and so I used 'e2fsck -f' and found lots of fuglies that got fixed.

Be careful running -f on a cross-linked file system like the /data partition on a Galaxy S3/S4. It can have the tendency to unlink the elfin magic Samsung used and make a mess.

- Dave
 
Last edited:

birdie

Senior Member
Nov 25, 2012
306
110
0
Vatican
This will not work with stock Android - default boot to recovery doesn't enable adb - you have to have CWM for that.

So, the questions remains - how can I run e2fsck without rooting my phone (and possibly voiding its warranty)?
 

krashd

Member
Aug 20, 2013
12
0
21
40
Dundee
www.mojeek.com
This will not work with stock Android - default boot to recovery doesn't enable adb - you have to have CWM for that.

So, the questions remains - how can I run e2fsck without rooting my phone (and possibly voiding its warranty)?
Is this why I get can't read '/etc/fstab': No such file or directory?

I'm using a stock Samsung S2, but it is rooted and has superuser and busybox.
 

cohosalmon

New member
Aug 30, 2017
4
1
0
Code:
I've been having lots of trouble with my SD and local filesystems getting corrupted, which in turn has been causing the flush-179 process to go ballistic (100% CPU loop, reboot hangs, etc.). If only there was a way to run a quick on my Android's unmounted filesystems to check for problems. Well, there is!

This may be old, old news to some of the more seasoned OS hackers, so please be kind with any negative feedback about it being intuitively obvious. It wasn't to me, but after some research and testing, I've come up with these simple steps:

  1. Boot into Recovery
  2. Connect via USB to ADB shell
    Code:
       C:\Scratch\Android> [B]adb devices[/B]
       C:\Scratch\Android> [B]adb shell[/B]
  3. Mount /system and /data to determine the /dev/block names, then umount each
    Code:
       ~ # [B]mount /system[/B]
       ~ # [B]mount /data[/B]
       ~ # [B]df[/B]
    Filesystem           1K-blocks      Used Available Use% Mounted on
    tmpfs                   308620        64    308556   0% /dev
    /dev/block/mmcblk0p27
                            295509    121021    159231  43% /cache
    /dev/block/mmcblk0p26
                           1184268    848052    276060  75% /data
    /dev/block/mmcblk0p25
                            562384    461416     72400  86% /system
       ~ # [B]umount /system[/B]
       ~ # [B]umount /data[/B]
  4. Run e2fsck against each /dev/block filesystem
    Code:
       ~ # [B]e2fsck -n /dev/block/mmcblk0p25[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p25: clean, 4168/35760 files, 117605/142847 blocks
       ~ # [B]e2fsck -n /dev/block/mmcblk0p26[/B]
    e2fsck 1.41.6 (30-May-2009)
    /dev/block/mmcblk0p26: clean, 7173/75200 files, 216745/300799 blocks
       ~ #
The 'e2fsck' command takes the same command-line switches as UNIX FSCK(8), so you can be as creative and daring as you need.

- Dave
Thank you for your very well done post. I also realize that this thread is very old. Still it is the best I have found after days of looking. And finally, I have a different phone. Having said that perhaps someone might help.

My phone is a Galaxy S5 Verizon SM-G900V running KitKat 4.4.4. I have root on the phone, but am running stock Verizon Kitkat with stock recovery.

So I have used ADB by plugging in my phone via USB to my Windows computer. I can get root in ADB and find the /data filesystem and its /dev/block/... device. But when I try to
Code:
umount /data
I get a response that the filesystem is busy. This makes sense.

I have booted into recovery via VOL UP + HOME + POWER and it takes me to the RECOVERY menu. But the only option that connects with my ADB shell is "apply update from ADB". When you use the command
Code:
ADB devices
, my phone shows up, but as "phoneid" sideload, and
Code:
ADB shell
exits immediately.

I have also tried to use a terminal shell and then su to root. Again I cannot umount /data since it is busy. (Of course it is, I am using it...)

And finally I have tried
Code:
touch /forcefsck
to create that file in the root directory. This is supposed to force a fsck during boot up. But the root directory (/) is read only. So you can't write the file to it.

I am at my wits end. What I really need to do is mark the /data filesystem as dirty and have the system check it on reboot. But I can't find anyway to do it.

So if anyone can help, I would be very grateful
Joe