# Corrupt SD - how to use fsck correctly?

**URL:** <https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285>\
**Category:** mangOH Red\
**Created:** [June 4, 2021, 6:41am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285 "2021-06-04T06:41:24Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 4, 2021, 6:41am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/1 "2021-06-04T06:41:24Z")

</div>

Hi everyone, I’m suffering from corrupted SD cards and am in need of a file system check (fsck).

I note that it is available through the command line (built into Busybox). From the command line (via SSH) I’ve tried:

```auto
 fsck -ANV /dev/mmcblk0p1

```

I get:

> fsck (busybox 1.27.2)  
> Checking all filesystems  
> root@swi-mdm9x28-wp:/mnt/userrw/sd#

As a response, but that’s it. Is there supposed to be more feedback?

Even just

```auto
fsck -V

```

Gives the same response.

I know for a fact that the SD card inserted has a bad file system and is marked read-only.

I figure I’m using it (fsck) incorrectly? Help please?  
Cheers,  
Terry

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 4, 2021, 6:58am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/2 "2021-06-04T06:58:34Z")

</div>

Suggest you trying fsck in Linux PC first.

Also are you using VFAT sytsem?

> [@Fscheck for vfat](https://mangoh.discourse.group/t/fscheck-for-vfat/5139):
>
> Hello, Our SD card in a mangoh red gets corrupted from time to time. We would like to run fsck, but the system reports that fsck.vfat is missing. Since fsck is within busybox, I guess that we need to update busybox by updating yocto?? Any idea? Thanks

---

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 4, 2021, 7:18am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/3 "2021-06-04T07:18:57Z")

</div>

I will try in a Linux PC, thanks.  
We are using FAT32. Do you recommend VFAT?

I saw that link you posted and unfortunately the link for the Yocto source for [[http://downloads.sierrawireless.com/AirPrime/WP77xx/Release13/Legato-Dist-Source-mdm9x06-SWI9X06Y\_02.35.02.00.tar.bz2](http://downloads.sierrawireless.com/AirPrime/WP77xx/Release13/Legato-Dist-Source-mdm9x06-SWI9X06Y_02.35.02.00.tar.bz2) ] is dead. It has been reported to Sierra Wireless, but it has not been fixed.

Do you have an alternate way of updating busybox? I’m not sure how to do it via Leaf

Thanks!  
Terry

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 4, 2021, 7:34am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/4 "2021-06-04T07:34:40Z")

</div>

you can try these binary first.  
[dosfstools.rar](https://mangoh.discourse.group/uploads/short-url/i4ygdgqCJuyPTkv8icOh4B14PD8.rar) (551.9 KB)

mkdir /tmp/fsck.vfat  
//now transfer those files in dosfstools.rar to /tmp/fsck.vfat folder via WINSCP  
chmod -R 777 /tmp/fsck.vfat/\*

```auto
root@swi-mdm9x28-wp:~# /tmp/fsck.vfat/fsck.vfat
CP437: Invalid argument
usage: /tmp/fsck.vfat/fsck.vfat [-aAbflrtvVwy] [-d path -d ...] [-u path -u ...]
               device
  -a automatically repair the filesystem
  -A toggle Atari filesystem format
  -b make read-only boot sector check
  -c N use DOS codepage N to decode short file names (default: 437)
  -d path drop that file
  -f salvage unused chains to files
  -l list path names
  -n no-op, check non-interactively without changing
  -p same as -a, for compat with other *fsck
  -r interactively repair the filesystem (default)
  -t test for bad clusters
  -u path try to undelete that (non-directory) file
  -v verbose mode
  -V perform a verification pass
  -w write changes to disk immediately
  -y same as -a, for compat with other *fsck
root@swi-mdm9x28-wp:~#

```

---

<div class="post-metadata">

**Author:** ![epastor](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@epastor](https://mangoh.discourse.group/u/epastor)\
**Post date:** [June 4, 2021, 9:11am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/5 "2021-06-04T09:11:53Z")

</div>

Hi,  
We can also provide the yocto compilation we made sometime ago.  
I will post it tomorrow, I don’t have the machine here with me.  
@jyijyi the rar you are providing is dos or yocto?  
regards

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 4, 2021, 9:13am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/6 "2021-06-04T09:13:54Z")

</div>

just some binary files:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/0/01526815b8b80687081a9abea50f125527ee23c8.png)

---

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 7, 2021, 12:20am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/7 "2021-06-07T00:20:11Z")

</div>

Thank you! I will try this shortly and let you know how I go

---

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 10, 2021, 5:05am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/8 "2021-06-10T05:05:33Z")

</div>

Hi everyone, the SCP method worked and I was able to fix the issues. However, I would like to perform this check automatically and have it built in (rebuild Yocto), but as mentioned before, the links are dead from Sierra Wireless.

@epastor are you able to share your compilation please? I would appreciate it greatly

Kind regards,  
Terry

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 10, 2021, 5:50am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/9 "2021-06-10T05:50:39Z")

</div>

you can save the binary tool in /home/root.  
also you can modify startlegato.sh to run init script to check.

> **[Adding scripts to run at startup](https://forum.legato.io/t/adding-scripts-to-run-at-startup/2412/7)**
>
> I just tried on WP76 R9, I found that modifying mount\_early is not working. Instead I modify /etc/init.d/startlegato.sh, and I can add my command there. case “$1” in start) echo “Legato start sequence 123” echo 123 \> /tmp/123.txt You can...

---

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 10, 2021, 7:18am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/10 "2021-06-10T07:18:51Z")

</div>

Thank you, I will try that

---

<div class="post-metadata">

**Author:** ![terryc](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@terryc](https://mangoh.discourse.group/u/terryc)\
**Post date:** [June 11, 2021, 5:34am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/11 "2021-06-11T05:34:37Z")

</div>

@jyijyi Thanks for your help so far - I’m nearly there!  
I have everything working, however I’m wondering if it is possible to write the output from fsck (-v verbose) to a text file in /tmp?

EDIT: I got it - append `| tee /tmp/fsck.txt`

Thanks again  
TC

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [June 11, 2021, 6:02am UTC](https://mangoh.discourse.group/t/corrupt-sd-how-to-use-fsck-correctly/9285/12 "2021-06-11T06:02:29Z")

</div>

this is also ok to me:

/tmp/fsck.vfat/fsck.vfat &\> /tmp/test.txt
