[Arm-dev] File system corruption

Mon Dec 17 14:58:29 UTC 2018
Stephan Guilloux <stephan.guilloux at crisalid.com>

In case, some more info ...



F3 (Fight Fraud Flash) for Linux and MAC OS:
     https://github.com/AltraMayor/f3           (version 7.0 is 
available in EPEL)
Provides a few tools to check your SD, mainly the SD card size.




Linux can help to read SD info, via a bunch of /sys files:
     /sys/block/mmcblk0/alignment_offset:0
     /sys/block/mmcblk0/capability:50
     /sys/block/mmcblk0/dev:179:0
     /sys/block/mmcblk0/discard_alignment:0
     /sys/block/mmcblk0/ext_range:256
     /sys/block/mmcblk0/force_ro:0
     /sys/block/mmcblk0/inflight:       0        0
     /sys/block/mmcblk0/range:32
     /sys/block/mmcblk0/removable:0
     /sys/block/mmcblk0/ro:0
     /sys/block/mmcblk0/size:249737216
     /sys/block/mmcblk0/stat:  536330    94424 116053382  7343060 
446532   512290 83512784 532542040        0 13771000 540108990
     /sys/block/mmcblk0/uevent:MAJOR=179
     /sys/block/mmcblk0/uevent:MINOR=0
     /sys/block/mmcblk0/uevent:DEVNAME=mmcblk0
     /sys/block/mmcblk0/uevent:DEVTYPE=disk

     /sys/block/mmcblk0/device/cid:413432534443495430002d858f01229d
     /sys/block/mmcblk0/device/csd:400e00325b590000e93f7f800a400063
     /sys/block/mmcblk0/device/date:02/2018
     /sys/block/mmcblk0/device/dsr:0x404
     /sys/block/mmcblk0/device/erase_size:512
     /sys/block/mmcblk0/device/fwrev:0x0
     /sys/block/mmcblk0/device/hwrev:0x3
     /sys/block/mmcblk0/device/manfid:0x000041
     /sys/block/mmcblk0/device/name:SDCIT
     /sys/block/mmcblk0/device/ocr:0x00200000
     /sys/block/mmcblk0/device/oemid:0x3432
     /sys/block/mmcblk0/device/preferred_erase_size:4194304
     /sys/block/mmcblk0/device/scr:0235800201000000
     /sys/block/mmcblk0/device/serial:0x002d858f
/sys/block/mmcblk0/device/ssr:00000000050000000400900200ab1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
     /sys/block/mmcblk0/device/type:SD
     /sys/block/mmcblk0/device/uevent:DRIVER=mmcblk
     /sys/block/mmcblk0/device/uevent:MMC_TYPE=SD
     /sys/block/mmcblk0/device/uevent:MMC_NAME=SDCIT
     /sys/block/mmcblk0/device/uevent:MODALIAS=mmc:block

Some details on these fields can be found here:
     https://www.kernel.org/doc/Documentation/mmc/mmc-dev-attrs.txt

In our case, some of these files helped to identify a few fake SD:
- some SD 32Gb built in 2008 (bought this year) !!,
- some SD with a dummy serial number,
- ...

And below, some other info, mostly for some ID and manufacturers:
https://www.cameramemoryspeed.com/sd-memory-card-faq/reading-sd-card-cid-serial-psn-internal-numbers/



Le 13/12/2018 à 11:34, Stephan Guilloux a écrit :
> Hello all,
>
> I noticed many many filesystem corruptions, after raspberry 3B reboot.
> For instance, with image Raspberry 1804, "yum update and reboot" made 
> my RPM DB corrupted rather often after reboot.
> We found some other scenarios, but all less easy to reproduce.
>
> Somehow, we came to the conclusion that we had to start some kind of 
> stressing tool, and this how it comes out:
> - install SD-Card with last CentOS image available (kernel 4.14.82)
> - create a 4Gb primary partition #4, starting at 2Gb with help of fdisk.
> - then, grow partition #3 with rootfs-expand.
> - format partition #4 as EXT4, with default parameters.
>
> In a stress-loop
> - mount partition #4
> - copy huge number of files (/usr/) to partition #4
>    (cd /usr ; tar -c . ) | (cd /mnt/ ; tar -x)
> - umount part #4
> - fsck on partition #4
> The script breaks the loop when FSCK returns status different than 0.
> Only a couple of iterations are enough to crash partition #4.
>
> I just tried the same with EXT2, and result is identical.
>
>
> Any idea to make this "system" less vulnerable ?
>
>
> _______________________________________________
> Arm-dev mailing list
> Arm-dev at centos.org
> https://lists.centos.org/mailman/listinfo/arm-dev